🎨 新增用户简介字段,新增手机端讲师相关接口
This commit is contained in:
@@ -3,6 +3,7 @@ package app
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
common "git.echol.cn/loser/lckt/model/common/request"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -361,3 +362,30 @@ func (a *AppUserApi) BindPhone(context *gin.Context) {
|
||||
|
||||
r.OkWithDetailed(user, "绑定手机号成功", context)
|
||||
}
|
||||
|
||||
// -----------------讲师相关---------------------
|
||||
|
||||
// GetTeacherList 获取讲师列表
|
||||
func (a *AppUserApi) GetTeacherList(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
|
||||
}
|
||||
|
||||
teachers, total, err := appUserService.GetTeacherList(p)
|
||||
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)
|
||||
}
|
||||
|
@@ -15,3 +15,10 @@ type UserInfo struct {
|
||||
IsVip int8 `json:"is_vip" form:"is_vip"` //是否是VIP 0 否 1 是
|
||||
VipExpireTime string `json:"vip_expire_time" form:"vip_expire_time"` // VIP过期时间
|
||||
}
|
||||
|
||||
type TeacherInfo struct {
|
||||
ID uint `json:"id" form:"id"`
|
||||
NickName string `json:"nick_name" form:"nick_name"`
|
||||
Avatar string `json:"avatar" form:"avatar"`
|
||||
Des string `json:"des" form:"des"`
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ type User struct {
|
||||
global.GVA_MODEL
|
||||
NickName string `json:"nick_name" form:"nick_name" gorm:"comment:用户昵称"`
|
||||
Phone string `json:"phone" form:"phone" gorm:"comment:用户手机号"`
|
||||
Des string `json:"des" form:"des" gorm:"comment:用户描述"`
|
||||
UnionId string `json:"union_id" form:"union_id" gorm:"type:varchar(255) comment '微信UnionId'"`
|
||||
OpenId string `gorm:"column:open_id;default:'';comment:'openId'" json:"-"`
|
||||
Password string `json:"password" form:"password" gorm:"comment:用户密码"`
|
||||
|
@@ -13,7 +13,8 @@ func (s *UserRouter) InitAppUserRouter(AppAuthGroup, PublicRouter *gin.RouterGro
|
||||
appUserRouter.GET("/info", userApi.GetUserInfo) // 获取用户信息
|
||||
//申请成为讲师
|
||||
appUserRouter.POST("/applyTeacher", userApi.ApplyTeacher) // 申请成为讲师
|
||||
appUserRouter.GET("/applyTeacher", userApi.GetTeacherApply) // 获取教师列表
|
||||
appUserRouter.GET("/applyTeacher", userApi.GetTeacherApply) // 获取教师申请状态
|
||||
appUserRouter.GET("/teachers", userApi.GetTeacherList) // 获取讲师列表
|
||||
}
|
||||
{
|
||||
publicRouter.POST("wxLogin", userApi.WechatLogin) // 微信登录
|
||||
|
@@ -5,6 +5,7 @@ import (
|
||||
"git.echol.cn/loser/lckt/global"
|
||||
"git.echol.cn/loser/lckt/model/app"
|
||||
"git.echol.cn/loser/lckt/model/app/vo"
|
||||
common "git.echol.cn/loser/lckt/model/common/request"
|
||||
"git.echol.cn/loser/lckt/model/user"
|
||||
"git.echol.cn/loser/lckt/model/user/request"
|
||||
utils2 "git.echol.cn/loser/lckt/utils"
|
||||
@@ -221,3 +222,25 @@ func (u *AppUserService) BindPhone(p request.BindPhoneReq) (*user.User, error) {
|
||||
|
||||
return &userInfo, nil
|
||||
}
|
||||
|
||||
func (u *AppUserService) GetTeacherList(p common.PageInfo) (list []vo.TeacherInfo, total int64, err error) {
|
||||
limit := p.PageSize
|
||||
offset := (p.Page - 1) * p.PageSize
|
||||
db := global.GVA_DB.Model(&user.User{}).Where("user_type = ?", 2)
|
||||
|
||||
if p.Keyword != "" {
|
||||
db = db.Where("nick_name LIKE ?", "%"+p.Keyword+"%")
|
||||
}
|
||||
|
||||
err = db.Count(&total).Error
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("查询教师总数失败", zap.Error(err))
|
||||
return nil, 0, err
|
||||
}
|
||||
err = db.Limit(limit).Offset(offset).Select("id, nick_name, avatar,des").Find(&list).Error
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("查询教师列表失败", zap.Error(err))
|
||||
return nil, 0, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user