fix: unify user ID type to string and rename service to users-api
This commit is contained in:
@@ -6,6 +6,8 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"juwan-backend/app/users/api/internal/svc"
|
||||
"juwan-backend/app/users/api/internal/types"
|
||||
"juwan-backend/app/users/rpc/usercenter"
|
||||
@@ -30,9 +32,13 @@ func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUs
|
||||
}
|
||||
|
||||
func (l *GetUserInfoLogic) GetUserInfo(req *types.GetUserReq) (resp types.User, err error) {
|
||||
targetId, err := strconv.ParseInt(req.Id, 10, 64)
|
||||
if err != nil {
|
||||
return types.User{}, errors.New("invalid user id")
|
||||
}
|
||||
|
||||
pbUser, err := l.svcCtx.UserRpc.GetUsersById(l.ctx, &usercenter.GetUsersByIdReq{
|
||||
Id: req.Id,
|
||||
Id: targetId,
|
||||
})
|
||||
if err != nil {
|
||||
return types.User{}, errors.New("failed to get user info by userid")
|
||||
@@ -44,6 +50,7 @@ func (l *GetUserInfoLogic) GetUserInfo(req *types.GetUserReq) (resp types.User,
|
||||
logx.Errorf("struct to user info failed, err:%v.", err)
|
||||
return types.User{}, errors.New("failed to get user info by userid")
|
||||
}
|
||||
user.Id = strconv.FormatInt(pbUser.Users.Id, 10)
|
||||
user.Role = pbUser.Users.CurrentRole
|
||||
|
||||
return user, nil
|
||||
|
||||
Reference in New Issue
Block a user