44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
|
package controller
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"go.uber.org/zap"
|
||
|
"youtu_ecpm/api/gin/service"
|
||
|
"youtu_ecpm/dao/query"
|
||
|
)
|
||
|
|
||
|
type AppUserInfo struct {
|
||
|
*Controller
|
||
|
logger *zap.Logger
|
||
|
appUser *service.AppUserInfo
|
||
|
}
|
||
|
|
||
|
func NewAppUserInfoController(logger *zap.Logger, q *query.Query) *AppUserInfo {
|
||
|
return &AppUserInfo{
|
||
|
logger: logger,
|
||
|
appUser: service.NewAppUserInfo(q),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (ctl *AppUserInfo) SetAppAccount(c *gin.Context) {
|
||
|
var req struct {
|
||
|
ID uint64 `gorm:"column:id;type:bigint unsigned;primaryKey;autoIncrement:true" json:"id" binding:"required"`
|
||
|
Nickname string `gorm:"column:nickname;type:varchar(255);not null;comment:昵称" json:"nickname" binding:"required"` // 昵称
|
||
|
ImageURL string `gorm:"column:image_url;type:varchar(255);not null;comment:头像" json:"image_url" binding:"required"` // 头像
|
||
|
}
|
||
|
|
||
|
if err := c.ShouldBind(&req); err != nil {
|
||
|
ctl.logger.Sugar().Error(err)
|
||
|
ctl.ResponseErr(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if err := ctl.appUser.UpdateUserNickNameAndImageUrl(c, req.ID, req.Nickname, req.ImageURL); err != nil {
|
||
|
ctl.logger.Sugar().Error(err)
|
||
|
ctl.ResponseErr(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.JSON(200, "ok")
|
||
|
}
|