mirror of https://gitee.com/answerdev/answer.git
Merge branch 'ai_user_avatar' into 'main'
update userinfo show user set avatar See merge request opensource/answer!125
This commit is contained in:
commit
a613315f4f
98
docs/docs.go
98
docs/docs.go
|
@ -3326,7 +3326,7 @@ const docTemplate = `{
|
|||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/schema.GetUserResp"
|
||||
"$ref": "#/definitions/schema.GetUserToSetShowResp"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4853,6 +4853,102 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.GetUserToSetShowResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"access_token": {
|
||||
"description": "access token",
|
||||
"type": "string"
|
||||
},
|
||||
"answer_count": {
|
||||
"description": "answer count",
|
||||
"type": "integer"
|
||||
},
|
||||
"authority_group": {
|
||||
"description": "authority group",
|
||||
"type": "integer"
|
||||
},
|
||||
"avatar": {
|
||||
"$ref": "#/definitions/schema.AvatarInfo"
|
||||
},
|
||||
"bio": {
|
||||
"description": "bio markdown",
|
||||
"type": "string"
|
||||
},
|
||||
"bio_html": {
|
||||
"description": "bio html",
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"description": "create time",
|
||||
"type": "integer"
|
||||
},
|
||||
"display_name": {
|
||||
"description": "display name",
|
||||
"type": "string"
|
||||
},
|
||||
"e_mail": {
|
||||
"description": "email",
|
||||
"type": "string"
|
||||
},
|
||||
"follow_count": {
|
||||
"description": "follow count",
|
||||
"type": "integer"
|
||||
},
|
||||
"id": {
|
||||
"description": "user id",
|
||||
"type": "string"
|
||||
},
|
||||
"ip_info": {
|
||||
"description": "ip info",
|
||||
"type": "string"
|
||||
},
|
||||
"is_admin": {
|
||||
"description": "is admin",
|
||||
"type": "boolean"
|
||||
},
|
||||
"last_login_date": {
|
||||
"description": "last login date",
|
||||
"type": "integer"
|
||||
},
|
||||
"location": {
|
||||
"description": "location",
|
||||
"type": "string"
|
||||
},
|
||||
"mail_status": {
|
||||
"description": "mail status(1 pass 2 to be verified)",
|
||||
"type": "integer"
|
||||
},
|
||||
"mobile": {
|
||||
"description": "mobile",
|
||||
"type": "string"
|
||||
},
|
||||
"notice_status": {
|
||||
"description": "notice status(1 on 2off)",
|
||||
"type": "integer"
|
||||
},
|
||||
"question_count": {
|
||||
"description": "question count",
|
||||
"type": "integer"
|
||||
},
|
||||
"rank": {
|
||||
"description": "rank",
|
||||
"type": "integer"
|
||||
},
|
||||
"status": {
|
||||
"description": "user status",
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"description": "username",
|
||||
"type": "string"
|
||||
},
|
||||
"website": {
|
||||
"description": "website",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.GetVoteWithPageResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
@ -3314,7 +3314,7 @@
|
|||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/schema.GetUserResp"
|
||||
"$ref": "#/definitions/schema.GetUserToSetShowResp"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4841,6 +4841,102 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.GetUserToSetShowResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"access_token": {
|
||||
"description": "access token",
|
||||
"type": "string"
|
||||
},
|
||||
"answer_count": {
|
||||
"description": "answer count",
|
||||
"type": "integer"
|
||||
},
|
||||
"authority_group": {
|
||||
"description": "authority group",
|
||||
"type": "integer"
|
||||
},
|
||||
"avatar": {
|
||||
"$ref": "#/definitions/schema.AvatarInfo"
|
||||
},
|
||||
"bio": {
|
||||
"description": "bio markdown",
|
||||
"type": "string"
|
||||
},
|
||||
"bio_html": {
|
||||
"description": "bio html",
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"description": "create time",
|
||||
"type": "integer"
|
||||
},
|
||||
"display_name": {
|
||||
"description": "display name",
|
||||
"type": "string"
|
||||
},
|
||||
"e_mail": {
|
||||
"description": "email",
|
||||
"type": "string"
|
||||
},
|
||||
"follow_count": {
|
||||
"description": "follow count",
|
||||
"type": "integer"
|
||||
},
|
||||
"id": {
|
||||
"description": "user id",
|
||||
"type": "string"
|
||||
},
|
||||
"ip_info": {
|
||||
"description": "ip info",
|
||||
"type": "string"
|
||||
},
|
||||
"is_admin": {
|
||||
"description": "is admin",
|
||||
"type": "boolean"
|
||||
},
|
||||
"last_login_date": {
|
||||
"description": "last login date",
|
||||
"type": "integer"
|
||||
},
|
||||
"location": {
|
||||
"description": "location",
|
||||
"type": "string"
|
||||
},
|
||||
"mail_status": {
|
||||
"description": "mail status(1 pass 2 to be verified)",
|
||||
"type": "integer"
|
||||
},
|
||||
"mobile": {
|
||||
"description": "mobile",
|
||||
"type": "string"
|
||||
},
|
||||
"notice_status": {
|
||||
"description": "notice status(1 on 2off)",
|
||||
"type": "integer"
|
||||
},
|
||||
"question_count": {
|
||||
"description": "question count",
|
||||
"type": "integer"
|
||||
},
|
||||
"rank": {
|
||||
"description": "rank",
|
||||
"type": "integer"
|
||||
},
|
||||
"status": {
|
||||
"description": "user status",
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"description": "username",
|
||||
"type": "string"
|
||||
},
|
||||
"website": {
|
||||
"description": "website",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.GetVoteWithPageResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
@ -683,6 +683,77 @@ definitions:
|
|||
description: website
|
||||
type: string
|
||||
type: object
|
||||
schema.GetUserToSetShowResp:
|
||||
properties:
|
||||
access_token:
|
||||
description: access token
|
||||
type: string
|
||||
answer_count:
|
||||
description: answer count
|
||||
type: integer
|
||||
authority_group:
|
||||
description: authority group
|
||||
type: integer
|
||||
avatar:
|
||||
$ref: '#/definitions/schema.AvatarInfo'
|
||||
bio:
|
||||
description: bio markdown
|
||||
type: string
|
||||
bio_html:
|
||||
description: bio html
|
||||
type: string
|
||||
created_at:
|
||||
description: create time
|
||||
type: integer
|
||||
display_name:
|
||||
description: display name
|
||||
type: string
|
||||
e_mail:
|
||||
description: email
|
||||
type: string
|
||||
follow_count:
|
||||
description: follow count
|
||||
type: integer
|
||||
id:
|
||||
description: user id
|
||||
type: string
|
||||
ip_info:
|
||||
description: ip info
|
||||
type: string
|
||||
is_admin:
|
||||
description: is admin
|
||||
type: boolean
|
||||
last_login_date:
|
||||
description: last login date
|
||||
type: integer
|
||||
location:
|
||||
description: location
|
||||
type: string
|
||||
mail_status:
|
||||
description: mail status(1 pass 2 to be verified)
|
||||
type: integer
|
||||
mobile:
|
||||
description: mobile
|
||||
type: string
|
||||
notice_status:
|
||||
description: notice status(1 on 2off)
|
||||
type: integer
|
||||
question_count:
|
||||
description: question count
|
||||
type: integer
|
||||
rank:
|
||||
description: rank
|
||||
type: integer
|
||||
status:
|
||||
description: user status
|
||||
type: string
|
||||
username:
|
||||
description: username
|
||||
type: string
|
||||
website:
|
||||
description: website
|
||||
type: string
|
||||
type: object
|
||||
schema.GetVoteWithPageResp:
|
||||
properties:
|
||||
answer_id:
|
||||
|
@ -3305,7 +3376,7 @@ paths:
|
|||
- $ref: '#/definitions/handler.RespBody'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/schema.GetUserResp'
|
||||
$ref: '#/definitions/schema.GetUserToSetShowResp'
|
||||
type: object
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
|
|
|
@ -52,7 +52,7 @@ func NewUserController(
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {object} handler.RespBody{data=schema.GetUserResp}
|
||||
// @Success 200 {object} handler.RespBody{data=schema.GetUserToSetShowResp}
|
||||
// @Router /answer/api/v1/user/info [get]
|
||||
func (uc *UserController) GetUserInfoByUserID(ctx *gin.Context) {
|
||||
userID := middleware.GetLoginUserIDFromContext(ctx)
|
||||
|
|
|
@ -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