mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 10:52:33 +08:00
update user command
This commit is contained in:
parent
90553530a6
commit
dcee679f48
@ -111,14 +111,26 @@ func (u *UserMgo) UpdateUserCommand(ctx context.Context, userID string, Type int
|
|||||||
}
|
}
|
||||||
func (u *UserMgo) GetUserCommands(ctx context.Context, userID string, Type int32) (map[string]user.CommandInfo, error) {
|
func (u *UserMgo) GetUserCommands(ctx context.Context, userID string, Type int32) (map[string]user.CommandInfo, error) {
|
||||||
collection := u.coll.Database().Collection("userCommands")
|
collection := u.coll.Database().Collection("userCommands")
|
||||||
|
|
||||||
filter := bson.M{"userID": userID, "type": Type}
|
filter := bson.M{"userID": userID, "type": Type}
|
||||||
var result UserCommand
|
|
||||||
err := collection.FindOne(ctx, filter).Decode(&result)
|
cursor, err := collection.Find(ctx, filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return result.Commands, nil
|
defer cursor.Close(ctx)
|
||||||
|
results := make(map[string]user.CommandInfo)
|
||||||
|
for cursor.Next(ctx) {
|
||||||
|
var result struct {
|
||||||
|
Key string `bson:"key"`
|
||||||
|
Value user.CommandInfo `bson:"value"`
|
||||||
|
}
|
||||||
|
err = cursor.Decode(&result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
results[result.Key] = result.Value
|
||||||
|
}
|
||||||
|
return results, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserMgo) CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error) {
|
func (u *UserMgo) CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user