youtu_ecpm/api/gin/controller/app_user_info.go

44 lines
1.2 KiB
Go
Raw Permalink Normal View History

2025-01-18 17:56:36 +08:00
package controller
import (
2025-01-20 00:11:11 +08:00
"gitea.youtukeji.com.cn/xiabin/youtu_ecpm/api/gin/service"
"gitea.youtukeji.com.cn/xiabin/youtu_ecpm/dao/query"
2025-01-18 17:56:36 +08:00
"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"`
2025-01-18 19:02:58 +08:00
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"` // 头像
2025-01-18 17:56:36 +08:00
}
if err := c.ShouldBind(&req); err != nil {
ctl.logger.Sugar().Error(err)
ctl.ResponseErr(c, err)
return
}
2025-01-18 19:02:58 +08:00
if err := ctl.appUser.UpdateUserNickNameAndImageUrl(c, req.ID, req.Nickname, req.Avatar); err != nil {
2025-01-18 17:56:36 +08:00
ctl.logger.Sugar().Error(err)
ctl.ResponseErr(c, err)
return
}
c.JSON(200, "ok")
}