From 5eec833c74872cbf9194702b0d35b6975598c126 Mon Sep 17 00:00:00 2001 From: AndrewZuo01 Date: Tue, 12 Dec 2023 15:34:44 +0800 Subject: [PATCH] update user command --- internal/rpc/user/user.go | 18 +++++++++++------- pkg/common/db/mgo/user.go | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 4d952389f..8db54ad4c 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -375,13 +375,17 @@ func (s *userServer) ProcessUserCommandGet(ctx context.Context, req *pbuser.Proc return nil, err } - // Create a new map with the required type - commandPointers := make(map[string]*pbuser.CommandInfo) - for k, v := range commands { - vCopy := v // Create a copy of v - commandPointers[k] = &vCopy + // Create a slice to store CommandInfoResp + var commandInfoSlice []*pbuser.CommandInfoResp + + for _, v := range commands { + commandInfoSlice = append(commandInfoSlice, &pbuser.CommandInfoResp{ + Uuid: v.Uuid, + Value: v.Value, + CreateTime: v.CreateTime, + }) } - // Return the new map - return &pbuser.ProcessUserCommandGetResp{UuidValue: commandPointers}, nil + // Return the new slice + return &pbuser.ProcessUserCommandGetResp{KVArray: commandInfoSlice}, nil } diff --git a/pkg/common/db/mgo/user.go b/pkg/common/db/mgo/user.go index 79f77024b..94d7c99bb 100644 --- a/pkg/common/db/mgo/user.go +++ b/pkg/common/db/mgo/user.go @@ -128,7 +128,7 @@ func (u *UserMgo) GetUserCommands(ctx context.Context, userID string, Type int32 var document struct { UUID string `bson:"uuid"` Value string `bson:"value"` - CreateTime int64 `bson:"createTime"` + CreateTime int64 `bson:"time"` } if err := cursor.Decode(&document); err != nil {