Merge branch 'ai_update_user_avatar' into 'main'

update AvatarInfo to show img

See merge request opensource/answer!129
This commit is contained in:
linkinstar 2022-10-31 03:11:47 +00:00
commit 3cde88e7d6
2 changed files with 7 additions and 5 deletions

View File

@ -73,7 +73,7 @@ type GetUserResp struct {
func (r *GetUserResp) GetFromUserEntity(userInfo *entity.User) {
_ = copier.Copy(r, userInfo)
r.Avatar = r.AvatarInfo(userInfo.Avatar)
r.Avatar = FormatAvatarInfo(userInfo.Avatar)
r.CreatedAt = userInfo.CreatedAt.Unix()
r.LastLoginDate = userInfo.LastLoginDate.Unix()
statusShow, ok := UserStatusShow[userInfo.Status]
@ -103,7 +103,7 @@ func (r *GetUserToSetShowResp) GetFromUserEntity(userInfo *entity.User) {
r.Avatar = avatarInfo
}
func (us *GetUserResp) AvatarInfo(avatarJson string) string {
func FormatAvatarInfo(avatarJson string) string {
if avatarJson == "" {
return ""
}
@ -172,6 +172,9 @@ type GetOtherUserInfoByUsernameResp struct {
func (r *GetOtherUserInfoByUsernameResp) GetFromUserEntity(userInfo *entity.User) {
_ = copier.Copy(r, userInfo)
Avatar := FormatAvatarInfo(userInfo.Avatar)
r.Avatar = Avatar
r.CreatedAt = userInfo.CreatedAt.Unix()
r.LastLoginDate = userInfo.LastLoginDate.Unix()
statusShow, ok := UserStatusShow[userInfo.Status]

View File

@ -76,13 +76,12 @@ func (us *UserCommon) BatchUserBasicInfoByID(ctx context.Context, IDs []string)
// UserBasicInfoFormat
func (us *UserCommon) UserBasicInfoFormat(ctx context.Context, userInfo *entity.User) *schema.UserBasicInfo {
userBasicInfo := &schema.UserBasicInfo{}
uinfo := &schema.GetUserResp{}
uinfo.AvatarInfo(userInfo.Avatar)
Avatar := schema.FormatAvatarInfo(userInfo.Avatar)
userBasicInfo.ID = userInfo.ID
userBasicInfo.Username = userInfo.Username
userBasicInfo.Rank = userInfo.Rank
userBasicInfo.DisplayName = userInfo.DisplayName
userBasicInfo.Avatar = uinfo.Avatar
userBasicInfo.Avatar = Avatar
userBasicInfo.Website = userInfo.Website
userBasicInfo.Location = userInfo.Location
userBasicInfo.IpInfo = userInfo.IPInfo