🎨 完善用户讲师申请接口,新增order模块
This commit is contained in:
@@ -5,8 +5,10 @@ import "git.echol.cn/loser/lckt/service"
|
||||
type ApiGroup struct {
|
||||
AppUserApi
|
||||
BannerApi
|
||||
OrderApi
|
||||
}
|
||||
|
||||
var userService = service.ServiceGroupApp.UserServiceGroup.UserService
|
||||
var appUserService = service.ServiceGroupApp.AppServiceGroup.AppUserService
|
||||
var bannerService = service.ServiceGroupApp.AppServiceGroup.BannerService
|
||||
var orderService = service.ServiceGroupApp.AppServiceGroup.OrderService
|
||||
|
3
api/v1/app/order.go
Normal file
3
api/v1/app/order.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package app
|
||||
|
||||
type OrderApi struct{}
|
@@ -270,3 +270,22 @@ func (a *AppUserApi) ApplyTeacher(context *gin.Context) {
|
||||
|
||||
r.OkWithMessage("申请成功", context)
|
||||
}
|
||||
|
||||
// GetTeacherApply 获取教师申请状态
|
||||
func (a *AppUserApi) GetTeacherApply(context *gin.Context) {
|
||||
id := user_jwt.GetUserID(context)
|
||||
if id == 0 {
|
||||
global.GVA_LOG.Error("获取用户ID失败")
|
||||
r.FailWithMessage("获取用户ID失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
status, err := appUserService.GetTeacherApplyStatus(id)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("获取教师申请状态失败", zap.Error(err))
|
||||
r.FailWithMessage("获取教师申请状态失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
r.OkWithDetailed(status, "获取教师申请状态成功", context)
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ type TeacherApply struct {
|
||||
ExpectRate string `json:"expectRate" gorm:"type:varchar(255);comment:期望分成比例"`
|
||||
Phone string `json:"phone" gorm:"type:varchar(20);comment:联系电话"`
|
||||
Nickname string `json:"nickname" gorm:"type:varchar(255);comment:讲师名称"`
|
||||
Note string `json:"note" gorm:"type:varchar(255);comment:审核备注"`
|
||||
}
|
||||
|
||||
func (TeacherApply) TableName() string {
|
||||
|
@@ -12,7 +12,8 @@ func (s *UserRouter) InitAppUserRouter(AppAuthGroup, PublicRouter *gin.RouterGro
|
||||
{
|
||||
appUserRouter.GET("/info", userApi.GetUserInfo) // 获取用户信息
|
||||
//申请成为讲师
|
||||
appUserRouter.POST("/applyTeacher", userApi.ApplyTeacher) // 申请成为讲师
|
||||
appUserRouter.POST("/applyTeacher", userApi.ApplyTeacher) // 申请成为讲师
|
||||
appUserRouter.GET("/applyTeacher", userApi.GetTeacherApply) // 获取教师列表
|
||||
}
|
||||
{
|
||||
publicRouter.POST("wxLogin", userApi.WechatLogin) // 微信登录
|
||||
|
@@ -3,4 +3,5 @@ package app
|
||||
type ServiceGroup struct {
|
||||
AppUserService
|
||||
BannerService
|
||||
OrderService
|
||||
}
|
||||
|
@@ -164,3 +164,14 @@ func (u *AppUserService) ApplyTeacher(p app.TeacherApply) (err error) {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *AppUserService) GetTeacherApplyStatus(id uint) (teacherApply app.TeacherApply, err error) {
|
||||
// 获取最后一条申请记录
|
||||
err = global.GVA_DB.Model(&app.TeacherApply{}).Where("user_id = ?", id).Last(&teacherApply).Error
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("查询申请记录失败", zap.Error(err))
|
||||
return teacherApply, err
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user