feat: adjusting the field length

This commit is contained in:
LinkinStar 2022-09-29 16:39:34 +08:00
parent a27821e174
commit b416f17526
6 changed files with 29 additions and 45 deletions

View File

@ -328,15 +328,15 @@ func (uc *UserController) UserModifyPassWord(ctx *gin.Context) {
handler.HandleResponse(ctx, err, nil)
}
// UserUpdateInfo godoc
// @Summary UserUpdateInfo
// @Description UserUpdateInfo
// UserUpdateInfo update user info
// @Summary UserUpdateInfo update user info
// @Description UserUpdateInfo update user info
// @Tags User
// @Accept json
// @Produce json
// @Security ApiKeyAuth
// @Param Authorization header string true "access-token"
// @Param data body schema.UpdateInfoRequest true "UpdateInfoRequest"
// @Param data body schema.UpdateInfoRequest true "UpdateInfoRequest"
// @Success 200 {object} handler.RespBody
// @Router /answer/api/v1/user/info [put]
func (uc *UserController) UserUpdateInfo(ctx *gin.Context) {

View File

@ -36,7 +36,7 @@ type User struct {
Rank int `xorm:"not null default 0 comment('rank') INT(11) rank"`
Status int `xorm:"not null default 1 comment('user status(available: 1; deleted: 10)') INT(11) status"`
AuthorityGroup int `xorm:"not null default 1 comment('authority group') INT(11) authority_group"`
DisplayName string `xorm:"not null default '' comment('display name') VARCHAR(50) display_name"`
DisplayName string `xorm:"not null default '' comment('display name') VARCHAR(30) display_name"`
Avatar string `xorm:"not null default '' comment('avatar') VARCHAR(255) avatar"`
Mobile string `xorm:"not null comment('mobile') VARCHAR(20) mobile"`
Bio string `xorm:"not null comment('bio markdown') TEXT bio"`

View File

@ -22,7 +22,7 @@ type CloseQuestionMeta struct {
type QuestionAdd struct {
// question title
Title string `validate:"required,gte=6,lte=64" json:"title"`
Title string `validate:"required,gte=6,lte=150" json:"title"`
// content
Content string `validate:"required,gte=6,lte=65535" json:"content"`
// html
@ -37,7 +37,7 @@ type QuestionUpdate struct {
// question id
ID string `validate:"required" json:"id"`
// question title
Title string `validate:"required,gte=6,lte=64" json:"title"`
Title string `validate:"required,gte=6,lte=150" json:"title"`
// content
Content string `validate:"required,gte=6,lte=65535" json:"content"`
// html

View File

@ -11,7 +11,7 @@ import (
// SearchTagLikeReq get tag list all request
type SearchTagLikeReq struct {
// tag
Tag string `validate:"required,gt=0,lte=50" form:"tag"`
Tag string `validate:"required,gt=0,lte=35" form:"tag"`
}
// GetTagInfoReq get tag info request
@ -19,7 +19,7 @@ type GetTagInfoReq struct {
// tag id
ID string `validate:"omitempty" form:"id"`
// tag slug name
Name string `validate:"omitempty,gt=0,lte=50" form:"name"`
Name string `validate:"omitempty,gt=0,lte=35" form:"name"`
// user id
UserID string `json:"-"`
}
@ -115,9 +115,9 @@ type TagChange struct {
type TagItem struct {
// slug_name
SlugName string `validate:"omitempty,gt=0,lte=50" json:"slug_name"`
SlugName string `validate:"omitempty,gt=0,lte=35" json:"slug_name"`
// display_name
DisplayName string `validate:"omitempty,gt=0,lte=50" json:"display_name"`
DisplayName string `validate:"omitempty,gt=0,lte=35" json:"display_name"`
// original text
OriginalText string `validate:"omitempty" json:"original_text"`
// parsed text
@ -137,9 +137,9 @@ type UpdateTagReq struct {
// tag_id
TagID string `validate:"required" json:"tag_id"`
// slug_name
SlugName string `validate:"omitempty,gt=0,lte=50" json:"slug_name"`
SlugName string `validate:"omitempty,gt=0,lte=35" json:"slug_name"`
// display_name
DisplayName string `validate:"omitempty,gt=0,lte=50" json:"display_name"`
DisplayName string `validate:"omitempty,gt=0,lte=35" json:"display_name"`
// original text
OriginalText string `validate:"omitempty" json:"original_text"`
// parsed text
@ -164,9 +164,9 @@ type GetTagWithPageReq struct {
// page size
PageSize int `validate:"omitempty,min=1" form:"page_size"`
// slug_name
SlugName string `validate:"omitempty,gt=0,lte=50" form:"slug_name"`
SlugName string `validate:"omitempty,gt=0,lte=35" form:"slug_name"`
// display_name
DisplayName string `validate:"omitempty,gt=0,lte=50" form:"display_name"`
DisplayName string `validate:"omitempty,gt=0,lte=35" form:"display_name"`
// query condition
QueryCond string `validate:"omitempty,oneof=popular name newest" form:"query_cond"`
// user id

View File

@ -226,14 +226,20 @@ func (u *UserModifyPassWordRequest) Check() (errField *validator.ErrorField, err
}
type UpdateInfoRequest struct {
UserId string `json:"-" ` // user_id
UserName string `json:"username"` // name
DisplayName string `json:"display_name" ` // display_name
Avatar string `json:"avatar" ` // avatar
Bio string `json:"bio"`
BioHtml string `json:"bio_html"`
Website string `json:"website" ` // website
Location string `json:"location"` // location
// display_name
DisplayName string `validate:"required,gt=0,lte=30" json:"display_name"`
// avatar
Avatar string `validate:"omitempty,gt=0,lte=500" json:"avatar"`
// bio
Bio string `validate:"omitempty,gt=0,lte=4096" json:"bio"`
// bio
BioHtml string `validate:"omitempty,gt=0,lte=4096" json:"bio_html"`
// website
Website string `validate:"omitempty,gt=0,lte=500" json:"website"`
// location
Location string `validate:"omitempty,gt=0,lte=100" json:"location"`
// user id
UserId string `json:"-" `
}
type UserRetrievePassWordRequest struct {

View File

@ -235,30 +235,8 @@ func (us *UserService) UserModifyPassWord(ctx context.Context, request *schema.U
// UpdateInfo
func (us *UserService) UpdateInfo(ctx context.Context, request *schema.UpdateInfoRequest) error {
// formatName, pass := us.CheckUserName(ctx, request.Username)
// if !pass {
// return fmt.Errorf("username format error")
// }
// dbuserinfo, has, err := us.userRepo.GetUserInfoByUserID(ctx, request.UserID)
// if err != nil {
// return err
// }
// if !has {
// return fmt.Errorf("user does not exist")
// }
// dbNameUserInfo, has, err := us.userRepo.GetOtherUserInfoByUsername(ctx, formatName)
// if err != nil {
// return err
// }
// if has {
// if dbuserinfo.TagID != dbNameUserInfo.TagID {
// return fmt.Errorf("username already exists")
// }
// }
userinfo := entity.User{}
userinfo.ID = request.UserId
//userinfo.Username = formatName
userinfo.Avatar = request.Avatar
userinfo.DisplayName = request.DisplayName
userinfo.Bio = request.Bio