GetUserInfoByUserID get user info by user id
(ctx context.Context, token, userID string)
| 107 | |
| 108 | // GetUserInfoByUserID get user info by user id |
| 109 | func (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 | |
| 134 | func (us *UserService) GetOtherUserInfoByUsername(ctx context.Context, req *schema.GetOtherUserInfoByUsernameReq) ( |
| 135 | resp *schema.GetOtherUserInfoByUsernameResp, err error) { |
nothing calls this directly
no test coverage detected