hrSensors.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /**
  2. * @ File:
  3. * @ Date: 2021/1/25 16:15
  4. * @ Author: JYQ
  5. * @ Description:
  6. */
  7. package controller
  8. type HrSensors struct {
  9. BaseController
  10. }
  11. // AddHrSensors godoc
  12. // @Summary 添加商家公共心率设备
  13. // @tags HrSensors
  14. // @Description 添加商家公共心率设备
  15. // @Accept x-www-form-urlencoded
  16. // @Produce json
  17. // @Param token formData string true "Token"
  18. // @Param shopId formData int true "商家ID"
  19. // @Param sn formData int true "心率带Sn"
  20. // @Param venueNo formData string false "场馆内编号 01 02"
  21. // @Success 200 {object} controller.ResponseBase
  22. // @Router /HrSensors/AddHrSensors [post]
  23. func (h *HrSensors) AddHrSensors() (err error) {
  24. //sess := h.Ctx().PostForm("Token")
  25. //sn := h.postString("sn", true)
  26. //venueNo := h.Ctx().PostForm("venueNo")
  27. //shopId := h.postIntNecessary("shopId")
  28. //
  29. //logInfo, err := service.HrSensors{}.AddHrSensors(sess, sn, venueNo, shopId)
  30. //if err != nil {
  31. // return
  32. //}
  33. //h.saveOptLogInfo(logInfo)
  34. //h.json(newResponseBase())
  35. return
  36. }
  37. // AddPvtHrSensors godoc
  38. // @Summary 添加会员私有心率设备
  39. // @tags HrSensors
  40. // @Description 添加会员私有心率设备
  41. // @Accept x-www-form-urlencoded
  42. // @Produce json
  43. // @Param token formData string true "Token"
  44. // @Param shopId formData int true "商家ID"
  45. // @Param sn formData int true "心率带Sn"
  46. // @Param userId formData int true "用户ID"
  47. // @Success 200 {object} controller.ResponseBase
  48. // @Router /HrSensors/AddPvtHrSensors [post]
  49. func (h *HrSensors) AddPvtHrSensors() (err error) {
  50. //sess := h.Ctx().PostForm("Token")
  51. //sn := h.postString("sn", true)
  52. //shopId := h.postIntNecessary("shopId")
  53. //userId := h.postIntNecessary("userId")
  54. //
  55. //logInfo, err := service.HrSensors{}.AddPvtHrSensors(sess, sn, userId, shopId)
  56. //if err != nil {
  57. // return
  58. //}
  59. //h.saveOptLogInfo(logInfo)
  60. //h.json(newResponseBase())
  61. return
  62. }
  63. // EditHrSensors godoc
  64. // @Summary 修改商家心率设备信息
  65. // @tags HrSensors
  66. // @Description 修改商家心率设备信息
  67. // @Accept x-www-form-urlencoded
  68. // @Produce json
  69. // @Param token formData string true "Token"
  70. // @Param hrId formData int true "心率带ID"
  71. // @Param sn formData string true "心率带Sn"
  72. // @Param shopId formData string true "商家ID"
  73. // @Param venueNo formData string false "场馆内编号 01 02"
  74. // @Success 200 {object} controller.ResponseBase
  75. // @Router /HrSensors/EditHrSensors [post]
  76. func (h *HrSensors) EditHrSensors() (err error) {
  77. //sess := h.getSession()
  78. //sn := h.postString("sn", true)
  79. //venueNo := h.Ctx().PostForm("venueNo")
  80. //hrId := h.postIntNecessary("hrId")
  81. //shopId := h.postIntNecessary("shopId")
  82. //
  83. //logInfo, err := service.HrSensors{}.EditHrSensors(sess, sn, venueNo, shopId, hrId)
  84. //if err != nil {
  85. // return
  86. //}
  87. //h.saveOptLogInfo(logInfo)
  88. //h.json(newResponseBase())
  89. return
  90. }
  91. // HrSensorsStatusEdit godoc
  92. // @Summary 修改商家心率设备状态
  93. // @tags HrSensors
  94. // @Description 修改商家心率设备状态
  95. // @Accept x-www-form-urlencoded
  96. // @Produce json
  97. // @Param token formData string true "Token"
  98. // @Param hrId formData int true "心率带ID"
  99. // @Param status formData int true "状态, 1:启用,8:暂停,9:删除"
  100. // @Success 200 {object} controller.ResponseBase
  101. // @Router /HrSensors/HrSensorsStatusEdit [post]
  102. func (h *HrSensors) HrSensorsStatusEdit() (err error) {
  103. //sess := h.getSession()
  104. //hrId := h.postIntNecessary("hrId")
  105. //status := h.postIntNecessary("status")
  106. //
  107. //logInfo, err := service.HrSensors{}.HrSensorsStatusEdit(sess, hrId, status)
  108. //if err != nil {
  109. // return
  110. //}
  111. //h.saveOptLogInfo(logInfo)
  112. //h.json(newResponseBase())
  113. return
  114. }
  115. type QueryHrSensorsInfo struct {
  116. ResponseBase
  117. Rs string
  118. }
  119. // QueryHrSensors godoc
  120. // @Summary 查询商家公共心率设备
  121. // @tags HrSensors
  122. // @Description 查询商家公共心率设备
  123. // @Accept x-www-form-urlencoded
  124. // @Produce json
  125. // @Param token formData string true "Token"
  126. // @Param shopId formData int true "商家ID"
  127. // @Param status formData int false "设备状态"
  128. // @Param str formData string false "模糊查询sn与场内编号"
  129. // @Success 200 {object} controller.ResponseBase
  130. // @Router /HrSensors/QueryHrSensors [post]
  131. func (h *HrSensors) QueryHrSensors() (err error) {
  132. //sess := h.getSession()
  133. //str := h.Ctx().PostForm("str")
  134. //shopId := h.postIntNecessary("shopId")
  135. //status := h.postInt("status")
  136. //hr, err := service.HrSensors{}.QueryHrSensors(sess, shopId, str, status)
  137. //if err != nil {
  138. // return
  139. //}
  140. //h.json(QueryHrSensorsInfo{
  141. // ResponseBase: ResponseBase{},
  142. // Rs: hr,
  143. //})
  144. return
  145. }
  146. // QueryPvtHrSensors godoc
  147. // @Summary 查询商家会员私有心率设备
  148. // @tags HrSensors
  149. // @Description 查询商家会员私有心率设备
  150. // @Accept x-www-form-urlencoded
  151. // @Produce json
  152. // @Param token formData string true "Token"
  153. // @Param shopId formData int true "商家ID"
  154. // @Param status formData int false "设备状态"
  155. // @Param userName formData string false "用户姓名"
  156. // @Param str formData string false "模糊查询sn与场内编号"
  157. // @Success 200 {object} controller.ResponseBase
  158. // @Router /HrSensors/QueryPvtHrSensors [post]
  159. func (h *HrSensors) QueryPvtHrSensors() (err error) {
  160. //sess := h.getSession()
  161. //str := h.Ctx().PostForm("str")
  162. //userName := h.Ctx().PostForm("userName")
  163. //shopId := h.postIntNecessary("shopId")
  164. //status := h.postInt("status")
  165. //hr, err := service.HrSensors{}.QueryPvtHrSensors(sess, shopId, str, userName, status)
  166. //if err != nil {
  167. // return
  168. //}
  169. //h.json(QueryHrSensorsInfo{
  170. // ResponseBase: ResponseBase{},
  171. // Rs: hr,
  172. //})
  173. return
  174. }
  175. // BindHrSensorsToUser godoc
  176. // @Summary 心率带绑定用户
  177. // @tags HrSensors
  178. // @Description 心率带绑定用户
  179. // @Accept x-www-form-urlencoded
  180. // @Produce json
  181. // @Param token formData string true "Token"
  182. // @Param sn formData string true "心率带Sn"
  183. // @Param cfId formData int true "课堂记录Id,必传字段"
  184. // @Param userId formData int true "用户Id"
  185. // @Param shopId formData int true "商家ID"
  186. // @Param hrId formData int true "心率带ID"
  187. // @Success 200 {object} controller.ResponseBase
  188. // @Router /HrSensors/BindHrSensorsToUser [post]
  189. func (h *HrSensors) BindHrSensorsToUser() (err error) {
  190. //sess := h.getSession()
  191. //sn := h.postString("sn", true)
  192. //cfId := h.postIntNecessary("cfId")
  193. //userId := h.postIntNecessary("userId")
  194. //shopId := h.postIntNecessary("shopId")
  195. //hrId := h.postIntNecessary("hrId")
  196. ////dpId := h.postInt("dpId") // 用来判断是否上课的依据,目前不需要前台传递,根据cfId进行反查。且未确认上课时cf表中dpId=0
  197. ////oldSn := h.Ctx().PostForm("oldSn")
  198. //
  199. //logInfo, err := service.HrSensors{}.HrSensorsBindUser(sess, sn, cfId, userId, shopId, hrId)
  200. //if err != nil {
  201. // return
  202. //}
  203. //h.saveOptLogInfo(logInfo)
  204. //h.json(newResponseBase())
  205. return
  206. }
  207. // UnBindHrSensorsToUser godoc
  208. // @Summary 心率带解绑用户
  209. // @tags HrSensors
  210. // @Description 心率带解绑用户
  211. // @Accept x-www-form-urlencoded
  212. // @Produce json
  213. // @Param token formData string true "Token"
  214. // @Param cfId formData int true "课堂记录Id,必传字段"
  215. // @Param bindId formData int true "绑定ID"
  216. // @Param userId formData int true "用户ID"
  217. // @Param sn formData string true "心率带Sn"
  218. // @Success 200 {object} controller.ResponseBase
  219. // @Router /HrSensors/UnBindHrSensorsToUser [post]
  220. func (h *HrSensors) UnBindHrSensorsToUser() (err error) {
  221. //sess := h.getSession()
  222. //cfId := h.postIntNecessary("cfId")
  223. //bindId := h.postIntNecessary("bindId")
  224. //userId := h.postIntNecessary("userId")
  225. //sn := h.postString("sn", true)
  226. //
  227. //logInfo, err := service.HrSensors{}.UnBindHrSensorsToUser(sess, sn, cfId, bindId, userId)
  228. //if err != nil {
  229. // return
  230. //}
  231. //h.saveOptLogInfo(logInfo)
  232. //h.json(newResponseBase())
  233. return
  234. }
  235. type SelectHrSensorsRs struct {
  236. ResponseBase
  237. Rs string
  238. //Rs []*model.HrSensors
  239. }
  240. // SelectHrSensors godoc
  241. // @Summary 查询未绑定的心率带--下拉框用
  242. // @tags HrSensors
  243. // @Description 查询未绑定的心率带--下拉框用
  244. // @Accept x-www-form-urlencoded
  245. // @Produce json
  246. // @Param token formData string true "Token"
  247. // @Param userId formData int false "用户ID"
  248. // @Success 200 {object} controller.ResponseBase
  249. // @Router /HrSensors/SelectHrSensors [post]
  250. func (h *HrSensors) SelectHrSensors() (err error) {
  251. //sess := h.getSession()
  252. //userId := h.postInt("userId")
  253. //rs, err := service.HrSensors{}.SelectHrSensors(sess, userId)
  254. //if err != nil {
  255. // return
  256. //}
  257. //h.json(SelectHrSensorsRs{
  258. // ResponseBase: ResponseBase{},
  259. // Rs: rs,
  260. //})
  261. return
  262. }
  263. type HrSensorsBindHistoryRs struct {
  264. ResponseBase
  265. Rs string
  266. }
  267. // HrSensorsBindHistory godoc
  268. // @Summary 查询心率带绑定历史记录
  269. // @tags HrSensors
  270. // @Description 查询心率带绑定历史记录
  271. // @Accept x-www-form-urlencoded
  272. // @Produce json
  273. // @Param token formData string true "Token"
  274. // @Param hrId formData int false "心率带ID"
  275. // @Param bt formData string true "开始时间 2020-10-10 00:00:01"
  276. // @Param et formData string true "结束时间 2020-10-10 23:59:59"
  277. // @Success 200 {object} controller.ResponseBase
  278. // @Router /HrSensors/HrSensorsBindHistory [post]
  279. func (h *HrSensors) HrSensorsBindHistory() (err error) {
  280. //sess := h.getSession()
  281. //bt, err := h.getPostFromTime("bt")
  282. //if err != nil {
  283. // return
  284. //}
  285. //et, err := h.getPostFromTime("et")
  286. //if err != nil {
  287. // return
  288. //}
  289. //hrId := h.postInt("hrId")
  290. //
  291. //rs, err := service.HrSensors{}.HrSensorsBindHistory(sess, hrId, bt, et)
  292. //if err != nil {
  293. // return
  294. //}
  295. //h.json(HrSensorsBindHistoryRs{
  296. // ResponseBase: ResponseBase{},
  297. // Rs: rs,
  298. //})
  299. return
  300. }
  301. // GetHrSensorsPowerPercent godoc
  302. // @Summary 获取心率带电量
  303. // @tags HrSensors
  304. // @Description 获取心率带电量
  305. // @Accept x-www-form-urlencoded
  306. // @Produce json
  307. // @Param token formData string true "Token"
  308. // @Param shopId formData int true "商家ID"
  309. // @Param hrId formData int false "心率带Id"
  310. // @Success 200 {object} controller.ResponseBase
  311. // @Router /HrSensors/GetHrSensorsPowerPercent [post]
  312. func (h *HrSensors) GetHrSensorsPowerPercent() (err error) {
  313. //sess := h.getSession()
  314. //shopId := h.postIntNecessary("shopId")
  315. //hrId := h.postInt("hrId")
  316. ////jsonStr := h.postString("jsonStr", false)
  317. ////dpId := h.postInt("dpId") // 用来判断是否上课的依据,目前不需要前台传递,根据cfId进行反查。且未确认上课时cf表中dpId=0
  318. ////oldSn := h.Ctx().PostForm("oldSn")
  319. //
  320. //logInfo, err := service.HrSensors{}.GetHrSensorsPowerPercent(sess, shopId, hrId)
  321. //if err != nil {
  322. // return
  323. //}
  324. //h.saveOptLogInfo(logInfo)
  325. //h.json(newResponseBase())
  326. return
  327. }