| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- /**
- * @ File:
- * @ Date: 2021/1/25 9:54
- * @ Author: JYQ
- * @ Description:
- */
- package controller
- type User struct {
- BaseController
- }
- type ShopUserInfo 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
- }
- // ShopCoachAdd 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 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)
- return
- }
|