user.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. /**
  2. * @ File:
  3. * @ Date: 2021/1/25 9:54
  4. * @ Author: JYQ
  5. * @ Description:
  6. */
  7. package controller
  8. type User struct {
  9. BaseController
  10. }
  11. type ShopUserInfo struct {
  12. ResponseBase
  13. PageCount int64
  14. Rs string
  15. }
  16. // ShopUserListQuery godoc
  17. // @Summary 会员用户列表(带分页)
  18. // @tags User
  19. // @Description 会员用户列表(带分页)
  20. // @Accept x-www-form-urlencoded
  21. // @Produce json
  22. // @Param token formData string true "Token"
  23. // @Param phone formData string false "手机号"
  24. // @Param name formData string false "姓名"
  25. // @Param start formData string true "当前条"
  26. // @Param tableMax formData string true "每页条数"
  27. // @Success 200 {object} controller.ShopUserInfo
  28. // @Router /User/ShopUserListQuery [post]
  29. func (u *User) ShopUserListQuery() (err error) {
  30. //sess := u.Ctx().PostForm("Token")
  31. //phone := u.Ctx().PostForm("phone")
  32. //name := u.Ctx().PostForm("name")
  33. //start := u.postIntNecessary("start")
  34. //tableMax := u.postIntNecessary("tableMax")
  35. //pageIndex := start/tableMax + 1
  36. //
  37. //rs, pageCount, err := service.User{}.ShopUserListQuery(sess, phone, name, pageIndex, tableMax)
  38. //
  39. //rp := ShopUserInfo{
  40. // newResponseBase(),
  41. // pageCount,
  42. // rs,
  43. //}
  44. //u.Ctx().JSON(http.StatusOK, rp)
  45. return
  46. }
  47. type ShopUserSimpleInfo struct {
  48. ResponseBase
  49. Rs string
  50. //Rs []*gorm.ShopUserSimpleInfo
  51. }
  52. // ShopUserSimpleQuery godoc
  53. // @Summary 本店会员用户基本信息查询
  54. // @tags User
  55. // @Description 本店会员用户基本信息查询
  56. // @Accept x-www-form-urlencoded
  57. // @Produce json
  58. // @Param token formData string true "Token"
  59. // @Param shopId formData int false "商家ID"
  60. // @Success 200 {object} controller.ShopUserSimpleInfo
  61. // @Router /User/ShopUserSimpleQuery [post]
  62. func (u *User) ShopUserSimpleQuery() (err error) {
  63. //shopId := u.postInt("shopId")
  64. //
  65. //sess := u.Ctx().PostForm("Token")
  66. //rs, err := service.User{}.ShopUserSimpleQuery(sess, shopId)
  67. //
  68. //rp := ShopUserSimpleInfo{
  69. // newResponseBase(),
  70. // rs,
  71. //}
  72. //u.Ctx().JSON(http.StatusOK, rp)
  73. return
  74. }
  75. // ShopUserAdd godoc
  76. // @Summary 会员用户添加
  77. // @tags User
  78. // @Description 会员用户添加
  79. // @Accept x-www-form-urlencoded
  80. // @Produce json
  81. // @Param token formData string true "Token"
  82. // @Param shopId formData int true "店铺ID"
  83. // @Param phone formData string true "登陆用户名也是手机号"
  84. // @Param name formData string true "姓名"
  85. // @Param sex formData int true "性别 1:男, 2:女"
  86. // @Param birthday formData string true "生日"
  87. // @Param height formData int true "身高"
  88. // @Param weight formData string true "体重 "
  89. // @Param staticHr formData int false "静态心率"
  90. // @Param head formData string false "头像"
  91. // @Param memo formData string false "备注"
  92. // @Success 200 {object} controller.ResponseBase
  93. // @Router /User/ShopUserAdd [post]
  94. func (u *User) ShopUserAdd() (err error) {
  95. //usercode := u.postString("phone", true)
  96. //name := u.postString("name", true)
  97. //phone := u.postString("phone", true)
  98. //memo := u.Ctx().PostForm("memo")
  99. //
  100. //sex := u.postIntNecessary("sex")
  101. //birthday := u.getPostFromDate("birthday")
  102. //
  103. //height := u.postIntNecessary("height")
  104. //staticHr := u.postInt("staticHr")
  105. //head := u.Ctx().PostForm("head")
  106. //w := u.postFloatToInt("weight", true)
  107. //
  108. //// 如果未传入静息心率,则通过生日计算年龄后获取此年龄段的平均静息心率
  109. //if staticHr == nil {
  110. // age := utils.GetAgeByBirthday(birthday)
  111. // hr := utils.GetStaticHrByAge(age)
  112. //
  113. // staticHr = &hr
  114. //}
  115. //
  116. //
  117. //sess := u.getSession()
  118. //s := service.NewUserService()
  119. //logInfo, err := s.ShopUserAdd(sess, usercode, name, phone, memo, sex, birthday, height, w, staticHr, head)
  120. //if err != nil {
  121. //
  122. // return
  123. //}
  124. //u.saveOptLogInfo(logInfo)
  125. //
  126. //u.Ctx().JSON(http.StatusOK, newResponseBase())
  127. return
  128. }
  129. // ShopUserEdit godoc
  130. // @Summary 会员用户基本信息修改
  131. // @tags User
  132. // @Description 会员用户基本信息修改
  133. // @Accept x-www-form-urlencoded
  134. // @Produce json
  135. // @Param token formData string true "Token"
  136. // @Param userId formData int true "用户Id"
  137. // @Param phone formData string false "手机号"
  138. // @Param name formData string false "姓名"
  139. // @Param memo formData string false "备注"
  140. // @Param birthday formData string true "生日"
  141. // @Param height formData int true "身高"
  142. // @Param weight formData string true "体重"
  143. // @Param sex formData int true "性别 1:男, 2:女"
  144. // @Param staticHr formData int false "静态心率"
  145. // @Param head formData string false "头像URL"
  146. // @Success 200 {object} controller.ResponseBase
  147. // @Router /User/ShopUserEdit [post]
  148. func (u *User) ShopUserEdit() (err error) {
  149. //userId := u.postIntNecessary("userId")
  150. //name := u.Ctx().PostForm("name")
  151. //phone := u.Ctx().PostForm("phone")
  152. //memo := u.Ctx().PostForm("memo")
  153. //
  154. ////ubId := u.postInt("ubId")
  155. //height := u.postIntNecessary("height")
  156. //w := u.postFloatToInt("weight", true)
  157. //sex := u.postIntNecessary("sex")
  158. //staticHr := u.postInt("staticHr")
  159. //head := u.Ctx().PostForm("head")
  160. //birthday := u.getPostFromDate("birthday")
  161. //
  162. //// 如果未传入静息心率,则通过生日计算年龄后获取此年龄段的平均静息心率
  163. //if staticHr == nil {
  164. // age := utils.GetAgeByBirthday(birthday)
  165. // hr := utils.GetStaticHrByAge(age)
  166. // staticHr = &hr
  167. //}
  168. //
  169. //sess := u.getSession()
  170. //logInfo, err := service.User{}.ShopUserEdit(sess, userId, name, phone, memo, height, w, sex, staticHr, head, birthday)
  171. //if err != nil {
  172. //
  173. // return
  174. //}
  175. //u.saveOptLogInfo(logInfo)
  176. //
  177. //u.Ctx().JSON(http.StatusOK, newResponseBase())
  178. return
  179. }
  180. // ShopUserStatusEdit godoc
  181. // @Summary 会员用户状态修改
  182. // @tags User
  183. // @Description 会员用户状态修改
  184. // @Accept x-www-form-urlencoded
  185. // @Produce json
  186. // @Param token formData string true "Token"
  187. // @Param userId formData int true "用户ID"
  188. // @Param status formData int true "状态 1:启用 8:禁用 9:删除"
  189. // @Success 200 {object} controller.ResponseBase
  190. // @Router /User/ShopUserStatusEdit [post]
  191. func (u *User) ShopUserStatusEdit() (err error) {
  192. //userId := u.postIntNecessary("userId")
  193. //status := u.postIntNecessary("status")
  194. //
  195. //sess := u.getSession()
  196. //logInfo, err := service.User{}.ShopUserStatusEdit(sess, userId, status)
  197. //if err != nil {
  198. // return
  199. //}
  200. //u.saveOptLogInfo(logInfo)
  201. //
  202. //u.Ctx().JSON(http.StatusOK, newResponseBase())
  203. return
  204. }
  205. // ShopCoachAdd godoc
  206. // @Summary 商家教练添加
  207. // @tags User
  208. // @Description 商家教练添加
  209. // @Accept x-www-form-urlencoded
  210. // @Produce json
  211. // @Param token formData string true "Token"
  212. // @Param shopId formData int true "店铺ID"
  213. // @Param phone formData string true "登陆用户名也是手机号"
  214. // @Param name formData string true "姓名"
  215. // @Param pwd formData string true "密码"
  216. // @Param sex formData int true "性别 1:男, 2:女"
  217. // @Param memo formData string false "备注"
  218. // @Success 200 {object} controller.ResponseBase
  219. // @Router /User/ShopCoachAdd [post]
  220. func (u *User) ShopCoachAdd() (err error) {
  221. //usercode := u.postString("phone", true)
  222. //name := u.postString("name", true)
  223. //phone := u.postString("phone", true)
  224. //pwd := u.postString("pwd", true)
  225. //memo := u.Ctx().PostForm("memo")
  226. //
  227. //sex := u.postIntNecessary("sex")
  228. //sess := u.getSession()
  229. //s := service.NewUserService()
  230. //logInfo, err := s.ShopCoachAdd(sess, usercode, name, phone, memo, sex, pwd)
  231. //if err != nil {
  232. //
  233. // return
  234. //}
  235. //u.saveOptLogInfo(logInfo)
  236. //
  237. //u.Ctx().JSON(http.StatusOK, newResponseBase())
  238. return
  239. }
  240. // ShopCoachEdit godoc
  241. // @Summary 商家教练基本信息修改
  242. // @tags User
  243. // @Description 商家教练基本信息修改
  244. // @Accept x-www-form-urlencoded
  245. // @Produce json
  246. // @Param token formData string true "Token"
  247. // @Param ssId formData int true "教练ID"
  248. // @Param phone formData string false "手机号"
  249. // @Param pwd formData string false "密码"
  250. // @Param name formData string false "姓名"
  251. // @Param memo formData string false "备注"
  252. // @Param sex formData int true "性别 1:男, 2:女"
  253. // @Success 200 {object} controller.ResponseBase
  254. // @Router /User/ShopCoachEdit [post]
  255. func (u *User) ShopCoachEdit() (err error) {
  256. //ssId := u.postIntNecessary("ssId")
  257. //name := u.Ctx().PostForm("name")
  258. //phone := u.Ctx().PostForm("phone")
  259. //pwd := u.Ctx().PostForm("pwd")
  260. //memo := u.Ctx().PostForm("memo")
  261. //
  262. //sex := u.postIntNecessary("sex")
  263. //
  264. //sess := u.getSession()
  265. //logInfo, err := service.User{}.ShopCoachEdit(sess, ssId, name, phone, memo, sex, pwd)
  266. //if err != nil {
  267. //
  268. // return
  269. //}
  270. //u.saveOptLogInfo(logInfo)
  271. //
  272. //u.Ctx().JSON(http.StatusOK, newResponseBase())
  273. return
  274. }
  275. // ShopCoachStatusEdit godoc
  276. // @Summary 商家教练状态修改
  277. // @tags User
  278. // @Description 商家教练状态修改
  279. // @Accept x-www-form-urlencoded
  280. // @Produce json
  281. // @Param token formData string true "Token"
  282. // @Param ssId formData int true "教练ID"
  283. // @Param status formData int true "状态 1:启用 8:禁用 9:删除"
  284. // @Success 200 {object} controller.ResponseBase
  285. // @Router /User/ShopCoachStatusEdit [post]
  286. func (u *User) ShopCoachStatusEdit() (err error) {
  287. //ssId := u.postIntNecessary("ssId")
  288. //status := u.postIntNecessary("status")
  289. //
  290. //sess := u.getSession()
  291. //logInfo, err := service.User{}.ShopCoachStatusEdit(sess, ssId, status)
  292. //if err != nil {
  293. // return
  294. //}
  295. //u.saveOptLogInfo(logInfo)
  296. //
  297. //u.Ctx().JSON(http.StatusOK, newResponseBase())
  298. return
  299. }
  300. type ShopCoachInfo struct {
  301. ResponseBase
  302. PageCount int64
  303. Rs string
  304. }
  305. // ShopCoachListQuery godoc
  306. // @Summary 会员用户列表(带分页)
  307. // @tags User
  308. // @Description 会员用户列表(带分页)
  309. // @Accept x-www-form-urlencoded
  310. // @Produce json
  311. // @Param token formData string true "Token"
  312. // @Param phone formData string false "手机号"
  313. // @Param name formData string false "姓名"
  314. // @Param start formData string true "当前条"
  315. // @Param tableMax formData string true "每页条数"
  316. // @Success 200 {object} controller.ShopUserInfo
  317. // @Router /User/ShopCoachListQuery [post]
  318. func (u *User) ShopCoachListQuery() (err error) {
  319. //sess := u.Ctx().PostForm("Token")
  320. //phone := u.Ctx().PostForm("phone")
  321. //name := u.Ctx().PostForm("name")
  322. //start := u.postIntNecessary("start")
  323. //tableMax := u.postIntNecessary("tableMax")
  324. //pageIndex := start/tableMax + 1
  325. //
  326. //rs, pageCount, err := service.User{}.ShopCoachListQuery(sess, phone, name, pageIndex, tableMax)
  327. //
  328. //rp := ShopCoachInfo{
  329. // newResponseBase(),
  330. // pageCount,
  331. // rs,
  332. //}
  333. //u.Ctx().JSON(http.StatusOK, rp)
  334. return
  335. }
  336. type ShopCoachSimpleInfo struct {
  337. ResponseBase
  338. Rs string
  339. //Rs []*gorm.ShopUserSimpleInfo
  340. }
  341. // ShopCoachSimpleQuery godoc
  342. // @Summary 本店会员用户基本信息查询
  343. // @tags User
  344. // @Description 本店会员用户基本信息查询
  345. // @Accept x-www-form-urlencoded
  346. // @Produce json
  347. // @Param token formData string true "Token"
  348. // @Param shopId formData int false "商家ID"
  349. // @Success 200 {object} controller.ShopCoachSimpleInfo
  350. // @Router /User/ShopCoachSimpleQuery [post]
  351. func (u *User) ShopCoachSimpleQuery() (err error) {
  352. //shopId := u.postInt("shopId")
  353. //
  354. //sess := u.Ctx().PostForm("Token")
  355. //rs, err := service.User{}.ShopCoachSimpleQuery(sess, shopId)
  356. //
  357. //rp := ShopCoachSimpleInfo{
  358. // newResponseBase(),
  359. // rs,
  360. //}
  361. //u.Ctx().JSON(http.StatusOK, rp)
  362. return
  363. }