🎨 新增讲师包月功能,优化支付回调
This commit is contained in:
@@ -6,9 +6,11 @@ type ApiGroup struct {
|
||||
AppUserApi
|
||||
BannerApi
|
||||
OrderApi
|
||||
TeacherVip
|
||||
}
|
||||
|
||||
var userService = service.ServiceGroupApp.UserServiceGroup.UserService
|
||||
var appUserService = service.ServiceGroupApp.AppServiceGroup.AppUserService
|
||||
var bannerService = service.ServiceGroupApp.AppServiceGroup.BannerService
|
||||
var orderService = service.ServiceGroupApp.AppServiceGroup.OrderService
|
||||
var teacherVipService = service.ServiceGroupApp.AppServiceGroup.TeacherVipService
|
||||
|
||||
112
api/v1/app/teacher_vip.go
Normal file
112
api/v1/app/teacher_vip.go
Normal file
@@ -0,0 +1,112 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"git.echol.cn/loser/lckt/global"
|
||||
"git.echol.cn/loser/lckt/model/app"
|
||||
"git.echol.cn/loser/lckt/model/app/request"
|
||||
common "git.echol.cn/loser/lckt/model/common/request"
|
||||
r "git.echol.cn/loser/lckt/model/common/response"
|
||||
"git.echol.cn/loser/lckt/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type TeacherVip struct{}
|
||||
|
||||
// CreateTeacherVip 创建讲师VIP
|
||||
func (a *TeacherVip) CreateTeacherVip(context *gin.Context) {
|
||||
var p app.TeacherVip
|
||||
if err := context.ShouldBind(&p); err != nil {
|
||||
global.GVA_LOG.Error("参数错误,创建讲师VIP失败", zap.Error(err))
|
||||
r.FailWithMessage("参数错误,创建讲师VIP失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
id := utils.GetUserID(context)
|
||||
|
||||
err := teacherVipService.CreateTeacherVip(p, id)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("创建讲师VIP失败", zap.Error(err))
|
||||
r.FailWithMessage("创建讲师VIP失败", context)
|
||||
return
|
||||
}
|
||||
r.OkWithMessage("创建讲师VIP成功", context)
|
||||
}
|
||||
|
||||
// DeleteTeacherVip 删除讲师VIP
|
||||
func (a *TeacherVip) DeleteTeacherVip(context *gin.Context) {
|
||||
var p app.TeacherVip
|
||||
if err := context.ShouldBindJSON(&p); err != nil {
|
||||
global.GVA_LOG.Error("参数错误,删除讲师VIP失败", zap.Error(err))
|
||||
r.FailWithMessage("参数错误,删除讲师VIP失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
err := teacherVipService.DeleteTeacherVip(p)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("删除讲师VIP失败", zap.Error(err))
|
||||
r.FailWithMessage("删除讲师VIP失败", context)
|
||||
return
|
||||
}
|
||||
r.OkWithMessage("删除讲师VIP成功", context)
|
||||
}
|
||||
|
||||
// Update 更新讲师VIP
|
||||
func (a *TeacherVip) Update(context *gin.Context) {
|
||||
var p app.TeacherVip
|
||||
if err := context.ShouldBindJSON(&p); err != nil {
|
||||
global.GVA_LOG.Error("参数错误,更新讲师VIP失败", zap.Error(err))
|
||||
r.FailWithMessage("参数错误,更新讲师VIP失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
err := teacherVipService.Update(p)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("更新讲师VIP失败", zap.Error(err))
|
||||
r.FailWithMessage("更新讲师VIP失败", context)
|
||||
return
|
||||
}
|
||||
r.OkWithMessage("更新讲师VIP成功", context)
|
||||
}
|
||||
|
||||
// GetTeacherVipList 获取讲师VIP列表
|
||||
func (a *TeacherVip) GetTeacherVipList(context *gin.Context) {
|
||||
var p request.GetTeacherVipList
|
||||
if err := context.ShouldBind(&p); err != nil {
|
||||
global.GVA_LOG.Error("参数错误,获取讲师VIP列表失败", zap.Error(err))
|
||||
r.FailWithMessage("参数错误,获取讲师VIP列表失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
vips, total, err := teacherVipService.GetTeacherVipList(p)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("获取讲师VIP列表失败", zap.Error(err))
|
||||
r.FailWithMessage("获取讲师VIP列表失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
r.OkWithDetailed(
|
||||
r.PageResult{
|
||||
List: vips,
|
||||
Total: total,
|
||||
Page: p.Page,
|
||||
PageSize: p.PageSize,
|
||||
}, "获取讲师VIP列表成功", context)
|
||||
}
|
||||
|
||||
func (a *TeacherVip) GetTeacherVip(context *gin.Context) {
|
||||
var p common.GetById
|
||||
if err := context.ShouldBind(&p); err != nil {
|
||||
global.GVA_LOG.Error("参数错误,获取讲师VIP失败", zap.Error(err))
|
||||
r.FailWithMessage("参数错误,获取讲师VIP失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
vip, err := teacherVipService.GetTeacherVip(p.ID)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("获取讲师VIP失败", zap.Error(err))
|
||||
r.FailWithMessage("获取讲师VIP失败", context)
|
||||
return
|
||||
}
|
||||
r.OkWithDetailed(vip, "获取讲师VIP成功", context)
|
||||
}
|
||||
@@ -476,3 +476,34 @@ func (a *AppUserApi) GetFollowStatus(ctx *gin.Context) {
|
||||
}
|
||||
r.OkWithDetailed(followed, "获取关注状态成功", ctx)
|
||||
}
|
||||
|
||||
// GetVipTeacherList 获取包月讲师列表
|
||||
func (a *AppUserApi) GetVipTeacherList(context *gin.Context) {
|
||||
var p common.PageInfo
|
||||
if err := context.ShouldBind(&p); err != nil {
|
||||
global.GVA_LOG.Error("参数错误,获取包月讲师列表失败", zap.Error(err))
|
||||
r.FailWithMessage("参数错误,获取包月讲师列表失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
userId := user_jwt.GetUserID(context)
|
||||
if userId == 0 {
|
||||
global.GVA_LOG.Error("获取用户ID失败")
|
||||
r.FailWithMessage("获取用户ID失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
teachers, total, err := appUserService.GetVipTeacherList(p, userId)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("获取包月讲师列表失败", zap.Error(err))
|
||||
r.FailWithMessage("获取包月讲师列表失败", context)
|
||||
return
|
||||
}
|
||||
r.OkWithDetailed(
|
||||
r.PageResult{
|
||||
List: teachers,
|
||||
Total: total,
|
||||
Page: p.Page,
|
||||
PageSize: p.PageSize,
|
||||
}, "获取包月讲师列表成功", context)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user