mirror of https://gitee.com/answerdev/answer.git
update userinfo show user set avatar
This commit is contained in:
parent
9b6a35d88b
commit
5ecac4dda3
|
@ -82,6 +82,27 @@ func (r *GetUserResp) GetFromUserEntity(userInfo *entity.User) {
|
|||
}
|
||||
}
|
||||
|
||||
type GetUserToSetShowResp struct {
|
||||
*GetUserResp
|
||||
Avatar *AvatarInfo `json:"avatar"`
|
||||
}
|
||||
|
||||
func (r *GetUserToSetShowResp) GetFromUserEntity(userInfo *entity.User) {
|
||||
_ = copier.Copy(r, userInfo)
|
||||
r.CreatedAt = userInfo.CreatedAt.Unix()
|
||||
r.LastLoginDate = userInfo.LastLoginDate.Unix()
|
||||
statusShow, ok := UserStatusShow[userInfo.Status]
|
||||
if ok {
|
||||
r.Status = statusShow
|
||||
}
|
||||
AvatarInfo := &AvatarInfo{}
|
||||
err := json.Unmarshal([]byte(userInfo.Avatar), AvatarInfo)
|
||||
if err != nil {
|
||||
log.Error("AvatarInfo json.Unmarshal Error", err)
|
||||
}
|
||||
r.Avatar = AvatarInfo
|
||||
}
|
||||
|
||||
func (us *GetUserResp) AvatarInfo(avatarJson string) string {
|
||||
if avatarJson == "" {
|
||||
return ""
|
||||
|
|
|
@ -51,7 +51,7 @@ func NewUserService(userRepo usercommon.UserRepo,
|
|||
}
|
||||
|
||||
// GetUserInfoByUserID get user info by user id
|
||||
func (us *UserService) GetUserInfoByUserID(ctx context.Context, token, userID string) (resp *schema.GetUserResp, err error) {
|
||||
func (us *UserService) GetUserInfoByUserID(ctx context.Context, token, userID string) (resp *schema.GetUserToSetShowResp, err error) {
|
||||
userInfo, exist, err := us.userRepo.GetByUserID(ctx, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -59,7 +59,7 @@ func (us *UserService) GetUserInfoByUserID(ctx context.Context, token, userID st
|
|||
if !exist {
|
||||
return nil, errors.BadRequest(reason.UserNotFound)
|
||||
}
|
||||
resp = &schema.GetUserResp{}
|
||||
resp = &schema.GetUserToSetShowResp{}
|
||||
resp.GetFromUserEntity(userInfo)
|
||||
resp.AccessToken = token
|
||||
return resp, nil
|
||||
|
|
Loading…
Reference in New Issue