youtu_ecpm/api/gin/controller/app_user_info.go
2025-01-20 00:14:43 +08:00

44 lines
1.2 KiB
Go

package controller
import (
"gitea.youtukeji.com.cn/xiabin/youtu_ecpm/api/gin/service"
"gitea.youtukeji.com.cn/xiabin/youtu_ecpm/dao/query"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
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"` // 昵称
Avatar string `gorm:"column:avatar;type:varchar(255);not null;comment:头像" json:"avatar" 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.Avatar); err != nil {
ctl.logger.Sugar().Error(err)
ctl.ResponseErr(c, err)
return
}
c.JSON(200, "ok")
}