🎨 新增批量修改包月服务价格功能&新增讲师管理相关功能
This commit is contained in:
@@ -110,3 +110,21 @@ func (a *TeacherVip) GetTeacherVip(context *gin.Context) {
|
|||||||
}
|
}
|
||||||
r.OkWithDetailed(vip, "获取讲师VIP成功", context)
|
r.OkWithDetailed(vip, "获取讲师VIP成功", context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdatePriceBatch 批量更新价格
|
||||||
|
func (a *TeacherVip) UpdatePriceBatch(context *gin.Context) {
|
||||||
|
var p request.UpdateTeacherVipPriceBatch
|
||||||
|
if err := context.ShouldBind(&p); err != nil {
|
||||||
|
global.GVA_LOG.Error("参数错误,批量更新价格失败", zap.Error(err))
|
||||||
|
r.FailWithMessage("参数错误,批量更新价格失败", context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err := teacherVipService.UpdatePriceBatch(p)
|
||||||
|
if err != nil {
|
||||||
|
r.FailWithMessage("批量更新价格失败", context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
r.OkWithMessage("批量更新价格成功", context)
|
||||||
|
}
|
||||||
|
|||||||
@@ -236,3 +236,39 @@ func (a *UserApi) GetUserVipList(context *gin.Context) {
|
|||||||
PageSize: p.PageSize,
|
PageSize: p.PageSize,
|
||||||
}, "获取用户会员列表成功", context)
|
}, "获取用户会员列表成功", context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetTeacherWeight 设置讲师权重
|
||||||
|
func (a *UserApi) SetTeacherWeight(context *gin.Context) {
|
||||||
|
var p request.SetTeacherInfo
|
||||||
|
if err := context.ShouldBind(&p); err != nil {
|
||||||
|
global.GVA_LOG.Error("参数错误,修改讲师信息失败", zap.Error(err))
|
||||||
|
r.FailWithMessage("参数错误,修改讲师信息失败", context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := userService.SetTeacherWeight(p); err != nil {
|
||||||
|
global.GVA_LOG.Error("修改讲师信息失败", zap.Error(err))
|
||||||
|
r.FailWithMessage("修改讲师信息失败", context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
r.OkWithMessage("修改讲师信息成功", context)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTeacherExpectRate 设置讲师分成比例
|
||||||
|
func (a *UserApi) SetTeacherExpectRate(context *gin.Context) {
|
||||||
|
var p request.SetTeacherInfo
|
||||||
|
if err := context.ShouldBind(&p); err != nil {
|
||||||
|
global.GVA_LOG.Error("参数错误,修改讲师信息失败", zap.Error(err))
|
||||||
|
r.FailWithMessage("参数错误,修改讲师信息失败", context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := userService.SetTeacherExpectRate(p); err != nil {
|
||||||
|
global.GVA_LOG.Error("修改讲师信息失败", zap.Error(err))
|
||||||
|
r.FailWithMessage("修改讲师信息失败", context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
r.OkWithMessage("修改讲师信息成功", context)
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,3 +6,8 @@ type GetTeacherVipList struct {
|
|||||||
common.PageInfo
|
common.PageInfo
|
||||||
TeacherId uint `json:"teacher_id" form:"teacher_id"` // 讲师ID
|
TeacherId uint `json:"teacher_id" form:"teacher_id"` // 讲师ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UpdateTeacherVipPriceBatch struct {
|
||||||
|
Ids []uint `json:"ids" form:"ids" vd:"@:len($)>0; msg:'请选择要修改的讲师VIP'"`
|
||||||
|
Price float64 `json:"price" form:"price" vd:"@:len($)>0; msg:'请输入讲师VIP价格'"` // 讲师VIP价格
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type TeacherVip struct {
|
|||||||
TeacherId uint `json:"teacher_id" gorm:"comment:讲师ID;"`
|
TeacherId uint `json:"teacher_id" gorm:"comment:讲师ID;"`
|
||||||
TeacherName string `json:"teacher_name" gorm:"comment:讲师名称"` // 讲师名称
|
TeacherName string `json:"teacher_name" gorm:"comment:讲师名称"` // 讲师名称
|
||||||
Avatar string `json:"avatar" gorm:"comment:讲师头像"`
|
Avatar string `json:"avatar" gorm:"comment:讲师头像"`
|
||||||
Price int `json:"price" gorm:"comment:VIP价格(单位为分)"`
|
Price float64 `json:"price" gorm:"comment:VIP价格(单位为分)"`
|
||||||
Desc string `json:"desc" gorm:"comment:VIP描述;type:longtext"`
|
Desc string `json:"desc" gorm:"comment:VIP描述;type:longtext"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,4 +22,5 @@ type TeacherInfo struct {
|
|||||||
Avatar string `json:"avatar" form:"avatar"`
|
Avatar string `json:"avatar" form:"avatar"`
|
||||||
Des string `json:"des" form:"des"`
|
Des string `json:"des" form:"des"`
|
||||||
Follow int64 `json:"follow" form:"follow"` // 粉丝数
|
Follow int64 `json:"follow" form:"follow"` // 粉丝数
|
||||||
|
Weight int `json:"weight" form:"weight"` // 权重
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,3 +90,9 @@ type SetUserVipReq struct {
|
|||||||
VipExpireTime string `json:"vip_expire_time" form:"vip_expire_time" vd:"@:len($)>0; msg:'会员过期时间不能为空'"`
|
VipExpireTime string `json:"vip_expire_time" form:"vip_expire_time" vd:"@:len($)>0; msg:'会员过期时间不能为空'"`
|
||||||
UserLabel int64 `json:"user_label" form:"user_label" vd:"@:len($)>0; msg:'用户标签不能为空'"` // 1 普通用户 2 Vip 3 Svip
|
UserLabel int64 `json:"user_label" form:"user_label" vd:"@:len($)>0; msg:'用户标签不能为空'"` // 1 普通用户 2 Vip 3 Svip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SetTeacherInfo struct {
|
||||||
|
Id int `json:"id" form:"id" vd:"@:len($)>0; msg:'用户ID不能为空'"`
|
||||||
|
ExpectRate int `json:"expect_rate" form:"expect_rate"`
|
||||||
|
Weight int `json:"weight" form:"weight" `
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ func (s *UserRouter) InitUserRouter(Router *gin.RouterGroup, PublicRouter *gin.R
|
|||||||
userRouter.GET("/login/log", userApi.GetLoginLog) // 获取用户登录日志
|
userRouter.GET("/login/log", userApi.GetLoginLog) // 获取用户登录日志
|
||||||
userRouter.DELETE("/vip", userApi.RemoveUserVip) // 删除用户会员
|
userRouter.DELETE("/vip", userApi.RemoveUserVip) // 删除用户会员
|
||||||
userRouter.GET("/vip/list", userApi.GetUserVipList) // 获取用户会员列表
|
userRouter.GET("/vip/list", userApi.GetUserVipList) // 获取用户会员列表
|
||||||
|
userRouter.PUT("/rate", userApi.SetTeacherExpectRate) // 设置讲师分成比例
|
||||||
|
userRouter.PUT("/weight", userApi.SetTeacherWeight) // 设置讲师权重
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
userRouter.GET("teacher_vips", teacherVipApi.GetTeacherVipList) // 获取讲师VIP列表
|
userRouter.GET("teacher_vips", teacherVipApi.GetTeacherVipList) // 获取讲师VIP列表
|
||||||
@@ -30,5 +32,6 @@ func (s *UserRouter) InitUserRouter(Router *gin.RouterGroup, PublicRouter *gin.R
|
|||||||
userRouter.POST("teacher_vip", teacherVipApi.CreateTeacherVip) // 创建讲师VIP
|
userRouter.POST("teacher_vip", teacherVipApi.CreateTeacherVip) // 创建讲师VIP
|
||||||
userRouter.PUT("teacher_vip", teacherVipApi.Update) // 更新讲师VIP
|
userRouter.PUT("teacher_vip", teacherVipApi.Update) // 更新讲师VIP
|
||||||
userRouter.DELETE("teacher_vip", teacherVipApi.DeleteTeacherVip) // 删除讲师VIP
|
userRouter.DELETE("teacher_vip", teacherVipApi.DeleteTeacherVip) // 删除讲师VIP
|
||||||
|
userRouter.PUT("/teacher_vip/price", teacherVipApi.UpdatePriceBatch) // 批量设置讲师课程价格
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,4 +97,13 @@ func (u *TeacherVipService) GetTeacherVip(id int) (vip app.TeacherVip, err error
|
|||||||
return vip, nil
|
return vip, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *TeacherVipService) UpdatePriceBatch(p request.UpdateTeacherVipPriceBatch) (err error) {
|
||||||
|
err = global.GVA_DB.Model(&app.TeacherVip{}).Where("id IN ?", p.Ids).Update("price", p.Price).Error
|
||||||
|
if err != nil {
|
||||||
|
global.GVA_LOG.Error("批量更新讲师VIP价格失败", zap.Error(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================管理后台接口===========================
|
// ===========================管理后台接口===========================
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ func (u *AppUserService) GetTeacherList(p common.PageInfo) (list []vo.TeacherInf
|
|||||||
global.GVA_LOG.Error("查询教师总数失败", zap.Error(err))
|
global.GVA_LOG.Error("查询教师总数失败", zap.Error(err))
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
err = db.Limit(limit).Offset(offset).Select("id, nick_name, avatar,des").Find(&list).Error
|
err = db.Limit(limit).Offset(offset).Select("id, nick_name, avatar,des,weight").Find(&list).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.GVA_LOG.Error("查询教师列表失败", zap.Error(err))
|
global.GVA_LOG.Error("查询教师列表失败", zap.Error(err))
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
|
|||||||
@@ -363,3 +363,23 @@ func (u *UserService) GetUserVipList(p request.GetUserListReq) (list []vo.UserIn
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetTeacherWeight 设置讲师权重
|
||||||
|
func (u *UserService) SetTeacherWeight(p request.SetTeacherInfo) (err error) {
|
||||||
|
err = global.GVA_DB.Model(&user.User{}).Where("id = ?", p.Id).Update("weight", p.Weight).Error
|
||||||
|
if err != nil {
|
||||||
|
global.GVA_LOG.Error("设置讲师权重失败", zap.Error(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTeacherExpectRate 设置讲师分成
|
||||||
|
func (u *UserService) SetTeacherExpectRate(p request.SetTeacherInfo) (err error) {
|
||||||
|
err = global.GVA_DB.Model(&user.User{}).Where("id = ?", p.Id).Update("expect_rate", p.ExpectRate).Error
|
||||||
|
if err != nil {
|
||||||
|
global.GVA_LOG.Error("设置讲师权重失败", zap.Error(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user