|
|
@@ -6,380 +6,42 @@
|
|
|
*/
|
|
|
package controller
|
|
|
|
|
|
+import (
|
|
|
+ "net/http"
|
|
|
+ "video_course/model"
|
|
|
+ "video_course/service"
|
|
|
+)
|
|
|
+
|
|
|
type User struct {
|
|
|
BaseController
|
|
|
}
|
|
|
|
|
|
-type ShopUserInfo struct {
|
|
|
+type UserInfoResponse struct {
|
|
|
ResponseBase
|
|
|
- PageCount int64
|
|
|
- Rs string
|
|
|
-}
|
|
|
-
|
|
|
-// ShopUserListQuery godoc
|
|
|
-// @Summary 会员用户列表(带分页)
|
|
|
-// @tags User
|
|
|
-// @Description 会员用户列表(带分页)
|
|
|
-// @Accept x-www-form-urlencoded
|
|
|
-// @Produce json
|
|
|
-// @Param token formData string true "Token"
|
|
|
-// @Param phone formData string false "手机号"
|
|
|
-// @Param name formData string false "姓名"
|
|
|
-// @Param start formData string true "当前条"
|
|
|
-// @Param tableMax formData string true "每页条数"
|
|
|
-// @Success 200 {object} controller.ShopUserInfo
|
|
|
-// @Router /User/ShopUserListQuery [post]
|
|
|
-func (u *User) ShopUserListQuery() (err error) {
|
|
|
- //sess := u.Ctx().PostForm("Token")
|
|
|
- //phone := u.Ctx().PostForm("phone")
|
|
|
- //name := u.Ctx().PostForm("name")
|
|
|
- //start := u.postIntNecessary("start")
|
|
|
- //tableMax := u.postIntNecessary("tableMax")
|
|
|
- //pageIndex := start/tableMax + 1
|
|
|
- //
|
|
|
- //rs, pageCount, err := service.User{}.ShopUserListQuery(sess, phone, name, pageIndex, tableMax)
|
|
|
- //
|
|
|
- //rp := ShopUserInfo{
|
|
|
- // newResponseBase(),
|
|
|
- // pageCount,
|
|
|
- // rs,
|
|
|
- //}
|
|
|
- //u.Ctx().JSON(http.StatusOK, rp)
|
|
|
-
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-type ShopUserSimpleInfo struct {
|
|
|
- ResponseBase
|
|
|
- Rs string
|
|
|
- //Rs []*gorm.ShopUserSimpleInfo
|
|
|
-}
|
|
|
-
|
|
|
-// ShopUserSimpleQuery godoc
|
|
|
-// @Summary 本店会员用户基本信息查询
|
|
|
-// @tags User
|
|
|
-// @Description 本店会员用户基本信息查询
|
|
|
-// @Accept x-www-form-urlencoded
|
|
|
-// @Produce json
|
|
|
-// @Param token formData string true "Token"
|
|
|
-// @Param shopId formData int false "商家ID"
|
|
|
-// @Success 200 {object} controller.ShopUserSimpleInfo
|
|
|
-// @Router /User/ShopUserSimpleQuery [post]
|
|
|
-func (u *User) ShopUserSimpleQuery() (err error) {
|
|
|
-
|
|
|
- //shopId := u.postInt("shopId")
|
|
|
- //
|
|
|
- //sess := u.Ctx().PostForm("Token")
|
|
|
- //rs, err := service.User{}.ShopUserSimpleQuery(sess, shopId)
|
|
|
- //
|
|
|
- //rp := ShopUserSimpleInfo{
|
|
|
- // newResponseBase(),
|
|
|
- // rs,
|
|
|
- //}
|
|
|
- //u.Ctx().JSON(http.StatusOK, rp)
|
|
|
-
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-// ShopUserAdd godoc
|
|
|
-// @Summary 会员用户添加
|
|
|
-// @tags User
|
|
|
-// @Description 会员用户添加
|
|
|
-// @Accept x-www-form-urlencoded
|
|
|
-// @Produce json
|
|
|
-// @Param token formData string true "Token"
|
|
|
-// @Param shopId formData int true "店铺ID"
|
|
|
-// @Param phone formData string true "登陆用户名也是手机号"
|
|
|
-// @Param name formData string true "姓名"
|
|
|
-// @Param sex formData int true "性别 1:男, 2:女"
|
|
|
-// @Param birthday formData string true "生日"
|
|
|
-// @Param height formData int true "身高"
|
|
|
-// @Param weight formData string true "体重 "
|
|
|
-// @Param staticHr formData int false "静态心率"
|
|
|
-// @Param head formData string false "头像"
|
|
|
-// @Param memo formData string false "备注"
|
|
|
-// @Success 200 {object} controller.ResponseBase
|
|
|
-// @Router /User/ShopUserAdd [post]
|
|
|
-func (u *User) ShopUserAdd() (err error) {
|
|
|
- //usercode := u.postString("phone", true)
|
|
|
- //name := u.postString("name", true)
|
|
|
- //phone := u.postString("phone", true)
|
|
|
- //memo := u.Ctx().PostForm("memo")
|
|
|
- //
|
|
|
- //sex := u.postIntNecessary("sex")
|
|
|
- //birthday := u.getPostFromDate("birthday")
|
|
|
- //
|
|
|
- //height := u.postIntNecessary("height")
|
|
|
- //staticHr := u.postInt("staticHr")
|
|
|
- //head := u.Ctx().PostForm("head")
|
|
|
- //w := u.postFloatToInt("weight", true)
|
|
|
- //
|
|
|
- //// 如果未传入静息心率,则通过生日计算年龄后获取此年龄段的平均静息心率
|
|
|
- //if staticHr == nil {
|
|
|
- // age := utils.GetAgeByBirthday(birthday)
|
|
|
- // hr := utils.GetStaticHrByAge(age)
|
|
|
- //
|
|
|
- // staticHr = &hr
|
|
|
- //}
|
|
|
- //
|
|
|
- //
|
|
|
- //sess := u.getSession()
|
|
|
- //s := service.NewUserService()
|
|
|
- //logInfo, err := s.ShopUserAdd(sess, usercode, name, phone, memo, sex, birthday, height, w, staticHr, head)
|
|
|
- //if err != nil {
|
|
|
- //
|
|
|
- // return
|
|
|
- //}
|
|
|
- //u.saveOptLogInfo(logInfo)
|
|
|
- //
|
|
|
- //u.Ctx().JSON(http.StatusOK, newResponseBase())
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-// ShopUserEdit godoc
|
|
|
-// @Summary 会员用户基本信息修改
|
|
|
-// @tags User
|
|
|
-// @Description 会员用户基本信息修改
|
|
|
-// @Accept x-www-form-urlencoded
|
|
|
-// @Produce json
|
|
|
-// @Param token formData string true "Token"
|
|
|
-// @Param userId formData int true "用户Id"
|
|
|
-// @Param phone formData string false "手机号"
|
|
|
-// @Param name formData string false "姓名"
|
|
|
-// @Param memo formData string false "备注"
|
|
|
-// @Param birthday formData string true "生日"
|
|
|
-// @Param height formData int true "身高"
|
|
|
-// @Param weight formData string true "体重"
|
|
|
-// @Param sex formData int true "性别 1:男, 2:女"
|
|
|
-// @Param staticHr formData int false "静态心率"
|
|
|
-// @Param head formData string false "头像URL"
|
|
|
-// @Success 200 {object} controller.ResponseBase
|
|
|
-// @Router /User/ShopUserEdit [post]
|
|
|
-func (u *User) ShopUserEdit() (err error) {
|
|
|
- //userId := u.postIntNecessary("userId")
|
|
|
- //name := u.Ctx().PostForm("name")
|
|
|
- //phone := u.Ctx().PostForm("phone")
|
|
|
- //memo := u.Ctx().PostForm("memo")
|
|
|
- //
|
|
|
- ////ubId := u.postInt("ubId")
|
|
|
- //height := u.postIntNecessary("height")
|
|
|
- //w := u.postFloatToInt("weight", true)
|
|
|
- //sex := u.postIntNecessary("sex")
|
|
|
- //staticHr := u.postInt("staticHr")
|
|
|
- //head := u.Ctx().PostForm("head")
|
|
|
- //birthday := u.getPostFromDate("birthday")
|
|
|
- //
|
|
|
- //// 如果未传入静息心率,则通过生日计算年龄后获取此年龄段的平均静息心率
|
|
|
- //if staticHr == nil {
|
|
|
- // age := utils.GetAgeByBirthday(birthday)
|
|
|
- // hr := utils.GetStaticHrByAge(age)
|
|
|
- // staticHr = &hr
|
|
|
- //}
|
|
|
- //
|
|
|
- //sess := u.getSession()
|
|
|
- //logInfo, err := service.User{}.ShopUserEdit(sess, userId, name, phone, memo, height, w, sex, staticHr, head, birthday)
|
|
|
- //if err != nil {
|
|
|
- //
|
|
|
- // return
|
|
|
- //}
|
|
|
- //u.saveOptLogInfo(logInfo)
|
|
|
- //
|
|
|
- //u.Ctx().JSON(http.StatusOK, newResponseBase())
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-// ShopUserStatusEdit godoc
|
|
|
-// @Summary 会员用户状态修改
|
|
|
-// @tags User
|
|
|
-// @Description 会员用户状态修改
|
|
|
-// @Accept x-www-form-urlencoded
|
|
|
-// @Produce json
|
|
|
-// @Param token formData string true "Token"
|
|
|
-// @Param userId formData int true "用户ID"
|
|
|
-// @Param status formData int true "状态 1:启用 8:禁用 9:删除"
|
|
|
-// @Success 200 {object} controller.ResponseBase
|
|
|
-// @Router /User/ShopUserStatusEdit [post]
|
|
|
-func (u *User) ShopUserStatusEdit() (err error) {
|
|
|
- //userId := u.postIntNecessary("userId")
|
|
|
- //status := u.postIntNecessary("status")
|
|
|
- //
|
|
|
- //sess := u.getSession()
|
|
|
- //logInfo, err := service.User{}.ShopUserStatusEdit(sess, userId, status)
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //u.saveOptLogInfo(logInfo)
|
|
|
- //
|
|
|
- //u.Ctx().JSON(http.StatusOK, newResponseBase())
|
|
|
- return
|
|
|
+ Rs *model.UserBodyInfo
|
|
|
}
|
|
|
|
|
|
-// ShopCoachAdd godoc
|
|
|
-// @Summary 商家教练添加
|
|
|
+// UserInfoQuery godoc
|
|
|
+// @Summary 会员信息查询
|
|
|
// @tags User
|
|
|
-// @Description 商家教练添加
|
|
|
+// @Description 会员信息查询
|
|
|
// @Accept x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param token formData string true "Token"
|
|
|
-// @Param shopId formData int true "店铺ID"
|
|
|
-// @Param phone formData string true "登陆用户名也是手机号"
|
|
|
-// @Param name formData string true "姓名"
|
|
|
-// @Param pwd formData string true "密码"
|
|
|
-// @Param sex formData int true "性别 1:男, 2:女"
|
|
|
-// @Param memo formData string false "备注"
|
|
|
// @Success 200 {object} controller.ResponseBase
|
|
|
-// @Router /User/ShopCoachAdd [post]
|
|
|
-func (u *User) ShopCoachAdd() (err error) {
|
|
|
- //usercode := u.postString("phone", true)
|
|
|
- //name := u.postString("name", true)
|
|
|
- //phone := u.postString("phone", true)
|
|
|
- //pwd := u.postString("pwd", true)
|
|
|
- //memo := u.Ctx().PostForm("memo")
|
|
|
- //
|
|
|
- //sex := u.postIntNecessary("sex")
|
|
|
-
|
|
|
- //sess := u.getSession()
|
|
|
- //s := service.NewUserService()
|
|
|
- //logInfo, err := s.ShopCoachAdd(sess, usercode, name, phone, memo, sex, pwd)
|
|
|
- //if err != nil {
|
|
|
- //
|
|
|
- // return
|
|
|
- //}
|
|
|
- //u.saveOptLogInfo(logInfo)
|
|
|
- //
|
|
|
- //u.Ctx().JSON(http.StatusOK, newResponseBase())
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-// ShopCoachEdit godoc
|
|
|
-// @Summary 商家教练基本信息修改
|
|
|
-// @tags User
|
|
|
-// @Description 商家教练基本信息修改
|
|
|
-// @Accept x-www-form-urlencoded
|
|
|
-// @Produce json
|
|
|
-// @Param token formData string true "Token"
|
|
|
-// @Param ssId formData int true "教练ID"
|
|
|
-// @Param phone formData string false "手机号"
|
|
|
-// @Param pwd formData string false "密码"
|
|
|
-// @Param name formData string false "姓名"
|
|
|
-// @Param memo formData string false "备注"
|
|
|
-// @Param sex formData int true "性别 1:男, 2:女"
|
|
|
-// @Success 200 {object} controller.ResponseBase
|
|
|
-// @Router /User/ShopCoachEdit [post]
|
|
|
-func (u *User) ShopCoachEdit() (err error) {
|
|
|
- //ssId := u.postIntNecessary("ssId")
|
|
|
- //name := u.Ctx().PostForm("name")
|
|
|
- //phone := u.Ctx().PostForm("phone")
|
|
|
- //pwd := u.Ctx().PostForm("pwd")
|
|
|
- //memo := u.Ctx().PostForm("memo")
|
|
|
- //
|
|
|
- //sex := u.postIntNecessary("sex")
|
|
|
- //
|
|
|
- //sess := u.getSession()
|
|
|
- //logInfo, err := service.User{}.ShopCoachEdit(sess, ssId, name, phone, memo, sex, pwd)
|
|
|
- //if err != nil {
|
|
|
- //
|
|
|
- // return
|
|
|
- //}
|
|
|
- //u.saveOptLogInfo(logInfo)
|
|
|
- //
|
|
|
- //u.Ctx().JSON(http.StatusOK, newResponseBase())
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-// ShopCoachStatusEdit godoc
|
|
|
-// @Summary 商家教练状态修改
|
|
|
-// @tags User
|
|
|
-// @Description 商家教练状态修改
|
|
|
-// @Accept x-www-form-urlencoded
|
|
|
-// @Produce json
|
|
|
-// @Param token formData string true "Token"
|
|
|
-// @Param ssId formData int true "教练ID"
|
|
|
-// @Param status formData int true "状态 1:启用 8:禁用 9:删除"
|
|
|
-// @Success 200 {object} controller.ResponseBase
|
|
|
-// @Router /User/ShopCoachStatusEdit [post]
|
|
|
-func (u *User) ShopCoachStatusEdit() (err error) {
|
|
|
- //ssId := u.postIntNecessary("ssId")
|
|
|
- //status := u.postIntNecessary("status")
|
|
|
- //
|
|
|
- //sess := u.getSession()
|
|
|
- //logInfo, err := service.User{}.ShopCoachStatusEdit(sess, ssId, status)
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //u.saveOptLogInfo(logInfo)
|
|
|
- //
|
|
|
- //u.Ctx().JSON(http.StatusOK, newResponseBase())
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-type ShopCoachInfo struct {
|
|
|
- ResponseBase
|
|
|
- PageCount int64
|
|
|
- Rs string
|
|
|
-}
|
|
|
-
|
|
|
-// ShopCoachListQuery godoc
|
|
|
-// @Summary 会员用户列表(带分页)
|
|
|
-// @tags User
|
|
|
-// @Description 会员用户列表(带分页)
|
|
|
-// @Accept x-www-form-urlencoded
|
|
|
-// @Produce json
|
|
|
-// @Param token formData string true "Token"
|
|
|
-// @Param phone formData string false "手机号"
|
|
|
-// @Param name formData string false "姓名"
|
|
|
-// @Param start formData string true "当前条"
|
|
|
-// @Param tableMax formData string true "每页条数"
|
|
|
-// @Success 200 {object} controller.ShopUserInfo
|
|
|
-// @Router /User/ShopCoachListQuery [post]
|
|
|
-func (u *User) ShopCoachListQuery() (err error) {
|
|
|
- //sess := u.Ctx().PostForm("Token")
|
|
|
- //phone := u.Ctx().PostForm("phone")
|
|
|
- //name := u.Ctx().PostForm("name")
|
|
|
- //start := u.postIntNecessary("start")
|
|
|
- //tableMax := u.postIntNecessary("tableMax")
|
|
|
- //pageIndex := start/tableMax + 1
|
|
|
- //
|
|
|
- //rs, pageCount, err := service.User{}.ShopCoachListQuery(sess, phone, name, pageIndex, tableMax)
|
|
|
- //
|
|
|
- //rp := ShopCoachInfo{
|
|
|
- // newResponseBase(),
|
|
|
- // pageCount,
|
|
|
- // rs,
|
|
|
- //}
|
|
|
- //u.Ctx().JSON(http.StatusOK, rp)
|
|
|
-
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-type ShopCoachSimpleInfo struct {
|
|
|
- ResponseBase
|
|
|
- Rs string
|
|
|
- //Rs []*gorm.ShopUserSimpleInfo
|
|
|
-}
|
|
|
-
|
|
|
-// ShopCoachSimpleQuery godoc
|
|
|
-// @Summary 本店会员用户基本信息查询
|
|
|
-// @tags User
|
|
|
-// @Description 本店会员用户基本信息查询
|
|
|
-// @Accept x-www-form-urlencoded
|
|
|
-// @Produce json
|
|
|
-// @Param token formData string true "Token"
|
|
|
-// @Param shopId formData int false "商家ID"
|
|
|
-// @Success 200 {object} controller.ShopCoachSimpleInfo
|
|
|
-// @Router /User/ShopCoachSimpleQuery [post]
|
|
|
-func (u *User) ShopCoachSimpleQuery() (err error) {
|
|
|
-
|
|
|
- //shopId := u.postInt("shopId")
|
|
|
- //
|
|
|
- //sess := u.Ctx().PostForm("Token")
|
|
|
- //rs, err := service.User{}.ShopCoachSimpleQuery(sess, shopId)
|
|
|
- //
|
|
|
- //rp := ShopCoachSimpleInfo{
|
|
|
- // newResponseBase(),
|
|
|
- // rs,
|
|
|
- //}
|
|
|
- //u.Ctx().JSON(http.StatusOK, rp)
|
|
|
+// @Router /User/UserInfoQuery [post]
|
|
|
+func (u *User) UserInfoQuery() (err error) {
|
|
|
+ token := u.Ctx().PostForm("token")
|
|
|
+
|
|
|
+ rs, err := service.User{}.UserInfoQuery(token)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ r := UserInfoResponse{
|
|
|
+ ResponseBase: newResponseBase(),
|
|
|
+ Rs: rs,
|
|
|
+ }
|
|
|
+ u.Ctx().JSON(http.StatusOK, r)
|
|
|
|
|
|
return
|
|
|
}
|