fix: unify user ID type to string and rename service to users-api

This commit is contained in:
zetaloop
2026-04-22 22:03:49 +08:00
parent 59256897e9
commit b3db04c9cc
11 changed files with 59 additions and 28 deletions
@@ -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