update user command

pull/1532/head
AndrewZuo01 2 years ago
parent e0d17df248
commit 5eec833c74

@ -375,13 +375,17 @@ func (s *userServer) ProcessUserCommandGet(ctx context.Context, req *pbuser.Proc
return nil, err return nil, err
} }
// Create a new map with the required type // Create a slice to store CommandInfoResp
commandPointers := make(map[string]*pbuser.CommandInfo) var commandInfoSlice []*pbuser.CommandInfoResp
for k, v := range commands {
vCopy := v // Create a copy of v for _, v := range commands {
commandPointers[k] = &vCopy commandInfoSlice = append(commandInfoSlice, &pbuser.CommandInfoResp{
Uuid: v.Uuid,
Value: v.Value,
CreateTime: v.CreateTime,
})
} }
// Return the new map // Return the new slice
return &pbuser.ProcessUserCommandGetResp{UuidValue: commandPointers}, nil return &pbuser.ProcessUserCommandGetResp{KVArray: commandInfoSlice}, nil
} }

@ -128,7 +128,7 @@ func (u *UserMgo) GetUserCommands(ctx context.Context, userID string, Type int32
var document struct { var document struct {
UUID string `bson:"uuid"` UUID string `bson:"uuid"`
Value string `bson:"value"` Value string `bson:"value"`
CreateTime int64 `bson:"createTime"` CreateTime int64 `bson:"time"`
} }
if err := cursor.Decode(&document); err != nil { if err := cursor.Decode(&document); err != nil {

Loading…
Cancel
Save