Explorar el Código

HrSensorsUpdate

lhs hace 4 años
padre
commit
59c2e8b61a
Se han modificado 8 ficheros con 144 adiciones y 135 borrados
  1. 3 5
      controller/auth.go
  2. 36 2
      controller/user.go
  3. 29 44
      docs/docs.go
  4. 29 44
      docs/swagger.json
  5. 24 34
      docs/swagger.yaml
  6. 2 0
      repository/http/heartrate_server.go
  7. 4 6
      service/auth.go
  8. 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
 	}

+ 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:

+ 2 - 0
repository/http/heartrate_server.go

@@ -120,6 +120,7 @@ func (h HeartRateServer) GetDuInfoAndUserInfoByUserMd5(userMd5 string) (inClass
 	var responseBase struct {
 		Code     int
 		Memo     string
+		InClass  int
 		DuInfo   map[string]interface{}
 		UserInfo map[string]interface{}
 	}
@@ -130,6 +131,7 @@ func (h HeartRateServer) GetDuInfoAndUserInfoByUserMd5(userMd5 string) (inClass
 	}
 	rtnCode := responseBase.Code
 	if rtnCode == 0 {
+		inClass = responseBase.InClass
 		duInfo = &model.DuInfo{
 			DpName: utils.MapToString(responseBase.DuInfo, "DpName"),
 			DuId:   utils.MapToInt32(responseBase.DuInfo, "DuId"),

+ 4 - 6
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 == "" {

+ 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
+}