diff --git a/api/v1/app/enter.go b/api/v1/app/enter.go index 289723e..a8edda6 100644 --- a/api/v1/app/enter.go +++ b/api/v1/app/enter.go @@ -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 diff --git a/api/v1/app/order.go b/api/v1/app/order.go new file mode 100644 index 0000000..6e9fd3f --- /dev/null +++ b/api/v1/app/order.go @@ -0,0 +1,3 @@ +package app + +type OrderApi struct{} diff --git a/api/v1/app/user.go b/api/v1/app/user.go index e9f5543..2a5178b 100644 --- a/api/v1/app/user.go +++ b/api/v1/app/user.go @@ -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) +} diff --git a/model/app/teacher_apply.go b/model/app/teacher_apply.go index 7342821..d200136 100644 --- a/model/app/teacher_apply.go +++ b/model/app/teacher_apply.go @@ -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 { diff --git a/router/app/user.go b/router/app/user.go index f02df32..006d1b4 100644 --- a/router/app/user.go +++ b/router/app/user.go @@ -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) // 微信登录 diff --git a/service/app/enter.go b/service/app/enter.go index cd743ff..eaae487 100644 --- a/service/app/enter.go +++ b/service/app/enter.go @@ -3,4 +3,5 @@ package app type ServiceGroup struct { AppUserService BannerService + OrderService } diff --git a/service/app/user.go b/service/app/user.go index 0753e4f..7e2c1f8 100644 --- a/service/app/user.go +++ b/service/app/user.go @@ -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 + +}