🎨 新增讲师相关接口(待完善)
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.echol.cn/loser/lckt/global"
|
||||
"git.echol.cn/loser/lckt/model/app"
|
||||
r "git.echol.cn/loser/lckt/model/common/response"
|
||||
"git.echol.cn/loser/lckt/model/user/request"
|
||||
"git.echol.cn/loser/lckt/utils"
|
||||
@@ -194,6 +195,7 @@ func (*AppUserApi) PwdLogin(ctx *gin.Context) {
|
||||
}, "登录成功", ctx)
|
||||
}
|
||||
|
||||
// Register 用户手机注册
|
||||
func (a *AppUserApi) Register(context *gin.Context) {
|
||||
var p request.RegisterReq
|
||||
if err := context.ShouldBind(&p); err != nil {
|
||||
@@ -241,3 +243,30 @@ func (a *AppUserApi) Register(context *gin.Context) {
|
||||
"ExpiresAt": claims.RegisteredClaims.ExpiresAt.Unix() * 1000,
|
||||
}, "注册成功", context)
|
||||
}
|
||||
|
||||
// ApplyTeacher 申请成为教师
|
||||
func (a *AppUserApi) ApplyTeacher(context *gin.Context) {
|
||||
var p app.TeacherApply
|
||||
if err := context.ShouldBind(&p); err != nil {
|
||||
r.FailWithMessage(err.Error(), context)
|
||||
global.GVA_LOG.Error("参数错误,申请失败", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
id := user_jwt.GetUserID(context)
|
||||
if id == 0 {
|
||||
global.GVA_LOG.Error("获取用户ID失败")
|
||||
r.FailWithMessage("获取用户ID失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
p.UserId = id
|
||||
|
||||
if err := appUserService.ApplyTeacher(p); err != nil {
|
||||
global.GVA_LOG.Error("申请失败", zap.Error(err))
|
||||
r.FailWithMessage("申请失败", context)
|
||||
return
|
||||
}
|
||||
|
||||
r.OkWithMessage("申请成功", context)
|
||||
}
|
||||
|
Reference in New Issue
Block a user