MCPcopy Index your code
hub / github.com/apache/answer / GetUserInfoByUserID

Method GetUserInfoByUserID

internal/service/content/user_service.go:109–132  ·  view source on GitHub ↗

GetUserInfoByUserID get user info by user id

(ctx context.Context, token, userID string)

Source from the content-addressed store, hash-verified

107
108// GetUserInfoByUserID get user info by user id
109func (us *UserService) GetUserInfoByUserID(ctx context.Context, token, userID string) (
110 resp *schema.GetCurrentLoginUserInfoResp, err error) {
111 userInfo, exist, err := us.userRepo.GetByUserID(ctx, userID)
112 if err != nil {
113 return nil, err
114 }
115 if !exist {
116 return nil, errors.BadRequest(reason.UserNotFound)
117 }
118 if userInfo.Status == entity.UserStatusDeleted {
119 return nil, errors.Unauthorized(reason.UnauthorizedError)
120 }
121
122 resp = &schema.GetCurrentLoginUserInfoResp{}
123 resp.ConvertFromUserEntity(userInfo)
124 resp.RoleID, err = us.userRoleService.GetUserRole(ctx, userInfo.ID)
125 if err != nil {
126 log.Error(err)
127 }
128 resp.Avatar = us.siteInfoService.FormatAvatar(ctx, userInfo.Avatar, userInfo.EMail, userInfo.Status)
129 resp.AccessToken = token
130 resp.HavePassword = len(userInfo.Pass) > 0
131 return resp, nil
132}
133
134func (us *UserService) GetOtherUserInfoByUsername(ctx context.Context, req *schema.GetOtherUserInfoByUsernameReq) (
135 resp *schema.GetOtherUserInfoByUsernameResp, err error) {

Callers

nothing calls this directly

Calls 4

GetUserRoleMethod · 0.80
GetByUserIDMethod · 0.65
FormatAvatarMethod · 0.65
ConvertFromUserEntityMethod · 0.45

Tested by

no test coverage detected