update user command

pull/1532/head
AndrewZuo01 2 years ago
parent 72ef3d1a7f
commit 90553530a6

@ -368,7 +368,6 @@ func (s *userServer) ProcessUserCommandUpdate(ctx context.Context, req *pbuser.P
return &pbuser.ProcessUserCommandUpdateResp{}, nil return &pbuser.ProcessUserCommandUpdateResp{}, nil
} }
// ProcessUserCommandGet user general function get
func (s *userServer) ProcessUserCommandGet(ctx context.Context, req *pbuser.ProcessUserCommandGetReq) (*pbuser.ProcessUserCommandGetResp, error) { func (s *userServer) ProcessUserCommandGet(ctx context.Context, req *pbuser.ProcessUserCommandGetReq) (*pbuser.ProcessUserCommandGetResp, error) {
// Fetch user commands from the database // Fetch user commands from the database
commands, err := s.UserDatabase.GetUserCommands(ctx, req.UserID, req.Type) commands, err := s.UserDatabase.GetUserCommands(ctx, req.UserID, req.Type)
@ -376,6 +375,13 @@ func (s *userServer) ProcessUserCommandGet(ctx context.Context, req *pbuser.Proc
return nil, err return nil, err
} }
// The commands variable is already a map[string]string, so you can directly return it // Create a new map with the required type
return &pbuser.ProcessUserCommandGetResp{UuidValue: commands}, nil commandPointers := make(map[string]*pbuser.CommandInfo)
for k, v := range commands {
vCopy := v // Create a copy of v
commandPointers[k] = &vCopy
}
// Return the new map
return &pbuser.ProcessUserCommandGetResp{UuidValue: commandPointers}, nil
} }

Loading…
Cancel
Save