diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index c6391bcb3..49f800242 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -141,7 +141,7 @@ func (s *userServer) GetAllConversationMsgOpt(ctx context.Context, req *pbUser.G } func (s *userServer) DeleteUsers(_ context.Context, req *pbUser.DeleteUsersReq) (*pbUser.DeleteUsersResp, error) { log.NewInfo(req.OperationID, "DeleteUsers args ", req.String()) - if token_verify.IsMangerUserID(req.OpUserID) { + if !token_verify.IsMangerUserID(req.OpUserID) { log.NewError(req.OperationID, "IsMangerUserID false ", req.OpUserID) return &pbUser.DeleteUsersResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, FailedUserIDList: req.DeleteUserIDList}, nil } @@ -161,7 +161,7 @@ func (s *userServer) DeleteUsers(_ context.Context, req *pbUser.DeleteUsersReq) func (s *userServer) GetAllUserID(_ context.Context, req *pbUser.GetAllUserIDReq) (*pbUser.GetAllUserIDResp, error) { log.NewInfo(req.OperationID, "GetAllUserID args ", req.String()) - if token_verify.IsMangerUserID(req.OpUserID) { + if !token_verify.IsMangerUserID(req.OpUserID) { log.NewError(req.OperationID, "IsMangerUserID false ", req.OpUserID) return &pbUser.GetAllUserIDResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil } @@ -177,11 +177,12 @@ func (s *userServer) GetAllUserID(_ context.Context, req *pbUser.GetAllUserIDReq func (s *userServer) AccountCheck(_ context.Context, req *pbUser.AccountCheckReq) (*pbUser.AccountCheckResp, error) { log.NewInfo(req.OperationID, "AccountCheck args ", req.String()) - if token_verify.IsMangerUserID(req.OpUserID) { + if !token_verify.IsMangerUserID(req.OpUserID) { log.NewError(req.OperationID, "IsMangerUserID false ", req.OpUserID) return &pbUser.AccountCheckResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil } uidList, err := imdb.SelectSomeUserID(req.CheckUserIDList) + log.NewDebug(req.OperationID, "from db uid list is:", uidList) if err != nil { log.NewError(req.OperationID, "SelectSomeUserID failed ", err.Error(), req.CheckUserIDList) return &pbUser.AccountCheckResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil diff --git a/pkg/common/db/mysql_model/im_mysql_model/user_model.go b/pkg/common/db/mysql_model/im_mysql_model/user_model.go index 8a4900ee1..fbc382718 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/user_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/user_model.go @@ -112,10 +112,10 @@ func SelectSomeUserID(userIDList []string) ([]string, error) { if err != nil { return nil, err } - var userList []User - err = dbConn.Table("user").Where("(user_id) IN ? ", userIDList).Find(&userList).Error + var resultArr []string + err = dbConn.Table("user").Where("(user_id) IN ? ", userIDList).Pluck("user_id", &resultArr).Error if err != nil { return nil, err } - return userIDList, nil + return resultArr, nil }