浏览代码

Merge remote-tracking branch 'origin/master'

jyq 5 年之前
父节点
当前提交
b359911268
共有 15 个文件被更改,包括 364 次插入522 次删除
  1. 3 5
      controller/auth.go
  2. 33 331
      controller/hrSensors.go
  3. 50 54
      controller/test.go
  4. 36 2
      controller/user.go
  5. 29 44
      docs/docs.go
  6. 29 44
      docs/swagger.json
  7. 24 34
      docs/swagger.yaml
  8. 6 0
      errors/error.go
  9. 1 1
      go.mod
  10. 1 0
      main.go
  11. 6 0
      model/duInfo.go
  12. 93 0
      repository/http/heartrate_server.go
  13. 9 7
      service/auth.go
  14. 27 0
      service/hrsensors.go
  15. 17 0
      service/user.go

+ 3 - 5
controller/auth.go

@@ -82,16 +82,14 @@ func (a *Auth) GenVerifyPic() (err error) {
 // @Produce  json
 // @Param phone formData string true "手机号"
 // @Param codeType formData int true "验证码类型 1:登录"
-// @Param picId formData string true "图形验证码id"
-// @Param picCode formData string true "图形验证码"
 // @Success 200 {object} controller.ResponseBase
 // @Router /Auth/GetPhoneVFCode [post]
 func (a *Auth) GetPhoneVFCode() (err error) {
 	phone := a.postString("phone", true)
 	codeType := a.postIntNecessary("codeType")
-	picId := a.Ctx().PostForm("picId")
-	picCode := a.Ctx().PostForm("picCode")
-	err = service.Auth{}.GenVFCode(codeType, phone, a.getIp(), picId, picCode)
+	//picId := a.Ctx().PostForm("picId")
+	//picCode := a.Ctx().PostForm("picCode")
+	err = service.Auth{}.GenVFCode(codeType, phone, a.getIp())
 	if err != nil {
 		return
 	}

+ 33 - 331
controller/hrSensors.go

@@ -6,338 +6,40 @@
  */
 package controller
 
+import (
+	"net/http"
+	"video_course/service"
+)
+
 type HrSensors struct {
 	BaseController
 }
+type UpdateHrSensorsInfo struct {
+	ResponseBase
+	HrId int
+}
 
-//
-//// AddHrSensors godoc
-//// @Summary 添加商家公共心率设备
-//// @tags HrSensors
-//// @Description 添加商家公共心率设备
-//// @Accept  x-www-form-urlencoded
-//// @Produce  json
-//// @Param token formData string true "Token"
-//// @Param shopId formData int true "商家ID"
-//// @Param sn formData int true "心率带Sn"
-//// @Param venueNo formData string false "场馆内编号  01 02"
-//// @Success 200 {object} controller.ResponseBase
-//// @Router /HrSensors/AddHrSensors [post]
-//func (h *HrSensors) AddHrSensors() (err error) {
-//	//sess := h.Ctx().PostForm("Token")
-//	//sn := h.postString("sn", true)
-//	//venueNo := h.Ctx().PostForm("venueNo")
-//	//shopId := h.postIntNecessary("shopId")
-//	//
-//	//logInfo, err := service.HrSensors{}.AddHrSensors(sess, sn, venueNo, shopId)
-//	//if err != nil {
-//	//	return
-//	//}
-//	//h.saveOptLogInfo(logInfo)
-//	//h.json(newResponseBase())
-//	return
-//}
-//
-//// AddPvtHrSensors godoc
-//// @Summary 添加会员私有心率设备
-//// @tags HrSensors
-//// @Description 添加会员私有心率设备
-//// @Accept  x-www-form-urlencoded
-//// @Produce  json
-//// @Param token formData string true "Token"
-//// @Param shopId formData int true "商家ID"
-//// @Param sn formData int true "心率带Sn"
-//// @Param userId formData int true "用户ID"
-//// @Success 200 {object} controller.ResponseBase
-//// @Router /HrSensors/AddPvtHrSensors [post]
-//func (h *HrSensors) AddPvtHrSensors() (err error) {
-//	//sess := h.Ctx().PostForm("Token")
-//	//sn := h.postString("sn", true)
-//	//shopId := h.postIntNecessary("shopId")
-//	//userId := h.postIntNecessary("userId")
-//	//
-//	//logInfo, err := service.HrSensors{}.AddPvtHrSensors(sess, sn, userId, shopId)
-//	//if err != nil {
-//	//	return
-//	//}
-//	//h.saveOptLogInfo(logInfo)
-//	//h.json(newResponseBase())
-//	return
-//}
-//
-//// EditHrSensors godoc
-//// @Summary 修改商家心率设备信息
-//// @tags HrSensors
-//// @Description 修改商家心率设备信息
-//// @Accept  x-www-form-urlencoded
-//// @Produce  json
-//// @Param token formData string true "Token"
-//// @Param hrId formData int true "心率带ID"
-//// @Param sn formData string true "心率带Sn"
-//// @Param shopId formData string true "商家ID"
-//// @Param venueNo formData string false "场馆内编号  01 02"
-//// @Success 200 {object} controller.ResponseBase
-//// @Router /HrSensors/EditHrSensors [post]
-//func (h *HrSensors) EditHrSensors() (err error) {
-//	//sess := h.getSession()
-//	//sn := h.postString("sn", true)
-//	//venueNo := h.Ctx().PostForm("venueNo")
-//	//hrId := h.postIntNecessary("hrId")
-//	//shopId := h.postIntNecessary("shopId")
-//	//
-//	//logInfo, err := service.HrSensors{}.EditHrSensors(sess, sn, venueNo, shopId, hrId)
-//	//if err != nil {
-//	//	return
-//	//}
-//	//h.saveOptLogInfo(logInfo)
-//	//h.json(newResponseBase())
-//	return
-//}
-//
-//// HrSensorsStatusEdit godoc
-//// @Summary 修改商家心率设备状态
-//// @tags HrSensors
-//// @Description 修改商家心率设备状态
-//// @Accept  x-www-form-urlencoded
-//// @Produce  json
-//// @Param token formData string true "Token"
-//// @Param hrId formData int true "心率带ID"
-//// @Param status formData int true "状态, 1:启用,8:暂停,9:删除"
-//// @Success 200 {object} controller.ResponseBase
-//// @Router /HrSensors/HrSensorsStatusEdit [post]
-//func (h *HrSensors) HrSensorsStatusEdit() (err error) {
-//	//sess := h.getSession()
-//	//hrId := h.postIntNecessary("hrId")
-//	//status := h.postIntNecessary("status")
-//	//
-//	//logInfo, err := service.HrSensors{}.HrSensorsStatusEdit(sess, hrId, status)
-//	//if err != nil {
-//	//	return
-//	//}
-//	//h.saveOptLogInfo(logInfo)
-//	//h.json(newResponseBase())
-//	return
-//}
-//
-//type QueryHrSensorsInfo struct {
-//	ResponseBase
-//	Rs string
-//}
-//
-//// QueryHrSensors godoc
-//// @Summary 查询商家公共心率设备
-//// @tags HrSensors
-//// @Description 查询商家公共心率设备
-//// @Accept  x-www-form-urlencoded
-//// @Produce  json
-//// @Param token formData string true "Token"
-//// @Param shopId formData int true "商家ID"
-//// @Param status formData int false "设备状态"
-//// @Param str formData string false "模糊查询sn与场内编号"
-//// @Success 200 {object} controller.ResponseBase
-//// @Router /HrSensors/QueryHrSensors [post]
-//func (h *HrSensors) QueryHrSensors() (err error) {
-//	//sess := h.getSession()
-//	//str := h.Ctx().PostForm("str")
-//	//shopId := h.postIntNecessary("shopId")
-//	//status := h.postInt("status")
-//	//hr, err := service.HrSensors{}.QueryHrSensors(sess, shopId, str, status)
-//	//if err != nil {
-//	//	return
-//	//}
-//	//h.json(QueryHrSensorsInfo{
-//	//	ResponseBase: ResponseBase{},
-//	//	Rs:           hr,
-//	//})
-//	return
-//}
-//
-//// QueryPvtHrSensors godoc
-//// @Summary 查询商家会员私有心率设备
-//// @tags HrSensors
-//// @Description 查询商家会员私有心率设备
-//// @Accept  x-www-form-urlencoded
-//// @Produce  json
-//// @Param token formData string true "Token"
-//// @Param shopId formData int true "商家ID"
-//// @Param status formData int false "设备状态"
-//// @Param userName formData string false "用户姓名"
-//// @Param str formData string false "模糊查询sn与场内编号"
-//// @Success 200 {object} controller.ResponseBase
-//// @Router /HrSensors/QueryPvtHrSensors [post]
-//func (h *HrSensors) QueryPvtHrSensors() (err error) {
-//	//sess := h.getSession()
-//	//str := h.Ctx().PostForm("str")
-//	//userName := h.Ctx().PostForm("userName")
-//	//shopId := h.postIntNecessary("shopId")
-//	//status := h.postInt("status")
-//	//hr, err := service.HrSensors{}.QueryPvtHrSensors(sess, shopId, str, userName, status)
-//	//if err != nil {
-//	//	return
-//	//}
-//	//h.json(QueryHrSensorsInfo{
-//	//	ResponseBase: ResponseBase{},
-//	//	Rs:           hr,
-//	//})
-//	return
-//}
-//
-//// BindHrSensorsToUser godoc
-//// @Summary 心率带绑定用户
-//// @tags HrSensors
-//// @Description 心率带绑定用户
-//// @Accept  x-www-form-urlencoded
-//// @Produce  json
-//// @Param token formData string true "Token"
-//// @Param sn formData string true "心率带Sn"
-//// @Param cfId formData int true "课堂记录Id,必传字段"
-//// @Param userId formData int true "用户Id"
-//// @Param shopId formData int true "商家ID"
-//// @Param hrId formData int true "心率带ID"
-//// @Success 200 {object} controller.ResponseBase
-//// @Router /HrSensors/BindHrSensorsToUser [post]
-//func (h *HrSensors) BindHrSensorsToUser() (err error) {
-//	//sess := h.getSession()
-//	//sn := h.postString("sn", true)
-//	//cfId := h.postIntNecessary("cfId")
-//	//userId := h.postIntNecessary("userId")
-//	//shopId := h.postIntNecessary("shopId")
-//	//hrId := h.postIntNecessary("hrId")
-//	////dpId := h.postInt("dpId")  // 用来判断是否上课的依据,目前不需要前台传递,根据cfId进行反查。且未确认上课时cf表中dpId=0
-//	////oldSn := h.Ctx().PostForm("oldSn")
-//	//
-//	//logInfo, err := service.HrSensors{}.HrSensorsBindUser(sess, sn, cfId, userId, shopId, hrId)
-//	//if err != nil {
-//	//	return
-//	//}
-//	//h.saveOptLogInfo(logInfo)
-//	//h.json(newResponseBase())
-//	return
-//}
-//
-//// UnBindHrSensorsToUser godoc
-//// @Summary 心率带解绑用户
-//// @tags HrSensors
-//// @Description 心率带解绑用户
-//// @Accept  x-www-form-urlencoded
-//// @Produce  json
-//// @Param token formData string true "Token"
-//// @Param cfId formData int true "课堂记录Id,必传字段"
-//// @Param bindId formData int true "绑定ID"
-//// @Param userId formData int true "用户ID"
-//// @Param sn formData string true "心率带Sn"
-//// @Success 200 {object} controller.ResponseBase
-//// @Router /HrSensors/UnBindHrSensorsToUser [post]
-//func (h *HrSensors) UnBindHrSensorsToUser() (err error) {
-//	//sess := h.getSession()
-//	//cfId := h.postIntNecessary("cfId")
-//	//bindId := h.postIntNecessary("bindId")
-//	//userId := h.postIntNecessary("userId")
-//	//sn := h.postString("sn", true)
-//	//
-//	//logInfo, err := service.HrSensors{}.UnBindHrSensorsToUser(sess, sn, cfId, bindId, userId)
-//	//if err != nil {
-//	//	return
-//	//}
-//	//h.saveOptLogInfo(logInfo)
-//	//h.json(newResponseBase())
-//	return
-//}
-//
-//type SelectHrSensorsRs struct {
-//	ResponseBase
-//	Rs string
-//	//Rs []*model.HrSensors
-//}
-//
-//// SelectHrSensors godoc
-//// @Summary 查询未绑定的心率带--下拉框用
-//// @tags HrSensors
-//// @Description 查询未绑定的心率带--下拉框用
-//// @Accept  x-www-form-urlencoded
-//// @Produce  json
-//// @Param token formData string true "Token"
-//// @Param userId formData int false "用户ID"
-//// @Success 200 {object} controller.ResponseBase
-//// @Router /HrSensors/SelectHrSensors [post]
-//func (h *HrSensors) SelectHrSensors() (err error) {
-//	//sess := h.getSession()
-//	//userId := h.postInt("userId")
-//	//rs, err := service.HrSensors{}.SelectHrSensors(sess, userId)
-//	//if err != nil {
-//	//	return
-//	//}
-//	//h.json(SelectHrSensorsRs{
-//	//	ResponseBase: ResponseBase{},
-//	//	Rs:           rs,
-//	//})
-//	return
-//}
-//
-//type HrSensorsBindHistoryRs struct {
-//	ResponseBase
-//	Rs string
-//}
-//
-//// HrSensorsBindHistory godoc
-//// @Summary 查询心率带绑定历史记录
-//// @tags HrSensors
-//// @Description 查询心率带绑定历史记录
-//// @Accept  x-www-form-urlencoded
-//// @Produce  json
-//// @Param token formData string true "Token"
-//// @Param hrId formData int false "心率带ID"
-//// @Param bt formData string true "开始时间  2020-10-10 00:00:01"
-//// @Param et formData string true "结束时间  2020-10-10 23:59:59"
-//// @Success 200 {object} controller.ResponseBase
-//// @Router /HrSensors/HrSensorsBindHistory [post]
-//func (h *HrSensors) HrSensorsBindHistory() (err error) {
-//	//sess := h.getSession()
-//	//bt, err := h.getPostFromTime("bt")
-//	//if err != nil {
-//	//	return
-//	//}
-//	//et, err := h.getPostFromTime("et")
-//	//if err != nil {
-//	//	return
-//	//}
-//	//hrId := h.postInt("hrId")
-//	//
-//	//rs, err := service.HrSensors{}.HrSensorsBindHistory(sess, hrId, bt, et)
-//	//if err != nil {
-//	//	return
-//	//}
-//	//h.json(HrSensorsBindHistoryRs{
-//	//	ResponseBase: ResponseBase{},
-//	//	Rs:           rs,
-//	//})
-//	return
-//}
-//
-//// GetHrSensorsPowerPercent godoc
-//// @Summary 获取心率带电量
-//// @tags HrSensors
-//// @Description 获取心率带电量
-//// @Accept  x-www-form-urlencoded
-//// @Produce  json
-//// @Param token formData string true "Token"
-//// @Param shopId formData int true "商家ID"
-//// @Param hrId formData int false "心率带Id"
-//// @Success 200 {object} controller.ResponseBase
-//// @Router /HrSensors/GetHrSensorsPowerPercent [post]
-//func (h *HrSensors) GetHrSensorsPowerPercent() (err error) {
-//	//sess := h.getSession()
-//	//shopId := h.postIntNecessary("shopId")
-//	//hrId := h.postInt("hrId")
-//	////jsonStr := h.postString("jsonStr", false)
-//	////dpId := h.postInt("dpId")  // 用来判断是否上课的依据,目前不需要前台传递,根据cfId进行反查。且未确认上课时cf表中dpId=0
-//	////oldSn := h.Ctx().PostForm("oldSn")
-//	//
-//	//logInfo, err := service.HrSensors{}.GetHrSensorsPowerPercent(sess, shopId, hrId)
-//	//if err != nil {
-//	//	return
-//	//}
-//	//h.saveOptLogInfo(logInfo)
-//	//h.json(newResponseBase())
-//	return
-//}
+// HrSensorsUpdate godoc
+// @Summary 心率带信息查询和更新
+// @tags HrSensors
+// @Description  心率带信息查询和更新
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param sn formData string true "心率带编号"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/HrSensorsUpdate [post]
+func (h *HrSensors) HrSensorsUpdate() (err error) {
+	token := h.Ctx().PostForm("token")
+	sn := h.Ctx().PostForm("sn")
+	hrId, err := service.HrSensors{}.HrSensorsUpdate(token, sn)
+	if err != nil {
+		return
+	}
+	r := UpdateHrSensorsInfo{
+		newResponseBase(),
+		hrId,
+	}
+	h.Ctx().JSON(http.StatusOK, r)
+	return
+}

+ 50 - 54
controller/test.go

@@ -1,60 +1,56 @@
 package controller
 
-import (
-	"net/http"
-	"video_course/service"
-)
-
 type Test struct {
 	BaseController
 }
 
-// UserAdd godoc
-// @Summary 会员用户添加
-// @tags Test
-// @Description 会员用户添加
-// @Accept  x-www-form-urlencoded
-// @Produce  json
-// @Param name formData string true "姓名"
-// @Success 200 {object} controller.ResponseBase
-// @Router /Test/UserAdd [post]
-func (t *Test) UserAdd() (err error) {
-
-	name := t.postString("name", true)
-
-	err = service.Test{}.UserAdd(name)
-	if err != nil {
-		return
-	}
-
-	t.Ctx().JSON(http.StatusOK, newResponseBase())
-	return
-}
-
-type UserList struct {
-	ResponseBase
-	Rs []interface{}
-	//Rs []*gorm.ShopUserSimpleInfo
-}
-
-// UserListQuery godoc
-// @Summary 会员用户查询
-// @tags Test
-// @Description 会员用户查询
-// @Accept  x-www-form-urlencoded
-// @Produce  json
-// @Success 200 {object} controller.UserList
-// @Router /Test/UserListQuery [post]
-func (t *Test) UserListQuery() (err error) {
-
-	rs, err := service.Test{}.UserListQuery()
-	if err != nil {
-		return
-	}
-	rp := UserList{
-		newResponseBase(),
-		rs,
-	}
-	t.Ctx().JSON(http.StatusOK, rp)
-	return
-}
+//
+//// UserAdd godoc
+//// @Summary 会员用户添加
+//// @tags Test
+//// @Description 会员用户添加
+//// @Accept  x-www-form-urlencoded
+//// @Produce  json
+//// @Param name formData string true "姓名"
+//// @Success 200 {object} controller.ResponseBase
+//// @Router /Test/UserAdd [post]
+//func (t *Test) UserAdd() (err error) {
+//
+//	name := t.postString("name", true)
+//
+//	err = service.Test{}.UserAdd(name)
+//	if err != nil {
+//		return
+//	}
+//
+//	t.Ctx().JSON(http.StatusOK, newResponseBase())
+//	return
+//}
+//
+//type UserList struct {
+//	ResponseBase
+//	Rs []interface{}
+//	//Rs []*gorm.ShopUserSimpleInfo
+//}
+//
+//// UserListQuery godoc
+//// @Summary 会员用户查询
+//// @tags Test
+//// @Description 会员用户查询
+//// @Accept  x-www-form-urlencoded
+//// @Produce  json
+//// @Success 200 {object} controller.UserList
+//// @Router /Test/UserListQuery [post]
+//func (t *Test) UserListQuery() (err error) {
+//
+//	rs, err := service.Test{}.UserListQuery()
+//	if err != nil {
+//		return
+//	}
+//	rp := UserList{
+//		newResponseBase(),
+//		rs,
+//	}
+//	t.Ctx().JSON(http.StatusOK, rp)
+//	return
+//}

+ 36 - 2
controller/user.go

@@ -22,9 +22,9 @@ type UserOneResponse struct {
 }
 
 // UserSelfQuery godoc
-// @Summary 会员信息查询
+// @Summary 会员自身信息查询
 // @tags User
-// @Description 会员信息查询
+// @Description 会员自身信息查询
 // @Accept  x-www-form-urlencoded
 // @Produce  json
 // @Param token formData string true "Token"
@@ -45,3 +45,37 @@ func (u *User) UserSelfQuery() (err error) {
 
 	return
 }
+
+type DuAndUserRs struct {
+	ResponseBase
+	InClass  int
+	DuInfo   *model.DuInfo
+	UserInfo *model.UserBodyInfo
+}
+
+// GetDuInfoAndUserInfoByUserMd5 godoc
+// @Summary 查询用户是否正在上课接口
+// @tags User
+// @Description 查询用户当前显示单元和对应身体信息
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Success 200 {object} controller.ResponseBase
+// @Router /User/GetDuInfoAndUserInfoByUserMd5 [post]
+func (u *User) GetDuInfoAndUserInfoByUserMd5() (err error) {
+	token := u.Ctx().PostForm("token")
+
+	inClass, duInfo, userInfo, err := service.User{}.GetDuInfoAndUserInfoByUserMd5(token)
+	if err != nil {
+		return
+	}
+	r := DuAndUserRs{
+		newResponseBase(),
+		inClass,
+		duInfo,
+		userInfo,
+	}
+	u.Ctx().JSON(http.StatusOK, r)
+
+	return
+}

+ 29 - 44
docs/docs.go

@@ -120,20 +120,6 @@ var doc = `{
                         "name": "codeType",
                         "in": "formData",
                         "required": true
-                    },
-                    {
-                        "type": "string",
-                        "description": "图形验证码id",
-                        "name": "picId",
-                        "in": "formData",
-                        "required": true
-                    },
-                    {
-                        "type": "string",
-                        "description": "图形验证码",
-                        "name": "picCode",
-                        "in": "formData",
-                        "required": true
                     }
                 ],
                 "responses": {
@@ -185,9 +171,9 @@ var doc = `{
                 }
             }
         },
-        "/Test/UserAdd": {
+        "/HrSensors/HrSensorsUpdate": {
             "post": {
-                "description": "会员用户添加",
+                "description": "心率带信息查询和更新",
                 "consumes": [
                     "application/x-www-form-urlencoded"
                 ],
@@ -195,14 +181,21 @@ var doc = `{
                     "application/json"
                 ],
                 "tags": [
-                    "Test"
+                    "HrSensors"
                 ],
-                "summary": "会员用户添加",
+                "summary": "心率带信息查询和更新",
                 "parameters": [
                     {
                         "type": "string",
-                        "description": "姓名",
-                        "name": "name",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "心率带编号",
+                        "name": "sn",
                         "in": "formData",
                         "required": true
                     }
@@ -217,9 +210,9 @@ var doc = `{
                 }
             }
         },
-        "/Test/UserListQuery": {
+        "/User/GetDuInfoAndUserInfoByUserMd5": {
             "post": {
-                "description": "会员用户查询",
+                "description": "查询用户当前显示单元和对应身体信息",
                 "consumes": [
                     "application/x-www-form-urlencoded"
                 ],
@@ -227,14 +220,23 @@ var doc = `{
                     "application/json"
                 ],
                 "tags": [
-                    "Test"
+                    "User"
+                ],
+                "summary": "查询用户是否正在上课接口",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    }
                 ],
-                "summary": "会员用户查询",
                 "responses": {
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/controller.UserList"
+                            "$ref": "#/definitions/controller.ResponseBase"
                         }
                     }
                 }
@@ -242,7 +244,7 @@ var doc = `{
         },
         "/User/UserSelfQuery": {
             "post": {
-                "description": "会员信息查询",
+                "description": "会员自身信息查询",
                 "consumes": [
                     "application/x-www-form-urlencoded"
                 ],
@@ -252,7 +254,7 @@ var doc = `{
                 "tags": [
                     "User"
                 ],
-                "summary": "会员信息查询",
+                "summary": "会员自身信息查询",
                 "parameters": [
                     {
                         "type": "string",
@@ -295,23 +297,6 @@ var doc = `{
                     "type": "string"
                 }
             }
-        },
-        "controller.UserList": {
-            "type": "object",
-            "properties": {
-                "code": {
-                    "type": "integer"
-                },
-                "memo": {
-                    "type": "string"
-                },
-                "rs": {
-                    "type": "array",
-                    "items": {
-                        "type": "object"
-                    }
-                }
-            }
         }
     },
     "securityDefinitions": {

+ 29 - 44
docs/swagger.json

@@ -104,20 +104,6 @@
                         "name": "codeType",
                         "in": "formData",
                         "required": true
-                    },
-                    {
-                        "type": "string",
-                        "description": "图形验证码id",
-                        "name": "picId",
-                        "in": "formData",
-                        "required": true
-                    },
-                    {
-                        "type": "string",
-                        "description": "图形验证码",
-                        "name": "picCode",
-                        "in": "formData",
-                        "required": true
                     }
                 ],
                 "responses": {
@@ -169,9 +155,9 @@
                 }
             }
         },
-        "/Test/UserAdd": {
+        "/HrSensors/HrSensorsUpdate": {
             "post": {
-                "description": "会员用户添加",
+                "description": "心率带信息查询和更新",
                 "consumes": [
                     "application/x-www-form-urlencoded"
                 ],
@@ -179,14 +165,21 @@
                     "application/json"
                 ],
                 "tags": [
-                    "Test"
+                    "HrSensors"
                 ],
-                "summary": "会员用户添加",
+                "summary": "心率带信息查询和更新",
                 "parameters": [
                     {
                         "type": "string",
-                        "description": "姓名",
-                        "name": "name",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "心率带编号",
+                        "name": "sn",
                         "in": "formData",
                         "required": true
                     }
@@ -201,9 +194,9 @@
                 }
             }
         },
-        "/Test/UserListQuery": {
+        "/User/GetDuInfoAndUserInfoByUserMd5": {
             "post": {
-                "description": "会员用户查询",
+                "description": "查询用户当前显示单元和对应身体信息",
                 "consumes": [
                     "application/x-www-form-urlencoded"
                 ],
@@ -211,14 +204,23 @@
                     "application/json"
                 ],
                 "tags": [
-                    "Test"
+                    "User"
+                ],
+                "summary": "查询用户是否正在上课接口",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    }
                 ],
-                "summary": "会员用户查询",
                 "responses": {
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/controller.UserList"
+                            "$ref": "#/definitions/controller.ResponseBase"
                         }
                     }
                 }
@@ -226,7 +228,7 @@
         },
         "/User/UserSelfQuery": {
             "post": {
-                "description": "会员信息查询",
+                "description": "会员自身信息查询",
                 "consumes": [
                     "application/x-www-form-urlencoded"
                 ],
@@ -236,7 +238,7 @@
                 "tags": [
                     "User"
                 ],
-                "summary": "会员信息查询",
+                "summary": "会员自身信息查询",
                 "parameters": [
                     {
                         "type": "string",
@@ -279,23 +281,6 @@
                     "type": "string"
                 }
             }
-        },
-        "controller.UserList": {
-            "type": "object",
-            "properties": {
-                "code": {
-                    "type": "integer"
-                },
-                "memo": {
-                    "type": "string"
-                },
-                "rs": {
-                    "type": "array",
-                    "items": {
-                        "type": "object"
-                    }
-                }
-            }
         }
     },
     "securityDefinitions": {

+ 24 - 34
docs/swagger.yaml

@@ -14,17 +14,6 @@ definitions:
       pic:
         type: string
     type: object
-  controller.UserList:
-    properties:
-      code:
-        type: integer
-      memo:
-        type: string
-      rs:
-        items:
-          type: object
-        type: array
-    type: object
 info:
   contact:
     email: support@swagger.io
@@ -95,16 +84,6 @@ paths:
         name: codeType
         required: true
         type: integer
-      - description: 图形验证码id
-        in: formData
-        name: picId
-        required: true
-        type: string
-      - description: 图形验证码
-        in: formData
-        name: picCode
-        required: true
-        type: string
       produces:
       - application/json
       responses:
@@ -141,15 +120,20 @@ paths:
       summary: 手机验证码登录
       tags:
       - Auth
-  /Test/UserAdd:
+  /HrSensors/HrSensorsUpdate:
     post:
       consumes:
       - application/x-www-form-urlencoded
-      description: 会员用户添加
+      description: 心率带信息查询和更新
       parameters:
-      - description: 姓名
+      - description: Token
         in: formData
-        name: name
+        name: token
+        required: true
+        type: string
+      - description: 心率带编号
+        in: formData
+        name: sn
         required: true
         type: string
       produces:
@@ -159,29 +143,35 @@ paths:
           description: OK
           schema:
             $ref: '#/definitions/controller.ResponseBase'
-      summary: 会员用户添加
+      summary: 心率带信息查询和更新
       tags:
-      - Test
-  /Test/UserListQuery:
+      - HrSensors
+  /User/GetDuInfoAndUserInfoByUserMd5:
     post:
       consumes:
       - application/x-www-form-urlencoded
-      description: 会员用户查询
+      description: 查询用户当前显示单元和对应身体信息
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
       produces:
       - application/json
       responses:
         "200":
           description: OK
           schema:
-            $ref: '#/definitions/controller.UserList'
-      summary: 会员用户查询
+            $ref: '#/definitions/controller.ResponseBase'
+      summary: 查询用户是否正在上课接口
       tags:
-      - Test
+      - User
   /User/UserSelfQuery:
     post:
       consumes:
       - application/x-www-form-urlencoded
-      description: 会员信息查询
+      description: 会员自身信息查询
       parameters:
       - description: Token
         in: formData
@@ -195,7 +185,7 @@ paths:
           description: OK
           schema:
             $ref: '#/definitions/controller.ResponseBase'
-      summary: 会员信息查询
+      summary: 会员自身信息查询
       tags:
       - User
 securityDefinitions:

+ 6 - 0
errors/error.go

@@ -34,6 +34,9 @@ const (
 	CodeREDIS               ErrorCode = 10000
 	HrSensorsTimeOutErr     ErrorCode = 30012
 	JsonToMaptErr           ErrorCode = 30013
+	HrSensorsUpdateErr      ErrorCode = 30014
+	GetDuInfoUpdateErr      ErrorCode = 30015
+	SmsCodeRepeatErr        ErrorCode = 30016
 	CodeParam                         = ErrorCode(errors.CodeParam)
 )
 
@@ -45,6 +48,9 @@ var (
 	ErrBirthday         = NewServiceErr(BirthdayErr, "用户生日不得大于当前年份,请重新输入")
 	ErrJsonToMap        = NewServiceErr(JsonToMaptErr, "Json转换Map对象失败")
 	ErrHrSensorsTimeOut = NewServiceErr(HrSensorsTimeOutErr, "心率系统连接超时")
+	ErrHrSensorsUpdate  = NewServiceErr(HrSensorsUpdateErr, "心率系统更新Sn报错")
+	ErrGetDuInfo        = NewServiceErr(GetDuInfoUpdateErr, "心率系统查询用户当前显示单元和对应身体信息报错")
+	ErrSmsCodeRepeat    = NewServiceErr(SmsCodeRepeatErr, "短信验证码不能频繁发送")
 )
 
 func (e ErrorCode) ShowMsg() string {

+ 1 - 1
go.mod

@@ -10,7 +10,7 @@ require (
 	github.com/ZR233/session v1.1.5
 	github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
 	github.com/gin-gonic/gin v1.6.3
-	github.com/go-redis/redis v6.15.9+incompatible // indirect
+	github.com/go-redis/redis v6.15.9+incompatible
 	github.com/go-redis/redis/v7 v7.2.0
 	github.com/hashicorp/consul/api v1.8.1
 	github.com/jackc/pgconn v1.8.0

+ 1 - 0
main.go

@@ -89,6 +89,7 @@ func main() {
 		middleware.Session(),
 	)
 	r.AutoRegisterController("/v1", &controller.Auth{})
+	r.AutoRegisterController("/v1", &controller.HrSensors{})
 	r.AutoRegisterController("/v1", &controller.User{})
 	//debug模式下启用swag文档
 	if global.Project.Debug {

+ 6 - 0
model/duInfo.go

@@ -0,0 +1,6 @@
+package model
+
+type DuInfo struct {
+	DpName string
+	DuId   int
+}

+ 93 - 0
repository/http/heartrate_server.go

@@ -7,6 +7,7 @@ import (
 	"net/http"
 	"net/url"
 	"strings"
+	"video_course/errors"
 	"video_course/global"
 	"video_course/model"
 	"video_course/utils"
@@ -59,3 +60,95 @@ func (h HeartRateServer) VipUserQueryByUserMd5(userMd5 string) (rtnCode int, rtn
 
 	return
 }
+
+//线上心率带更新
+func (h HeartRateServer) HrSensorsUpdate(userMd5 string, sn string) (hrId int, err error) {
+	api := strings.Join([]string{global.Project.HeartrateUrl, "v1/OutService/HrSensorsUpdate"}, "/")
+
+	resp, err := http.PostForm(api, url.Values{
+		"userMd5": {userMd5},
+		"sn":      {sn},
+	})
+	if err != nil {
+		panic(err)
+	}
+
+	defer resp.Body.Close()
+	body, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		err = fmt.Errorf("response:[%s], err:\n%w", string(body), err)
+		panic(err)
+	}
+
+	var responseBase struct {
+		Code int
+		Memo string
+		HrId int
+	}
+	err = json.Unmarshal(body, &responseBase)
+	if err != nil {
+		err = fmt.Errorf("response:[%s], err:\n%w", string(body), err)
+		panic(err)
+	}
+	rtnCode := responseBase.Code
+	hrId = responseBase.HrId
+	if rtnCode != 0 {
+		err = errors.ErrHrSensorsUpdate
+	}
+
+	return
+}
+
+//查询用户是否正在上课接口
+func (h HeartRateServer) GetDuInfoAndUserInfoByUserMd5(userMd5 string) (inClass int, duInfo *model.DuInfo, userInfo *model.UserBodyInfo, err error) {
+	api := strings.Join([]string{global.Project.HeartrateUrl, "v1/OutService/GetDuInfoAndUserInfoByUserMd5"}, "/")
+
+	resp, err := http.PostForm(api, url.Values{
+		"userMd5": {userMd5},
+	})
+	if err != nil {
+		panic(err)
+	}
+
+	defer resp.Body.Close()
+	body, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		err = fmt.Errorf("response:[%s], err:\n%w", string(body), err)
+		panic(err)
+	}
+
+	var responseBase struct {
+		Code     int
+		Memo     string
+		InClass  int
+		DuInfo   map[string]interface{}
+		UserInfo map[string]interface{}
+	}
+	err = json.Unmarshal(body, &responseBase)
+	if err != nil {
+		err = fmt.Errorf("response:[%s], err:\n%w", string(body), err)
+		panic(err)
+	}
+	rtnCode := responseBase.Code
+	if rtnCode == 0 {
+		inClass = responseBase.InClass
+		duInfo = &model.DuInfo{
+			DpName: utils.MapToString(responseBase.DuInfo, "DpName"),
+			DuId:   utils.MapToInt32(responseBase.DuInfo, "DuId"),
+		}
+		userInfo = &model.UserBodyInfo{
+			UserName: utils.MapToString(responseBase.UserInfo, "Name"),
+			Birthday: utils.MapToTime(responseBase.UserInfo, "Birthday"),
+			Height:   utils.MapToInt32(responseBase.UserInfo, "Height"),
+			Weight:   utils.MapToInt32(responseBase.UserInfo, "Weight"),
+			Sex:      utils.MapToInt32(responseBase.UserInfo, "Sex"),
+			StaticHr: utils.MapToInt32(responseBase.UserInfo, "StaticHr"),
+			UserMd5:  utils.MapToString(responseBase.UserInfo, "UserMd5"),
+			Head:     utils.MapToString(responseBase.UserInfo, "Head"),
+		}
+	} else {
+		err = errors.ErrGetDuInfo
+	}
+
+	return
+}

+ 9 - 7
service/auth.go

@@ -78,13 +78,11 @@ func (Auth) GenVerifyPic(config *base64Captcha.DriverString) (id string, pic str
 }
 
 // 手机号发送短信验证码
-func (a Auth) GenVFCode(codeTypeInt int, phone string, ip string,
-	picId string,
-	picCode string) (err error) {
+func (a Auth) GenVFCode(codeType int, phone string, ip string) (err error) {
 	//图形验证码验证
-	if !store.Verify(picId, picCode, true) {
-		return errors.ErrPicVerifyCode
-	}
+	//if !store.Verify(picId, picCode, true) {
+	//	return errors.ErrPicVerifyCode
+	//}
 	//手机号验证
 	userMd5 := h.LoalloutServer{}.CheckPhone(phone)
 	if userMd5 == "" {
@@ -96,8 +94,12 @@ func (a Auth) GenVFCode(codeTypeInt int, phone string, ip string,
 	//smsCode :=  strconv.Itoa(smsInt)
 	smsCode := "12345678"
 
-	//存储短信验证码
+	//存储短信验证码前判断redis中是否有该手机号对应验证码,有说明还没失效
 	redisdb := rdb.GetRedis()
+	tmpCode, _ := redisdb.Get(global.ProjectName + ":" + global.AppName + ":" + "smsCode:" + phone).Result()
+	if tmpCode != "" {
+		err = errors.ErrSmsCodeRepeat
+	}
 	redisdb.Set(global.ProjectName+":"+global.AppName+":"+"smsCode:"+phone, []byte(smsCode), 3*time.Minute)
 	//发送短信
 	fmt.Println(smsCode)

+ 27 - 0
service/hrsensors.go

@@ -0,0 +1,27 @@
+package service
+
+import (
+	"video_course/lib/session"
+	h "video_course/repository/http"
+)
+
+type HrSensors struct {
+	base
+}
+
+//心率带更新(
+func (hr HrSensors) HrSensorsUpdate(
+	token string, sn string) (hrId int, err error) {
+	sm := session.GetSessionManager()
+	sess, err_ := sm.FindByToken(token)
+	if err_ != nil {
+		err = err_
+		return
+	}
+	userMd5 := sess.UserId
+
+	//首先查询心率系统,如果查询失败查询小飞龙系统
+	hrId, err = h.HeartRateServer{}.HrSensorsUpdate(userMd5, sn)
+
+	return
+}

+ 17 - 0
service/user.go

@@ -39,3 +39,20 @@ func (u User) UserSelfQuery(
 
 	return
 }
+
+//查询用户是否正在上课接口
+func (u User) GetDuInfoAndUserInfoByUserMd5(
+	token string) (inClass int, duInfo *model.DuInfo, userBodyInfo *model.UserBodyInfo, err error) {
+	sm := session.GetSessionManager()
+	sess, err_ := sm.FindByToken(token)
+	if err_ != nil {
+		err = err_
+		return
+	}
+	userMd5 := sess.UserId
+
+	//查询心率系统
+	inClass, duInfo, userBodyInfo, err = h.HeartRateServer{}.GetDuInfoAndUserInfoByUserMd5(userMd5)
+
+	return
+}