Rick.Lan 2 months ago
commit
9ae087d9c2

+ 2 - 0
.gitignore View File

1
+sws_xcx.exe
2
+sws_xcx.exe~

+ 42 - 0
conf/app.conf View File

1
+appname = sws_xcx
2
+httpport = 9539
3
+runmode = test
4
+autorender = false
5
+copyrequestbody = true
6
+EnableDocs = true
7
+
8
+
9
+enablexsrf = false
10
+xsrfkey = 61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o
11
+xsrfexpire = 3600
12
+
13
+qiniu_accesskey = -l_Pcc1YJs0gh3w0YwN2uoaZO_5fY5J9SIYnSjg0
14
+qiniu_secretkey = DmZSp_Bmnp-9aUB7xUvoyViZpzmx1Rs2RL69GvlW
15
+qiniu_domain = https://images.shengws.com/
16
+qiniu_bucket = syhclub-storage
17
+
18
+appid = "wxcdf53b48b7df107e"
19
+key="Yz1HgsFX3yJvWPJSEdwJDA=="
20
+appsecret="94e944a69ad1d43ac447f5a8769ab801"
21
+
22
+[test]
23
+redishost = kuyi6666.redis.rds.aliyuncs.com
24
+redisport = 6379
25
+redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP
26
+redisdb = 4
27
+
28
+readmysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
29
+readmysqlport = 3306
30
+readmysqluser = root
31
+readmysqlpass = 1Q2W3e4r!@#$
32
+readmysqlname = sws_xcx
33
+
34
+writemysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
35
+writemysqlport = 3306
36
+writemysqluser = root
37
+writemysqlpass = 1Q2W3e4r!@#$
38
+writemysqlname = sws_xcx
39
+
40
+
41
+#appid = "wx25576346fbca6905"
42
+#appsecret="f6d53ccb4a529dc4d3bd543a7634b6bd"

+ 164 - 0
controllers/api_base_controller.go View File

1
+package controllers
2
+
3
+import (
4
+	"encoding/json"
5
+	"fmt"
6
+	"strings"
7
+	"sws_xcx/enums"
8
+	"sws_xcx/models"
9
+	"sws_xcx/service"
10
+	"sws_xcx/utils"
11
+
12
+	"net/http"
13
+	"time"
14
+
15
+	"github.com/astaxie/beego"
16
+	"github.com/dgrijalva/jwt-go"
17
+	"github.com/google/uuid"
18
+)
19
+
20
+func ApiControllersRegisterRouters() {
21
+
22
+	//接收MQTT消息
23
+	beego.Router("/xcx/api/device/emqmsg", &MessageApiControllor{}, "Post:PutEmqxMessage")
24
+
25
+	beego.Router("/xcx/api/user/login", &LoginApiController{}, "Post:WxXcxLogin")
26
+
27
+	beego.Router("/xcx/api/user/getphonenumber", &LoginApiController{}, "Post:GetPhoneNumber")
28
+}
29
+
30
+type BaseApiController struct {
31
+	beego.Controller
32
+}
33
+
34
+func (c *BaseApiController) Prepare() {
35
+}
36
+
37
+type BaseApiAuthController struct {
38
+	BaseApiController
39
+}
40
+
41
+func (c *BaseApiAuthController) Prepare() {
42
+	c.BaseApiController.Prepare()
43
+	// JWT Token通常放在请求头中,例如Authorization: Bearer <token>
44
+	authHeader := c.Ctx.Input.Header("Authorization")
45
+	if authHeader == "" {
46
+		c.ServeFailJsonSendAndStop(http.StatusUnauthorized, "缺少认证信息")
47
+		return
48
+	}
49
+	tokenString := authHeader
50
+	if strings.Contains(authHeader, "Bearer") {
51
+		tokenString = authHeader[len("Bearer "):]
52
+	}
53
+
54
+	token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
55
+		if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
56
+			return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
57
+		}
58
+		//从配置文件中获取secret
59
+		secret := beego.AppConfig.String("xsrfkey")
60
+		return []byte(secret), nil
61
+	})
62
+
63
+	if err != nil || !token.Valid {
64
+		utils.ErrorLog("Token验证失败: %v", err)
65
+		c.ServeFailJsonSendAndStop(http.StatusUnauthorized, "无效的Token")
66
+		return
67
+	}
68
+
69
+	// 假设JWT中包含了用户ID
70
+	claims, ok := token.Claims.(jwt.MapClaims)
71
+	if !ok {
72
+		c.ServeFailJsonSendAndStop(http.StatusUnauthorized, "无法解析Token中的信息")
73
+		return
74
+	}
75
+
76
+	userId, ok := claims["sessionkey"].(string)
77
+	if !ok {
78
+		c.ServeFailJsonSendAndStop(http.StatusUnauthorized, "无法获取会话ID")
79
+		return
80
+	}
81
+
82
+	c.SetSession("userId", userId)
83
+}
84
+
85
+type CustomClaims struct {
86
+	UserID string `json:"sessionkey"`
87
+	jwt.StandardClaims
88
+}
89
+
90
+// 输出数据格式化
91
+/*
92
+	success json:
93
+	{
94
+		"state": 1,
95
+		"code": 0,
96
+		"data": json,
97
+	}
98
+
99
+	fail json:
100
+	{
101
+		"state": 0,
102
+		"code": int,
103
+		"msg": string,
104
+	}
105
+*/
106
+func (c *BaseApiController) ServeSuccessJSON(data interface{}) {
107
+	c.Data["json"] = enums.MakeSuccessResponseJSON(data)
108
+	c.ServeJSON()
109
+}
110
+
111
+func (c *BaseApiController) ServeFailJSONWithSGJErrorCode(code int) {
112
+	c.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(code)
113
+	c.ServeJSON()
114
+}
115
+
116
+func (c *BaseApiController) ServeFailJSONWithSGJError(err *enums.SGJError) {
117
+	c.Data["json"] = enums.MakeFailResponseJSONWithSGJError(err)
118
+	c.ServeJSON()
119
+}
120
+
121
+func (c *BaseApiController) ServeFailJsonSend(code int, msg string) {
122
+	c.Data["json"] = enums.MakeFailResponseJSON(msg, code)
123
+	c.ServeJSON()
124
+}
125
+
126
+func (c *BaseApiController) ServeDynamicFailJsonSend(msg string) {
127
+	c.Data["json"] = enums.MakeDynamicFailResponseJSON(msg)
128
+	c.ServeJSON()
129
+}
130
+func (c *BaseApiController) ServeFailJsonSendAndStop(code int, msg string) {
131
+	c.Ctx.Output.SetStatus(code)
132
+	c.ServeFailJsonSend(code, msg)
133
+	c.StopRun()
134
+}
135
+
136
+func (c *BaseApiController) Login(u models.XcxUser) (string, error) {
137
+
138
+	key := uuid.New().String()
139
+
140
+	expire, _ := beego.AppConfig.Int("xsrfexpire")
141
+
142
+	if expire == 0 {
143
+		expire = 7200
144
+	}
145
+
146
+	uJson, _ := json.Marshal(u)
147
+
148
+	service.RedisClient().Set(key, uJson, time.Second*time.Duration(expire))
149
+
150
+	// 创建一个我们自己的声明
151
+	claims := CustomClaims{
152
+		UserID: key,
153
+		StandardClaims: jwt.StandardClaims{
154
+			ExpiresAt: time.Now().Add(time.Second * time.Duration(expire)).Unix(), // Token有效期(默认为7200秒)
155
+			Issuer:    "sws_xcx",                                                  // 签发者
156
+		},
157
+	}
158
+
159
+	// 使用指定的签名方法创建签名
160
+	token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
161
+
162
+	// 使用密钥签名并获得完整的编码后的字符串形式的Token
163
+	return token.SignedString([]byte(beego.AppConfig.String("xsrfkey")))
164
+}

+ 5 - 0
controllers/device_api_controllor.go View File

1
+package controllers
2
+
3
+type DeviceApiController struct {
4
+	BaseApiController
5
+}

+ 77 - 0
controllers/login_api_controllor.go View File

1
+package controllers
2
+
3
+import (
4
+	"encoding/json"
5
+	"sws_xcx/enums"
6
+	"sws_xcx/models"
7
+	"sws_xcx/service"
8
+
9
+	"github.com/astaxie/beego"
10
+	"github.com/medivhzhan/weapp/v3/auth"
11
+)
12
+
13
+type LoginApiController struct {
14
+	BaseApiController
15
+}
16
+
17
+// @Title WxXcxLogin
18
+// @Description 微信小程序登录
19
+// @Param	body	body 	models.WxXcxLoginReq	true  "小程序登录请求参数"
20
+// @Success	200	{object}	models.WxXcxLoginResp
21
+// @Failure 500 error
22
+// @router /login [post]
23
+func (c *LoginApiController) WxXcxLogin() {
24
+
25
+	dataBody := models.WxXcxLoginReq{}
26
+	if err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody); err != nil || dataBody.Code == "" {
27
+
28
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
29
+	}
30
+
31
+	wxcli := service.GetWxSdk().NewAuth()
32
+
33
+	resp, err := wxcli.Code2Session(&auth.Code2SessionRequest{JsCode: dataBody.Code, GrantType: "authorization_code",
34
+		Appid:  beego.AppConfig.String("appid"),
35
+		Secret: beego.AppConfig.String("appsecret")})
36
+
37
+	if err != nil {
38
+		c.ServeDynamicFailJsonSend(err.Error())
39
+		return
40
+	}
41
+	if resp.ErrCode != 0 {
42
+		c.ServeDynamicFailJsonSend(resp.ErrMSG)
43
+		return
44
+	}
45
+
46
+	s := service.NewXcxUserService()
47
+	u, err := s.GetOrCreate(resp.Openid, resp.Unionid)
48
+	if err != nil {
49
+		c.ServeDynamicFailJsonSend(err.Error())
50
+		return
51
+	}
52
+	u.SessionKey = resp.SessionKey
53
+	t, err := c.BaseApiController.Login(*u)
54
+	if err != nil {
55
+		c.ServeDynamicFailJsonSend(err.Error())
56
+		return
57
+	}
58
+	c.ServeSuccessJSON(models.WxXcxLoginResp{OpenId: u.OpenId, Token: t})
59
+
60
+}
61
+
62
+// @Title GetPhoneNumber
63
+// @Description 获取小程序绑定的手机号码
64
+// @Param	body	body 	models.WxXcxLoginReq	true  "小程序登录请求参数"
65
+// @Success 200	success
66
+// @Failure 500 error
67
+// @router /getphonenumber [post]
68
+func (c *LoginApiController) GetPhoneNumber() {
69
+
70
+	dataBody := models.WxXcxLoginReq{}
71
+	if err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody); err != nil || dataBody.Code == "" {
72
+
73
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
74
+	}
75
+	c.ServeSuccessJSON(new(interface{}))
76
+
77
+}

+ 15 - 0
controllers/message_api_controllor.go View File

1
+package controllers
2
+
3
+import (
4
+	"sws_xcx/utils"
5
+)
6
+
7
+type MessageApiControllor struct {
8
+	BaseApiController
9
+}
10
+
11
+func (c *MessageApiControllor) PutEmqxMessage() {
12
+
13
+	utils.InfoLog("Revice EMQX message: %s", c.Ctx.Input.RequestBody)
14
+	c.ServeSuccessJSON(map[string]interface{}{})
15
+}

+ 514 - 0
enums/error_code.go View File

1
+package enums
2
+
3
+import "sws_xcx/utils"
4
+
5
+const ( // ErrorCode
6
+	// 登录注册错误 6000+
7
+	ErrorCodeLoginTimeout                   = 6001
8
+	ErrorCodeNotLogin                       = 6002
9
+	ErrorCodePermissionDenied               = 6003
10
+	ErrorCodeMobileRegistered               = 6004
11
+	ErrorCodePasswordEmpty                  = 6005
12
+	ErrorCodeVerificationCodeWrong          = 6006
13
+	ErrorCodeRegisterFail                   = 6007
14
+	ErrorCodeInvalidToken                   = 6008
15
+	ErrorCodeAccountOrPasswordWrong         = 6009
16
+	ErrorCodeMissingOrg                     = 6010
17
+	ErrorCodeMissingOrgApp                  = 6011
18
+	ErrorCodeAccountOrVerCodeWrong          = 6012
19
+	ErrorCodeMobileNotExit                  = 6013
20
+	ErrorCodeUserNotExist                   = 6014
21
+	ErrorCodeUserWasForbidden               = 6015
22
+	ErrorCodeNeverCreateTypeApp             = 6016
23
+	ErrorCodeContactSuperAdminCreateTypeApp = 6017
24
+
25
+	ErrorCodeRepeatCreateOrg = 901
26
+
27
+	// 数据验证错误 7000+
28
+	ErrorCodeMobileFormat     = 7001
29
+	ErrorCodeTelphoneFormat   = 7002
30
+	ErrorCodeParamWrong       = 7003
31
+	ErrorCodeParamFormatWrong = 7004
32
+
33
+	// 数据库操作错误 8000+
34
+	ErrorCodeDBCreate         = 8001
35
+	ErrorCodeDBUpdate         = 8002
36
+	ErrorCodeDBDelete         = 8003
37
+	ErrorCodeDBSelectNoResult = 8004
38
+	ErrorCodeDataException    = 8005
39
+
40
+	// 业务逻辑操作错误 9000+
41
+	ErrorCodeRoleNotExist           = 9001
42
+	ErrorCodeAdminUserNotExist      = 9002
43
+	ErrorCodeMobileDidUsedInApp     = 9003
44
+	ErrorCodeMissingUserName        = 9004
45
+	ErrorCodeOldPasswordWrong       = 9005
46
+	ErrorCodeCannotRemoveRole       = 9006
47
+	ErrorCodeRoleMobileIsSuperAdmin = 9007
48
+
49
+	ErrorCodeGetQiniuUpToken                = 1001
50
+	ErrorCodeCreatePatient                  = 1002
51
+	ErrorCodeDialysisNoExist                = 1003
52
+	ErrorCodeIdCardNoExist                  = 1004
53
+	ErrorCodePatientNoExist                 = 1005
54
+	ErrorCodeUpdatePatient                  = 1006
55
+	ErrorCodeDialysisSolutionExist          = 1007
56
+	ErrorCodeDialysisSolutionCreate         = 1008
57
+	ErrorCodeDialysisSolutionUpdate         = 1009
58
+	ErrorCodeDialysisSolutionNotExist       = 1010
59
+	ErrorCodeParentDialysisSolutionNotExist = 1011
60
+	ErrorCodeAlReadyHadChildSolution        = 1012
61
+	ErrorCodeCanntCreateChildChildSolution  = 1013
62
+	ErrorCodeDialysisSolutionUsed           = 1014
63
+	ErrorCodeCreateDryWeightFail            = 1015
64
+	ErrorCodeCreateDoctorAdviceFail         = 1016
65
+	ErrorCodeDoctorAdviceNotExist           = 1017
66
+	ErrorCodeUpdateDoctorAdviceFail         = 1018
67
+	ErrorCodeLongTimeAdviceNotCanntEdit     = 1019
68
+	ErrorCodeAdviceStoped                   = 1020
69
+	ErrorCodeParentAdviceNotExist           = 1021
70
+	ErrorCodeStopAdviceFail                 = 1022
71
+	ErrorCodeDeleteAdviceFail               = 1023
72
+	ErrorCodeDialysisSolutionDelete         = 1024
73
+	ErrorCodeDeviceNumberNotTheZone         = 1025
74
+	ErrorCodeCreateScheduleFail             = 1026
75
+	ErrorCodeCantSetScheduleAgainOneDay     = 1027
76
+	ErrorCodeCantSetScheduleBeforeNow       = 1028
77
+	ErrorCodeScheduleNotExist               = 1029
78
+	ErrorCodeDeleteScheduleFail             = 1030
79
+	ErrorCodeChangeScheduleFail             = 1031
80
+	ErrorCodePatientPhoneUsed               = 1032
81
+	ErrorCodeAdviceExced                    = 1033
82
+	ErrorCodeAdviceChecked                  = 1034
83
+	ErrorCodePointScheduleExist             = 1035
84
+	ErrorCodeExceAndCheckNotOneUser         = 1036
85
+	ErrorCodeCanotEditOtherAdvice           = 1037
86
+	ErrorCodeEditLapsetoFail                = 1038
87
+	ErrorCodeAdviceCheckBeforeExce          = 1039
88
+	ErrorCodeAdviceExceBeforeStart          = 1040
89
+	ErrorCodeDelScheduleFailByDialysis      = 1041
90
+	ErrorCodeNotSelectLapsetoType           = 1042
91
+	ErrorCodeNotSelectLapsetoTime           = 1043
92
+	ErrorCodeEquitNoExist                   = 1045
93
+
94
+	ErrorCodeInspectionDateExit    = 1201
95
+	ErrorCodeInspectionAddFail     = 1202
96
+	ErrorCodeInspectionEditFail    = 1204
97
+	ErrorCodeInspectionDateNotExit = 1203
98
+	ErrorCodeInspectionDeleteFail  = 1205
99
+
100
+	ErrorCodeMonitorCreate                  = 1128
101
+	ErrorCodeMonitorNotExist                = 1129
102
+	ErrorCodeMonitorUpdate                  = 1130
103
+	ErrorDialysisOrderNoStart               = 1132
104
+	ErrorDialysisOrderNoEND                 = 1133
105
+	ErrorDialysisOrderRepeatStart           = 1134
106
+	ErrorDialysisOrderRepeatBed             = 1136
107
+	ErrorCodeDialysisPermissionDeniedModify = 1135
108
+
109
+	ErrorCodeNotSubscibe       = 4003
110
+	ErrorCodeServeNotExist     = 4004
111
+	ErrorCodeInvoiceExist      = 4005
112
+	ErrorCodeApplyInvoiceFail  = 4006
113
+	ErrorCodeHetongHad         = 4007
114
+	ErrorCodeCreateHetongFail  = 4008
115
+	ErrorCodePatientReachLimit = 4009
116
+
117
+	ErrorCodeDeviceZoneNotExist                      = 9021
118
+	ErrorCodeDeviceZoneNameRepeat                    = 9022
119
+	ErrorCodeDeviceGroupNotExist                     = 9023
120
+	ErrorCodeDeviceGroupNameRepeat                   = 9024
121
+	ErrorCodeDeviceNumberNotExist                    = 9025
122
+	ErrorCodeDeviceNumberRepeat                      = 9026
123
+	ErrorCodeDeviceNotExist                          = 9027
124
+	ErrorCodeDeviceZoneCannotDisable                 = 9028
125
+	ErrorCodeDeviceNumberCannotDisableCuzDevice      = 9029
126
+	ErrorCodeDeviceNumberCannotDisableCuzSchedule    = 9030
127
+	ErrorCodeDeviceNumberCannotDisableCuzSchTemplate = 9031
128
+
129
+	ErrorCommitFail = 90000
130
+
131
+	ErrorCodeCreateStockInFail = 20001
132
+
133
+	ErrorCodeCreateReturnFail = 50001
134
+
135
+	ErrorCodeCreateStockOutFail = 50002
136
+
137
+	ErrorCodeCreateCancelStockFail = 50003
138
+
139
+	ErrorCodeScheduleTemplateNotExist = 10001
140
+
141
+	ErrorCodeSystemError  = 6666
142
+	ErrorCodeProductError = 6667
143
+	ErrorCodeFieldExist   = 100001
144
+	ErrorCodeCreateConfig = 100002
145
+	ErrorCodeUpdateConfig = 100003
146
+
147
+	ErrorCodeDoubleCheckWrong     = 200003
148
+	ErrorCodeDoubleCheckUserWrong = 200004
149
+	ErrorCodeGoodNoStockInError   = 200005
150
+	ErrorCodeCancelStockFail      = 200006
151
+	ErrorCodeDeleteGoodTypeFail   = 200007
152
+	ErrorCodeDeleteGoodInfoFail   = 200008
153
+	ErrorCodeDeleteFail           = 200009
154
+
155
+	ErrorCodeKeyFail                 = 200010
156
+	ErrorCodeDeleteStockInRecordFail = 200011
157
+	ErrorCodeNameWrong               = 200012
158
+
159
+	ErrorCodeParamEmptyWrong       = 200013
160
+	ErrorCodeParamAdviceEmptyWrong = 200014
161
+
162
+	ErrorCodeParamTemplateNOEXISTWrong = 200015
163
+
164
+	ErrorCodeDeleteDealerWrong       = 200016
165
+	ErrorCodeDeleteManufacturerWrong = 200017
166
+	ErrorCodeGoodTypeNameExistError  = 200018
167
+	ErrorCodeGoodInfoNameExistError  = 200019
168
+
169
+	ErrorCodePrescriptionPermissionDeniedModify = 200020
170
+
171
+	ErrorCodeAdvicePermissionDeniedModify = 200021
172
+	ErrorCodePrescriptionException        = 200022
173
+
174
+	ErrorCodeNotDocking = 200023
175
+
176
+	ErrorCodeAdviceTypeWrong = 200024
177
+
178
+	ErrorCodeCreateAdvice = 200025
179
+
180
+	ErrorCodePatientDialysisOrder = 20026
181
+	ErrorSchedualcRepeatBed       = 20027
182
+
183
+	ErrorCodeChangeMode         = 20028
184
+	ErrorCodeChangeDeviceNumber = 20029
185
+
186
+	ErrorCodeHisIdExist = 20030
187
+
188
+	ErrorCodePreExist   = 20031
189
+	ErrorCodeOrgNoExist = 20032
190
+
191
+	ErrorCodeRegisterExist = 20033
192
+
193
+	ErrorCodeRepeatCreateStaffException = 20034
194
+
195
+	ErrorCodeForbidden       = 20035
196
+	ErrorCodeRoleNameIsExist = 20036
197
+
198
+	ErrorCodeRole = 20037
199
+
200
+	ErrorCodeAdminUserIsExit = 20038
201
+
202
+	ErrorCodePhone = 20039
203
+
204
+	ErrorCodeLogOut = 20049
205
+
206
+	ErrorCodeExportError = 20050
207
+
208
+	ErrorCodeOrgNoPatient = 20051
209
+
210
+	ErrorCodeDoctorAdviceEmpty = 20052
211
+
212
+	ErrorCodeOpenStocktWrong = 20053
213
+
214
+	ErrorCodeDrugRepeatDataException = 20054
215
+
216
+	ErrorCodeIDCartNo = 20055
217
+
218
+	ErrorCodeRegisterOneException = 20066
219
+
220
+	ErrorCodeRegisterTwoException = 20067
221
+
222
+	ErrorCodeCreateOrderException = 20068
223
+
224
+	ErrorCodeCalOrderException = 20069
225
+
226
+	ErrorCodeHisRegisterException = 300001
227
+
228
+	ErrorCodeNoBloodPatientException = 300002
229
+
230
+	ErrorCodeOrderParamWrong = 300003
231
+
232
+	ErrorCodeHisPatientParamWrong = 300004
233
+
234
+	ErrorCodeOutOfStockParamWrong = 300300
235
+
236
+	ErrorCodeOrderParamWrongTwo = 300500
237
+)
238
+
239
+var ErrCodeMsgs = map[int]string{
240
+	// 登录注册错误
241
+	ErrorCodeLoginTimeout:                   "登录超时",
242
+	ErrorCodeNotLogin:                       "未登录",
243
+	ErrorCodePermissionDenied:               "权限不足",
244
+	ErrorCodeMobileRegistered:               "手机号已被注册",
245
+	ErrorCodePasswordEmpty:                  "密码为空",
246
+	ErrorCodeVerificationCodeWrong:          "验证码错误",
247
+	ErrorCodeRegisterFail:                   "注册失败",
248
+	ErrorCodeInvalidToken:                   "令牌无效",
249
+	ErrorCodeAccountOrPasswordWrong:         "账号或密码错误",
250
+	ErrorCodeMissingOrg:                     "未创建机构",
251
+	ErrorCodeMissingOrgApp:                  "未创建任何应用",
252
+	ErrorCodeAccountOrVerCodeWrong:          "账号或验证码错误",
253
+	ErrorCodeMobileNotExit:                  "手机号不存在",
254
+	ErrorCodeUserNotExist:                   "用户不存在",
255
+	ErrorCodeUserWasForbidden:               "该用户被禁用",
256
+	ErrorCodeNeverCreateTypeApp:             "未创建此种应用",
257
+	ErrorCodeContactSuperAdminCreateTypeApp: "请联系超级管理员开通此种应用",
258
+
259
+	// 数据验证错误
260
+	ErrorCodeMobileFormat:     "手机号格式错误",
261
+	ErrorCodeTelphoneFormat:   "电话格式错误",
262
+	ErrorCodeParamWrong:       "参数错误",
263
+	ErrorCodeParamFormatWrong: "参数格式错误",
264
+
265
+	// 数据库操作错误
266
+	ErrorCodeDBCreate:         "数据库创建出错",
267
+	ErrorCodeDBUpdate:         "数据库更新出错",
268
+	ErrorCodeDBDelete:         "数据库删除出错",
269
+	ErrorCodeDBSelectNoResult: "查询无结果",
270
+	ErrorCodeDataException:    "数据异常",
271
+
272
+	// 业务逻辑操作错误
273
+	ErrorCodeRoleNotExist:           "角色不存在",
274
+	ErrorCodeAdminUserNotExist:      "管理员不存在",
275
+	ErrorCodeMobileDidUsedInApp:     "该手机号已在该应用中被注册为管理员",
276
+	ErrorCodeMissingUserName:        "缺少用户名",
277
+	ErrorCodeOldPasswordWrong:       "原密码不正确",
278
+	ErrorCodeCannotRemoveRole:       "该角色下存在用户,不能删除该角色",
279
+	ErrorCodeRoleMobileIsSuperAdmin: "该手机号已注册为超级管理员",
280
+
281
+	ErrorCodeGetQiniuUpToken: "获取七牛uptoken失败",
282
+	ErrorCodeCreatePatient:   "创建患者失败",
283
+	ErrorCodeDialysisNoExist: "患者透析号重复!",
284
+	ErrorCodeIdCardNoExist:   "身份证号重复!",
285
+	ErrorCodePatientNoExist:  "患者信息不存在!",
286
+	ErrorCodeUpdatePatient:   "修改患者信息失败",
287
+
288
+	ErrorCodeDialysisSolutionExist:          "该处方已经存在",
289
+	ErrorCodeDialysisSolutionCreate:         "创建处方失败",
290
+	ErrorCodeDialysisSolutionUpdate:         "修改处方失败",
291
+	ErrorCodeDialysisSolutionNotExist:       "该处方不存在",
292
+	ErrorCodeParentDialysisSolutionNotExist: "上级处方不存在",
293
+	ErrorCodeAlReadyHadChildSolution:        "所选处方已经存在子方案",
294
+	ErrorCodeCanntCreateChildChildSolution:  "子方案不能添加子方案",
295
+	ErrorCodeDialysisSolutionUsed:           "处方已被使用,不能删除",
296
+	ErrorCodeCreateDryWeightFail:            "添加干体重失败",
297
+	ErrorCodeCreateDoctorAdviceFail:         "添加医嘱失败",
298
+	ErrorCodeUpdateDoctorAdviceFail:         "修改医嘱信息失败",
299
+	ErrorCodeDoctorAdviceNotExist:           "医嘱不存在",
300
+	ErrorCodeLongTimeAdviceNotCanntEdit:     "长期医嘱不能修改!",
301
+	ErrorCodeAdviceStoped:                   "所选医嘱已停止",
302
+	ErrorCodeParentAdviceNotExist:           "上级医嘱不存在",
303
+	ErrorCodeDeleteAdviceFail:               "删除医嘱失败",
304
+	ErrorCodeStopAdviceFail:                 "停止医嘱失败",
305
+	ErrorCodeDialysisSolutionDelete:         "删除方案失败",
306
+	ErrorCodeDeviceNumberNotTheZone:         "所选机号不在选择分区中",
307
+	ErrorCodeCreateScheduleFail:             "添加排班失败",
308
+	ErrorCodeCantSetScheduleAgainOneDay:     "同一天不可有两次排班",
309
+	ErrorCodeCantSetScheduleBeforeNow:       "不能给今天之前的日期排班",
310
+	ErrorCodeScheduleNotExist:               "排班不存在",
311
+	ErrorCodePointScheduleExist:             "所先位置排班已经存在",
312
+	ErrorCodeDeleteScheduleFail:             "取消排班失败",
313
+	ErrorCodeChangeScheduleFail:             "修改排班失败",
314
+	ErrorCodePatientPhoneUsed:               "手机号已经存在",
315
+	ErrorCodeAdviceExced:                    "医嘱已经执行",
316
+	ErrorCodeAdviceCheckBeforeExce:          "核对医嘱不能在执行医嘱之前",
317
+	ErrorCodeAdviceExceBeforeStart:          "执行医嘱不能在开始之前",
318
+	ErrorCodeAdviceChecked:                  "医嘱已经核对",
319
+	ErrorCodeExceAndCheckNotOneUser:         "核对与执行不能是同一人",
320
+	ErrorCodeCanotEditOtherAdvice:           "不能修改非本人添加的医嘱",
321
+	ErrorCodeEditLapsetoFail:                "转归失败",
322
+	ErrorCodeDelScheduleFailByDialysis:      "已经上机透析,不能取消排班",
323
+	ErrorCodeNotSelectLapsetoType:           "请选择转归状态",
324
+	ErrorCodeNotSelectLapsetoTime:           "请选择转归时间",
325
+
326
+	ErrorCodeInspectionDateExit:    "当天已经存在检验检查记录",
327
+	ErrorCodeInspectionAddFail:     "添加记录失败",
328
+	ErrorCodeInspectionDateNotExit: "当天不存在检验检查记录",
329
+	ErrorCodeInspectionEditFail:    "修改记录失败",
330
+	ErrorCodeInspectionDeleteFail:  "删除记录失败",
331
+
332
+	ErrorCodeDeviceZoneNotExist:                      "设备分区不存在",
333
+	ErrorCodeDeviceZoneNameRepeat:                    "该分区名已存在",
334
+	ErrorCodeDeviceGroupNotExist:                     "设备分组不存在",
335
+	ErrorCodeDeviceGroupNameRepeat:                   "该分组名已存在",
336
+	ErrorCodeDeviceNumberNotExist:                    "机号不存在",
337
+	ErrorCodeDeviceNumberRepeat:                      "该机号已存在",
338
+	ErrorCodeDeviceNotExist:                          "该设备不存在",
339
+	ErrorCodeDeviceZoneCannotDisable:                 "该分区存在床位号,不能删除",
340
+	ErrorCodeDeviceNumberCannotDisableCuzDevice:      "该床位存在设备,不能删除",
341
+	ErrorCodeDeviceNumberCannotDisableCuzSchedule:    "该床位尚有排班安排,不能删除",
342
+	ErrorCodeDeviceNumberCannotDisableCuzSchTemplate: "排班模板在该床位尚有排班安排,不能删除",
343
+
344
+	ErrorCodeNotSubscibe:       "没有订阅服务或服务已过期,请先购买服务!",
345
+	ErrorCodeServeNotExist:     "服务订单不存在!",
346
+	ErrorCodeInvoiceExist:      "已经申请了发票!",
347
+	ErrorCodeApplyInvoiceFail:  "申请发票失败!",
348
+	ErrorCodeHetongHad:         "合同已经存在!",
349
+	ErrorCodeCreateHetongFail:  "合同创建失败",
350
+	ErrorCodePatientReachLimit: "患者数已达到当前服务版本病人数,需要升级到更高的版本",
351
+
352
+	ErrorCodeMonitorCreate:                  "创建监测失败",
353
+	ErrorCodeMonitorNotExist:                "监测记录不存在",
354
+	ErrorCodeMonitorUpdate:                  "修改监测失败",
355
+	ErrorCodeDialysisPermissionDeniedModify: "您没有权限修改其他医护的数据!",
356
+
357
+	ErrorDialysisOrderNoStart:     "尚未上机,无法执行下机操作",
358
+	ErrorDialysisOrderNoEND:       "已处于下机状态",
359
+	ErrorDialysisOrderRepeatStart: "已上机",
360
+	ErrorDialysisOrderRepeatBed:   "该床位已有患者上机,请选择其他床位",
361
+	//ErrorCodeScheduleTemplateNotExist: "排班模板不存在",
362
+
363
+	ErrorCodeSystemError:              "系统异常",
364
+	ErrorCodeProductError:             "该服务商品已丢失",
365
+	ErrorCodeScheduleTemplateNotExist: "排班模板不存在",
366
+
367
+	ErrorCodeCreateStockInFail: "入库失败",
368
+	//ErrorCodeSystemError:  "系统异常",
369
+	//ErrorCodeProductError: "该服务商品已丢失",
370
+	ErrorCodeFieldExist:   "配置字段已存在",
371
+	ErrorCodeCreateConfig: "创建配置失败",
372
+	ErrorCodeUpdateConfig: "修改配置失败",
373
+
374
+	ErrorCommitFail:               "提交失败",
375
+	ErrorCodeDoubleCheckWrong:     "核对已完成, 无法再次提交",
376
+	ErrorCodeDoubleCheckUserWrong: "你已完成核对,不能重复核对",
377
+	ErrorCodeGoodNoStockInError:   "该商品尚未入库",
378
+
379
+	ErrorCodeCancelStockFail:    "出库退库失败",
380
+	ErrorCodeDeleteGoodTypeFail: "该类型存在商品信息,无法删除",
381
+	ErrorCodeDeleteGoodInfoFail: "该商品已经入库或者出库无法删除",
382
+
383
+	ErrorCodeDeleteFail: "删除失败",
384
+
385
+	ErrorCodeKeyFail:                 "关键字不能为空",
386
+	ErrorCodeDeleteStockInRecordFail: "该记录已经有出库或退货操作,无法删除",
387
+	ErrorCodeNameWrong:               "该模版名字已存在",
388
+	ErrorCodeParamEmptyWrong:         "模版名称不能为空",
389
+	ErrorCodeParamAdviceEmptyWrong:   "医嘱名称不能为空",
390
+
391
+	ErrorCodeDeleteDealerWrong:       "该经销商所属商品已入库无法删除",
392
+	ErrorCodeDeleteManufacturerWrong: "该厂商所属商品已入库无法删除",
393
+	ErrorCodeGoodTypeNameExistError:  "该商品类型名字已存在",
394
+	ErrorCodeGoodInfoNameExistError:  "该规格名称名字已存在",
395
+
396
+	ErrorCodePrescriptionPermissionDeniedModify: "您没有权限修改透析处方数据",
397
+	ErrorCodeAdvicePermissionDeniedModify:       "您没有权限添加医嘱",
398
+	ErrorCodePrescriptionException:              "上机失败,请先开处方",
399
+	ErrorCodeNotDocking:                         "该地区尚未对接",
400
+
401
+	ErrorCodeAdviceTypeWrong:      "请选择医嘱模版类型",
402
+	ErrorCodeCreateAdvice:         "你没有权限开医嘱",
403
+	ErrorCodePatientDialysisOrder: "该病人已经上机,无法临时排班",
404
+	ErrorSchedualcRepeatBed:       "该床位已经有人排班,无法临时排班",
405
+
406
+	ErrorCodeChangeMode:         "该患者今天已上机治疗,请在透析记录中进行调整透析模式",
407
+	ErrorCodeChangeDeviceNumber: "该患者今天已上机治疗,请在透析记录中进行调整机号",
408
+
409
+	ErrorCodeHisIdExist: "该his_id已被占用,请重新输入",
410
+
411
+	ErrorCodePreExist: "没有该权限",
412
+
413
+	ErrorCodeRepeatCreateOrg: "该账号已创建过机构了",
414
+
415
+	ErrorCodeOrgNoExist: "该机构不存在",
416
+
417
+	ErrorCodeRegisterExist: "该账号已经注册,请登录",
418
+
419
+	ErrorCodeRepeatCreateStaffException: "该员工已经存在无法继续添加",
420
+
421
+	ErrorCodeForbidden: "你已经被管理员禁用,无法使用该系统",
422
+
423
+	ErrorCodeRoleNameIsExist: "该角色已经不存在",
424
+
425
+	ErrorCodeRole: "尚未配置角色,无访问权限",
426
+
427
+	ErrorCodeAdminUserIsExit: "用户不存在",
428
+	ErrorCodePhone:           "请填写正确的联系电话",
429
+
430
+	ErrorCodeLogOut:      "退出",
431
+	ErrorCodeExportError: "导入出错,请下载并查看相关日志",
432
+
433
+	ErrorCodeOrgNoPatient: "暂无病人",
434
+
435
+	ErrorCodeDoctorAdviceEmpty: "没有更多了",
436
+	ErrorCodeOpenStocktWrong:   "未开启自动扣减功能,无法出库",
437
+
438
+	ErrorCodeDrugRepeatDataException: "该药已经存在,无法添加",
439
+
440
+	ErrorCodeIDCartNo: "身份证不能为空",
441
+
442
+	ErrorCodeRegisterOneException: "无参保信息",
443
+
444
+	ErrorCodeRegisterTwoException: "挂号失败",
445
+
446
+	ErrorCodeCreateOrderException: "创建预结算订单失败",
447
+
448
+	ErrorCodeCalOrderException: "结算失败",
449
+
450
+	ErrorCodeHisRegisterException: "一天只能挂一个号",
451
+
452
+	ErrorCodeNoBloodPatientException: "找不到该患者,请先在系统录入患者信息或检查患者身份证信息",
453
+
454
+	ErrorCodeOrderParamWrong: "结算记录不存在",
455
+
456
+	ErrorCodeHisPatientParamWrong: "订单正在结算、请先结算完成",
457
+
458
+	ErrorCodeOutOfStockParamWrong: "库存不足",
459
+
460
+	ErrorCodeOrderParamWrongTwo: "该就诊号存在结算记录,需要先退费后再退号",
461
+}
462
+
463
+type SGJError struct {
464
+	Code int
465
+}
466
+
467
+func (e *SGJError) Error() string {
468
+	value, ok := ErrCodeMsgs[e.Code]
469
+	if ok {
470
+		return value
471
+	} else {
472
+		return "未知错误"
473
+	}
474
+}
475
+
476
+type CommonResp struct {
477
+	Code  int         `json:"code"`
478
+	Msg   string      `json:"msg"`
479
+	Data  interface{} `json:"data"`
480
+	State int         `json:"state"`
481
+}
482
+
483
+func MakeSuccessResponseJSON(data interface{}) CommonResp {
484
+	resp := CommonResp{Code: 0, State: 1, Msg: "success"}
485
+	if data != nil {
486
+		resp.Data = data
487
+	} else {
488
+		resp.Data = new(interface{})
489
+	}
490
+	return resp
491
+}
492
+
493
+func MakeFailResponseJSON(errMsg string, errCode int) CommonResp {
494
+	resp := CommonResp{Code: errCode, Msg: errMsg, State: 0}
495
+	return resp
496
+}
497
+
498
+func MakeDynamicFailResponseJSON(errMsg string) CommonResp {
499
+	resp := CommonResp{Msg: errMsg, State: 0}
500
+	return resp
501
+}
502
+
503
+func MakeFailResponseJSONWithSGJError(err *SGJError) CommonResp {
504
+	if err == nil {
505
+		utils.WarningLog("MakeFailResponseJSONWithSGJError 参数err 不能为空")
506
+		return CommonResp{}
507
+	}
508
+	return MakeFailResponseJSON(err.Error(), err.Code)
509
+}
510
+
511
+func MakeFailResponseJSONWithSGJErrorCode(code int) CommonResp {
512
+	err := &SGJError{Code: code}
513
+	return MakeFailResponseJSON(err.Error(), err.Code)
514
+}

+ 44 - 0
go.mod View File

1
+module sws_xcx
2
+
3
+go 1.19
4
+
5
+require (
6
+	github.com/astaxie/beego v1.12.3
7
+	github.com/dgrijalva/jwt-go v3.2.0+incompatible
8
+	github.com/go-redis/redis v6.14.2+incompatible
9
+	github.com/google/uuid v1.6.0
10
+	github.com/jinzhu/gorm v1.9.16
11
+	github.com/medivhzhan/weapp/v3 v3.8.1
12
+)
13
+
14
+require (
15
+	github.com/beorn7/perks v1.0.1 // indirect
16
+	github.com/cespare/xxhash/v2 v2.2.0 // indirect
17
+	github.com/denisenkom/go-mssqldb v0.12.0 // indirect
18
+	github.com/elazarl/go-bindata-assetfs v1.0.1 // indirect
19
+	github.com/fatih/color v1.16.0 // indirect
20
+	github.com/go-sql-driver/mysql v1.7.0 // indirect
21
+	github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
22
+	github.com/golang-sql/sqlexp v0.1.0 // indirect
23
+	github.com/golang/protobuf v1.5.3 // indirect
24
+	github.com/hashicorp/golang-lru v0.5.4 // indirect
25
+	github.com/jinzhu/inflection v1.0.0 // indirect
26
+	github.com/jinzhu/now v1.1.5 // indirect
27
+	github.com/mattn/go-colorable v0.1.13 // indirect
28
+	github.com/mattn/go-isatty v0.0.20 // indirect
29
+	github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
30
+	github.com/mitchellh/mapstructure v1.5.0 // indirect
31
+	github.com/prometheus/client_golang v1.16.0 // indirect
32
+	github.com/prometheus/client_model v0.3.0 // indirect
33
+	github.com/prometheus/common v0.42.0 // indirect
34
+	github.com/prometheus/procfs v0.10.1 // indirect
35
+	github.com/rogpeppe/go-internal v1.10.0 // indirect
36
+	github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
37
+	github.com/stretchr/testify v1.8.1 // indirect
38
+	golang.org/x/crypto v0.18.0 // indirect
39
+	golang.org/x/net v0.20.0 // indirect
40
+	golang.org/x/sys v0.16.0 // indirect
41
+	golang.org/x/text v0.14.0 // indirect
42
+	google.golang.org/protobuf v1.30.0 // indirect
43
+	gopkg.in/yaml.v2 v2.4.0 // indirect
44
+)

+ 277 - 0
go.sum View File

1
+github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw=
2
+github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0=
3
+github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8=
4
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
5
+github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
6
+github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
7
+github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
8
+github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
9
+github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
10
+github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
11
+github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
12
+github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
13
+github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
14
+github.com/astaxie/beego v1.12.3 h1:SAQkdD2ePye+v8Gn1r4X6IKZM1wd28EyUOVQ3PDSOOQ=
15
+github.com/astaxie/beego v1.12.3/go.mod h1:p3qIm0Ryx7zeBHLljmd7omloyca1s4yu1a8kM1FkpIA=
16
+github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
17
+github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=
18
+github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
19
+github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
20
+github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
21
+github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
22
+github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
23
+github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
24
+github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
25
+github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
26
+github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
27
+github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
28
+github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
29
+github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
30
+github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
31
+github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
32
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
33
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
34
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
35
+github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
36
+github.com/denisenkom/go-mssqldb v0.12.0 h1:VtrkII767ttSPNRfFekePK3sctr+joXgO58stqQbtUA=
37
+github.com/denisenkom/go-mssqldb v0.12.0/go.mod h1:iiK0YP1ZeepvmBQk/QpLEhhTNJgfzrpArPY/aFvc9yU=
38
+github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
39
+github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
40
+github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
41
+github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
42
+github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
43
+github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
44
+github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE03qmvRTNfbw=
45
+github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
46
+github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
47
+github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
48
+github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
49
+github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
50
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
51
+github.com/glendc/gopher-json v0.0.0-20170414221815-dc4743023d0c/go.mod h1:Gja1A+xZ9BoviGJNA2E9vFkPjjsl+CoJxSXiQM1UXtw=
52
+github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
53
+github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
54
+github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
55
+github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
56
+github.com/go-redis/redis v6.14.2+incompatible h1:UE9pLhzmWf+xHNmZsoccjXosPicuiNaInPgym8nzfg0=
57
+github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
58
+github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
59
+github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
60
+github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
61
+github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
62
+github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
63
+github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
64
+github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
65
+github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
66
+github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188/go.mod h1:vXjM/+wXQnTPR4KqTKDgJukSZ6amVRtWMPEjE6sQoK8=
67
+github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
68
+github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
69
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
70
+github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
71
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
72
+github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
73
+github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
74
+github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
75
+github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
76
+github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
77
+github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
78
+github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
79
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
80
+github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
81
+github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
82
+github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
83
+github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
84
+github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
85
+github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
86
+github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
87
+github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
88
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
89
+github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
90
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
91
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
92
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
93
+github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
94
+github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
95
+github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
96
+github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
97
+github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
98
+github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
99
+github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
100
+github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
101
+github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
102
+github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
103
+github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
104
+github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
105
+github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
106
+github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
107
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
108
+github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
109
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
110
+github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
111
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
112
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
113
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
114
+github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6/go.mod h1:n931TsDuKuq+uX4v1fulaMbA/7ZLLhjc85h7chZGBCQ=
115
+github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
116
+github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
117
+github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
118
+github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
119
+github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
120
+github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
121
+github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
122
+github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
123
+github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
124
+github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
125
+github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
126
+github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
127
+github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
128
+github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
129
+github.com/medivhzhan/weapp/v3 v3.8.1 h1:ZRYcEAU9mz73hI/X7+/qVj2ik+TPEQaI7PuiD2alF8E=
130
+github.com/medivhzhan/weapp/v3 v3.8.1/go.mod h1:xE4GrGv/3/eR2+GSO8L8wCmvbf261aBHJla/QmoVGQM=
131
+github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
132
+github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
133
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
134
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
135
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
136
+github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
137
+github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
138
+github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
139
+github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
140
+github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
141
+github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU=
142
+github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
143
+github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ=
144
+github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
145
+github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
146
+github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
147
+github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
148
+github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
149
+github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
150
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
151
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
152
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
153
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
154
+github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
155
+github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
156
+github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
157
+github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
158
+github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc=
159
+github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
160
+github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
161
+github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
162
+github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
163
+github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
164
+github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
165
+github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
166
+github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
167
+github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
168
+github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
169
+github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
170
+github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
171
+github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
172
+github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
173
+github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
174
+github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
175
+github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
176
+github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 h1:DAYUYH5869yV94zvCES9F51oYtN5oGlwjxJJz7ZCnik=
177
+github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
178
+github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
179
+github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
180
+github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
181
+github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
182
+github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
183
+github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
184
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
185
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
186
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
187
+github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
188
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
189
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
190
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
191
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
192
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
193
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
194
+github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
195
+github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
196
+github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
197
+github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
198
+github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
199
+github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
200
+github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
201
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
202
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
203
+golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
204
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
205
+golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
206
+golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
207
+golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
208
+golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
209
+golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
210
+golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
211
+golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
212
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
213
+golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
214
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
215
+golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
216
+golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
217
+golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
218
+golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
219
+golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
220
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
221
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
222
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
223
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
224
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
225
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
226
+golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
227
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
228
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
229
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
230
+golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
231
+golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
232
+golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
233
+golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
234
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
235
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
236
+golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
237
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
238
+golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
239
+golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
240
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
241
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
242
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
243
+golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
244
+golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
245
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
246
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
247
+google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
248
+google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
249
+google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
250
+google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
251
+google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
252
+google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
253
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
254
+google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
255
+google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
256
+google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
257
+gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
258
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
259
+gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
260
+gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
261
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
262
+gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
263
+gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
264
+gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
265
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
266
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
267
+gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
268
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
269
+gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
270
+gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
271
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
272
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
273
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
274
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
275
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
276
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
277
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

+ 17 - 0
main.go View File

1
+package main
2
+
3
+import (
4
+	_ "sws_xcx/routers"
5
+	"sws_xcx/service"
6
+
7
+	"github.com/astaxie/beego"
8
+)
9
+
10
+func main() {
11
+	service.ConnectDB()
12
+	if beego.BConfig.RunMode == "dev" {
13
+		beego.BConfig.WebConfig.DirectoryIndex = true
14
+		beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
15
+	}
16
+	beego.Run()
17
+}

+ 144 - 0
models/dbmodels.go View File

1
+package models
2
+
3
+import "time"
4
+
5
+type CheckItem struct {
6
+	Id              int       `json:"id" gorm:"type:int(11) auto_increment; NOT NULL; primary_key; COMMENT:'检测项目ID'"`
7
+	CheckItemNumber int       `json:"check_item_number" gorm:"type:int(11); COMMENT:'排序'"`
8
+	Language        string    `json:"language" gorm:"type:varchar(255); COMMENT:'cn: 中文 en 英文'"`
9
+	NameEn          string    `json:"name_en" gorm:"type:varchar(255); COMMENT:'检测项目英文名'"`
10
+	NameCn          string    `json:"name_cn" gorm:"type:varchar(255); COMMENT:'检测项目中文名'"`
11
+	DeviceType      string    `json:"device_type" gorm:"type:varchar(11); COMMENT:'设备类型'"`
12
+	CheckType       string    `json:"check_type" gorm:"type:varchar(255); COMMENT:'检测类型(试纸类型)'"`
13
+	ReferenceValue  string    `json:"reference_value" gorm:"type:varchar(255); COMMENT:' 参考值'"`
14
+	ScopeList       string    `json:"scope_list" gorm:"type:text; COMMENT:'范围value 值,type =1为正常、2及以上为异 常'"`
15
+	Text            string    `json:"text" gorm:"type:varchar(255); COMMENT:'文本'"`
16
+	Details         string    `json:"details" gorm:"type:text; COMMENT:'描述'"`
17
+	Unit            string    `json:"unit" gorm:"type:varchar(255); COMMENT:'单位'"`
18
+	Remark          string    `json:"remark" gorm:"type:varchar(255); COMMENT:'备注'"`
19
+	Ctime           time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'"`
20
+	Mtime           time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间 '"`
21
+	DeleteFlag      int       `json:"delete_flag" gorm:"type:int(11); COMMENT:'删除标志'"`
22
+}
23
+type CheckRecord struct {
24
+	Id                  int64     `json:"id" gorm:"type:bigint(20); NOT NULL; primary_key; COMMENT:'检测记录ID'"`
25
+	CheckType           string    `json:"check_type" gorm:"type:varchar(255); COMMENT:'检测类型(试纸类型)'"`
26
+	PutSources          string    `json:"put_sources" gorm:"type:varchar(255); COMMENT:'上传数据来源'"`
27
+	DeviceId            int64     `json:"device_id" gorm:"type:bigint(20); COMMENT:'设备ID'"`
28
+	DeviceStatus        int       `json:"device_status" gorm:"type:int(2); COMMENT:'设备状态'"`
29
+	MessageId           string    `json:"message_id" gorm:"type:varchar(255); COMMENT:'设备消息id'"`
30
+	UserId              int64     `json:"user_id" gorm:"type:bigint(20); DEFAULT:'0'; COMMENT:'用户ID'"`
31
+	UserHealthProfileId int64     `json:"user_health_profile_id" gorm:"type:bigint(20); DEFAULT:'0'; COMMENT:'健康档案ID'"`
32
+	View                int       `json:"view" gorm:"type:int(11); DEFAULT:'0'; COMMENT:'查看:1(已查看) 0(未查看)'"`
33
+	AlertItemIds        string    `json:"alert_item_ids" gorm:"type:varchar(255); COMMENT:'异常项目id (1,2,3)'"`
34
+	Acc                 int       `json:"acc" gorm:"type:int(10); COMMENT:'设备检测次数'"`
35
+	Ctime               time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间 '"`
36
+	Mtime               time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间'"`
37
+	DeleteFlag          int       `json:"delete_flag" gorm:"type:int(1); DEFAULT:'0'; COMMENT:'删除标志'"`
38
+}
39
+type CheckRecordItem struct {
40
+	Id              int64     `json:"id" gorm:"type:bigint(20) auto_increment; NOT NULL; primary_key"`
41
+	CheckId         int64     `json:"check_id" gorm:"type:bigint(20); NOT NULL; DEFAULT:'0'"`
42
+	CheckItemId     int       `json:"check_item_id" gorm:"type:int(11); COMMENT:'检测项目id'"`
43
+	CheckValue      string    `json:"check_value" gorm:"type:varchar(255); COMMENT:'检测结果数值'"`
44
+	CheckValueIndex int       `json:"check_value_index" gorm:"type:int(3); COMMENT:'check_item value index'"`
45
+	Ctime           time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP"`
46
+	Mtime           time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"`
47
+	DeleteFlag      int       `json:"delete_flag" gorm:"type:int(11); COMMENT:'删除标志'"`
48
+}
49
+type Device struct {
50
+	Id                   uint64    `json:"id" gorm:"type:bigint(20) unsigned auto_increment; NOT NULL; primary_key; COMMENT:'设备ID'"`
51
+	Name                 string    `json:"name" gorm:"type:varchar(255); COMMENT:'设备名称'"`
52
+	Serialno             string    `json:"serialno" gorm:"type:varchar(64); COMMENT:'设备编号'"`
53
+	DeviceName           string    `json:"device_name" gorm:"type:varchar(255); COMMENT:'设备名称'"`
54
+	DeviceType           string    `json:"device_type" gorm:"type:varchar(11); COMMENT:'设备类型'"`
55
+	InformType           int       `json:"inform_type" gorm:"type:int(1); COMMENT:'通知类型:0跳转小程序、1跳转网页 、默认跳转小程序'"`
56
+	Mac                  string    `json:"mac" gorm:"type:varchar(255)"`
57
+	Mcu                  string    `json:"mcu" gorm:"type:varchar(255)"`
58
+	BatchNumber          int       `json:"batch_number" gorm:"type:int(10); COMMENT:'批号'"`
59
+	ProductionDateNumber int       `json:"production_date_number" gorm:"type:int(10); COMMENT:'生产日期'"`
60
+	Number               int       `json:"number" gorm:"type:int(10); COMMENT:'序号'"`
61
+	QrCodeId             int64     `json:"qr_code_id" gorm:"type:bigint(20)"`
62
+	EmqPassword          string    `json:"emq_password" gorm:"type:varchar(255); COMMENT:'emq密码'"`
63
+	Status               int       `json:"status" gorm:"type:int(2); DEFAULT:'0'; COMMENT:'状态(0:未分配 1:已分配 2:包装中 3:待出厂 6:废弃 99:已出厂 100:销售中 101:已售出)'"`
64
+	Ver                  string    `json:"ver" gorm:"type:varchar(255); COMMENT:'软件版本'"`
65
+	OemCompany           int       `json:"oem_company" gorm:"type:int(11); NOT NULL; DEFAULT:'0'; COMMENT:'厂商(0:自营  1:艾玛OEM)'"`
66
+	McuType              string    `json:"mcu_type" gorm:"type:varchar(32); COMMENT:'MCU芯片类型'"`
67
+	SensorMode           string    `json:"sensor_mode" gorm:"type:varchar(32); COMMENT:'传感放大倍数'"`
68
+	Language             string    `json:"language" gorm:"type:varchar(32); COMMENT:'语言'"`
69
+	PaperCheck           int       `json:"paper_check" gorm:"type:int(11); COMMENT:'试纸检查状态'"`
70
+	WifiVer              string    `json:"wifi_ver" gorm:"type:varchar(32); COMMENT:'WIFI版本'"`
71
+	Ctime                time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'"`
72
+	Mtime                time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间 '"`
73
+	DeleteFlag           int       `json:"delete_flag" gorm:"type:int(11); DEFAULT:'0'; COMMENT:'删除标志'"`
74
+}
75
+type DeviceMessageLog struct {
76
+	Id         uint64    `json:"id" gorm:"type:bigint(20) unsigned auto_increment; NOT NULL; primary_key"`
77
+	MessageId  string    `json:"message_id" gorm:"type:varchar(255)"`
78
+	DeviceName string    `json:"device_name" gorm:"type:varchar(255)"`
79
+	Topic      string    `json:"topic" gorm:"type:varchar(255)"`
80
+	EventType  string    `json:"event_type" gorm:"type:varchar(255)"`
81
+	Content    string    `json:"content" gorm:"type:text; COMMENT:'消息内容'"`
82
+	Ctime      time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'"`
83
+}
84
+type DeviceRelate struct {
85
+	Id         int64     `json:"id" gorm:"type:bigint(20) auto_increment; NOT NULL; primary_key; COMMENT:'id'"`
86
+	Name       string    `json:"name" gorm:"type:varchar(255); COMMENT:'名称'"`
87
+	DeviceId   int64     `json:"device_id" gorm:"type:bigint(20); COMMENT:'设备Id'"`
88
+	UserId     int64     `json:"user_id" gorm:"type:bigint(20); COMMENT:'会员Id'"`
89
+	Ctime      time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'"`
90
+	Mtime      time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间 '"`
91
+	DeleteFlag int       `json:"delete_flag" gorm:"type:int(11); DEFAULT:'0'; COMMENT:'删除标志(解绑时标记为删除)'"`
92
+}
93
+type SysDictionary struct {
94
+	Id         int       `json:"id" gorm:"type:int(11) auto_increment; NOT NULL; primary_key"`
95
+	NameEn     string    `json:"name_en" gorm:"type:varchar(255)"`
96
+	NameCh     string    `json:"name_ch" gorm:"type:text"`
97
+	Type       string    `json:"type" gorm:"type:varchar(255)"`
98
+	ParentId   int       `json:"parent_id" gorm:"type:int(11)"`
99
+	Ctime      time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP"`
100
+	DeleteFlag int       `json:"delete_flag" gorm:"type:int(11); NOT NULL; DEFAULT:'0'; COMMENT:'删除标志'"`
101
+}
102
+type UserHealthProfile struct {
103
+	Id                  uint64    `json:"id" gorm:"type:bigint(20) unsigned auto_increment; NOT NULL; primary_key; COMMENT:'Primary Key ID'"`
104
+	UserId              int64     `json:"user_id" gorm:"type:bigint(20); NOT NULL; COMMENT:'用户ID'"`
105
+	RealName            string    `json:"real_name" gorm:"type:varchar(64); COMMENT:'真实姓名'"`
106
+	IdCard              string    `json:"id_card" gorm:"type:varchar(64); COMMENT:'身份证号'"`
107
+	InpatientRegPhone   string    `json:"inpatient_reg_phone" gorm:"type:varchar(32); COMMENT:'住院登记手机号'"`
108
+	Gender              int       `json:"gender" gorm:"type:int(11); DEFAULT:'0'; COMMENT:'性别(0:未知 1:男 2:女)'"`
109
+	Height              int       `json:"height" gorm:"type:int(11); COMMENT:'身高'"`
110
+	Weight              int       `json:"weight" gorm:"type:int(11); COMMENT:'体重'"`
111
+	BloodType           string    `json:"blood_type" gorm:"type:varchar(32); COMMENT:'血型'"`
112
+	Birthday            time.Time `json:"birthday" gorm:"type:datetime; COMMENT:'生日'"`
113
+	IllnessState        string    `json:"illness_state" gorm:"type:varchar(255); COMMENT:'病情'"`
114
+	RenalFunctionStatus int       `json:"renal_function_status" gorm:"type:int(11); COMMENT:'肾功能情况(0:未透析,1: 血液透析,2:腹膜透析,3:肾脏移植)'"`
115
+	Creatinine          int       `json:"creatinine" gorm:"type:int(11); NOT NULL; DEFAULT:'0'; COMMENT:'血肌酐'"`
116
+	CreatinineUnit      string    `json:"creatinine_unit" gorm:"type:varchar(32); COMMENT:'肌酐单位(umol/L,mg/dl)'"`
117
+	CreatineTime        time.Time `json:"creatine_time" gorm:"type:datetime; COMMENT:'肌酐检测时间'"`
118
+	UrineProtein24hUnit string    `json:"urine_protein_24h_unit" gorm:"type:varchar(32); COMMENT:'24小时尿蛋白单位(g/24h,mg/24h)'"`
119
+	UrineProtein24h     int       `json:"urine_protein_24h" gorm:"type:int(11); NOT NULL; DEFAULT:'0'; COMMENT:'24小时尿蛋白'"`
120
+	UrineProtein24hTime time.Time `json:"urine_protein_24h_time" gorm:"type:datetime; COMMENT:'24小时尿蛋白检测时间'"`
121
+	UrineProtein        int       `json:"urine_protein" gorm:"type:int(11); NOT NULL; DEFAULT:'0'; COMMENT:'尿蛋白'"`
122
+	UrineProteinUnit    string    `json:"urine_protein_unit" gorm:"type:varchar(32); COMMENT:'尿蛋白单位(g,mg)'"`
123
+	UrineProteinTime    time.Time `json:"urine_protein_time" gorm:"type:datetime; COMMENT:'尿蛋白检测时间'"`
124
+	Status              int       `json:"status" gorm:"type:int(11); DEFAULT:'1'; COMMENT:'状态(1:有效 0:无效 )'"`
125
+	Ctime               time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'"`
126
+	Mtime               time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间 '"`
127
+}
128
+type XcxUser struct {
129
+	Id                      uint64    `json:"id" gorm:"type:bigint(20) unsigned auto_increment; NOT NULL; primary_key; COMMENT:'Primary Key ID'"`
130
+	Phone                   string    `json:"phone" gorm:"type:varchar(32); COMMENT:'手机号码'"`
131
+	Email                   string    `json:"email" gorm:"type:varchar(255); COMMENT:'邮件'"`
132
+	OpenId                  string    `json:"open_id" gorm:"type:varchar(255); COMMENT:'OpenID'"`
133
+	UnionId                 string    `json:"union_id" gorm:"type:varchar(255); COMMENT:'unionid'"`
134
+	NickName                string    `json:"nick_name" gorm:"type:varchar(64); COMMENT:'昵称'"`
135
+	Avatar                  string    `json:"avatar" gorm:"type:varchar(255); COMMENT:'头像'"`
136
+	Status                  int       `json:"status" gorm:"type:int(11); DEFAULT:'1'; COMMENT:'状态(1:有效 0: 无效)'"`
137
+	RoleType                int       `json:"role_type" gorm:"type:int(2); COMMENT:'角色类型 0或空:普通 1:管理员 2:测试'"`
138
+	Source                  string    `json:"source" gorm:"type:varchar(255); COMMENT:'用户来源'"`
139
+	PrivacyProtocolVersions int       `json:"privacy_protocol_versions" gorm:"type:int(2); COMMENT:'隐私政策版本'"`
140
+	Ctime                   time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'"`
141
+	Mtime                   time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间 '"`
142
+
143
+	SessionKey string `json:"session_key" gorm:"-"`
144
+}

+ 10 - 0
models/httpmodels.go View File

1
+package models
2
+
3
+type WxXcxLoginReq struct {
4
+	Code string `json:"code"`
5
+}
6
+
7
+type WxXcxLoginResp struct {
8
+	Token  string `json:"token"`
9
+	OpenId string `json:"openid"`
10
+}

+ 40 - 0
routers/router.go View File

1
+// @APIVersion 1.0.0
2
+// @Title sws xcx api doc
3
+// @Description 圣卫士小程序API接口文档
4
+// @License 领透科技
5
+package routers
6
+
7
+import (
8
+	"sws_xcx/controllers"
9
+
10
+	"github.com/astaxie/beego"
11
+	"github.com/astaxie/beego/plugins/cors"
12
+)
13
+
14
+func init() {
15
+	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
16
+		// AllowAllOrigins:  true,
17
+		AllowOrigins: []string{"https://xt.kuyicloud.com", "http://sws.kuyicloud.com", "http://localhost:9539", "http://127.0.0.1:9539", "http://xcx.sgjyun.com"},
18
+		//AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com","http://mobile.sgjyun.com","http://mobile.kuyicloud.com"},
19
+		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
20
+		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "X-XSRF-TOKEN", "Permission"},
21
+		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
22
+		AllowCredentials: true,
23
+	}))
24
+
25
+	ns :=
26
+		beego.NewNamespace("/xcx",
27
+			beego.NSNamespace("/api/user",
28
+				beego.NSInclude(
29
+					&controllers.LoginApiController{},
30
+					&controllers.DeviceApiController{},
31
+				),
32
+			),
33
+			beego.NSNamespace("/api/device",
34
+				beego.NSInclude(
35
+					&controllers.MessageApiControllor{},
36
+				)),
37
+		)
38
+	beego.AddNamespace(ns)
39
+	controllers.ApiControllersRegisterRouters()
40
+}

+ 277 - 0
service/db.go View File

1
+// Pipe - A small and beautiful blogging platform written in golang.
2
+// Copyright (C) 2017-2018, b3log.org
3
+//
4
+// This program is free software: you can redistribute it and/or modify
5
+// it under the terms of the GNU General Public License as published by
6
+// the Free Software Foundation, either version 3 of the License, or
7
+// (at your option) any later version.
8
+//
9
+// This program is distributed in the hope that it will be useful,
10
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+// GNU General Public License for more details.
13
+//
14
+// You should have received a copy of the GNU General Public License
15
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
+
17
+package service
18
+
19
+import (
20
+	"fmt"
21
+	"sws_xcx/utils"
22
+
23
+	"github.com/astaxie/beego"
24
+	"github.com/jinzhu/gorm"
25
+	_ "github.com/jinzhu/gorm/dialects/mysql" // mysql
26
+)
27
+
28
+var readDb *gorm.DB
29
+var writeDb *gorm.DB
30
+
31
+// var readUserDb *gorm.DB
32
+// var writeUserDb *gorm.DB
33
+
34
+// var readMiddleDb *gorm.DB
35
+// var writeMiddleDb *gorm.DB
36
+
37
+// var readPatientDb *gorm.DB
38
+// var writePatientDb *gorm.DB
39
+
40
+// var readSgjPatientDb *gorm.DB
41
+// var writeSgjPatientDb *gorm.DB
42
+
43
+// var readUserDbT *gorm.DB
44
+// var writeUserDbT *gorm.DB
45
+
46
+var err error
47
+
48
+func ConnectDB() {
49
+	readHost := beego.AppConfig.String("readmysqlhost")
50
+	readPort := beego.AppConfig.String("readmysqlport")
51
+	readUser := beego.AppConfig.String("readmysqluser")
52
+	readPass := beego.AppConfig.String("readmysqlpass")
53
+	readName := beego.AppConfig.String("readmysqlname")
54
+
55
+	writeHost := beego.AppConfig.String("writemysqlhost")
56
+	writePort := beego.AppConfig.String("writemysqlport")
57
+	writeUser := beego.AppConfig.String("writemysqluser")
58
+	writePass := beego.AppConfig.String("writemysqlpass")
59
+	writeName := beego.AppConfig.String("writemysqlname")
60
+
61
+	// readUserHost := beego.AppConfig.String("readuserhost")
62
+	// readUserPort := beego.AppConfig.String("readuserport")
63
+	// readUserUser := beego.AppConfig.String("readuseruser")
64
+	// readUserPass := beego.AppConfig.String("readuserpass")
65
+	// readUserName := beego.AppConfig.String("readusername")
66
+
67
+	// writeUserHost := beego.AppConfig.String("writeuserhost")
68
+	// writeUserPort := beego.AppConfig.String("writeuserport")
69
+	// writeUserUser := beego.AppConfig.String("writeuseruser")
70
+	// writeUserPass := beego.AppConfig.String("writeuserpass")
71
+	// writeUserName := beego.AppConfig.String("writeusername")
72
+
73
+	// readMiddleHost := beego.AppConfig.String("readmiddlehost")
74
+	// readMiddlePort := beego.AppConfig.String("readmiddleport")
75
+	// readMiddleUser := beego.AppConfig.String("readmiddleuser")
76
+	// readMiddlePass := beego.AppConfig.String("readmiddlepass")
77
+	// readMiddleName := beego.AppConfig.String("readmiddlename")
78
+
79
+	// writeMiddleHost := beego.AppConfig.String("writemiddlehost")
80
+	// writeMiddlePort := beego.AppConfig.String("writemiddleport")
81
+	// writeMiddleUser := beego.AppConfig.String("writemiddleuser")
82
+	// writeMiddlePass := beego.AppConfig.String("writemiddlepass")
83
+	// writeMiddleName := beego.AppConfig.String("writemiddlename")
84
+
85
+	// readPatientHost := beego.AppConfig.String("readpatienthost")
86
+	// readPatientPort := beego.AppConfig.String("readpatientport")
87
+	// readPatientUser := beego.AppConfig.String("readpatientuser")
88
+	// readPatientPass := beego.AppConfig.String("readpatientpass")
89
+	// readPatientName := beego.AppConfig.String("readpatientname")
90
+
91
+	// writePatientHost := beego.AppConfig.String("writepatienthost")
92
+	// writePatientPort := beego.AppConfig.String("writepatientport")
93
+	// writePatientUser := beego.AppConfig.String("writepatientuser")
94
+	// writePatientPass := beego.AppConfig.String("writepatientpass")
95
+	// writePatientName := beego.AppConfig.String("writepatientname")
96
+
97
+	// readSgjPatientHost := beego.AppConfig.String("readsgjpatientmysqlhost")
98
+	// readSgjPatientPort := beego.AppConfig.String("readsgjpatientmysqlport")
99
+	// readSgjPatientUser := beego.AppConfig.String("readsgjpatientmysqluser")
100
+	// readSgjPatientPass := beego.AppConfig.String("readsgjpatientmysqlpass")
101
+	// readSgjPatientName := beego.AppConfig.String("readsgjpatientmysqlname")
102
+
103
+	// writeSgjPatientHost := beego.AppConfig.String("writesgjpatientmysqlhost")
104
+	// writeSgjPatientPort := beego.AppConfig.String("writesgjpatientmysqlport")
105
+	// writeSgjPatientUser := beego.AppConfig.String("writesgjpatientmysqluser")
106
+	// writeSgjPatientPass := beego.AppConfig.String("writesgjpatientmysqlpass")
107
+	// writeSgjPatientName := beego.AppConfig.String("writesgjpatientmysqlname")
108
+
109
+	// readUserHostT := beego.AppConfig.String("readuserhostTest")
110
+	// readUserPortT := beego.AppConfig.String("readuserportTest")
111
+	// readUserUserT := beego.AppConfig.String("readuseruserTest")
112
+	// readUserPassT := beego.AppConfig.String("readuserpassTest")
113
+	// readUserNameT := beego.AppConfig.String("readusernameTest")
114
+
115
+	// writeUserHostT := beego.AppConfig.String("writeuserhostTest")
116
+	// writeUserPortT := beego.AppConfig.String("writeuserportTest")
117
+	// writeUserUserT := beego.AppConfig.String("writeuseruserTest")
118
+	// writeUserPassT := beego.AppConfig.String("writeuserpassTest")
119
+	// writeUserNameT := beego.AppConfig.String("writeusernameTest")
120
+
121
+	rdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser, readPass, readHost, readPort, readName)
122
+	wdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUser, writePass, writeHost, writePort, writeName)
123
+
124
+	// rudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUserUser, readUserPass, readUserHost, readUserPort, readUserName)
125
+	// wudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUserUser, writeUserPass, writeUserHost, writeUserPort, writeUserName)
126
+
127
+	// rmdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readMiddleUser, readMiddlePass, readMiddleHost, readMiddlePort, readMiddleName)
128
+	// wmdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeMiddleUser, writeMiddlePass, writeMiddleHost, writeMiddlePort, writeMiddleName)
129
+
130
+	// rpdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readPatientUser, readPatientPass, readPatientHost, readPatientPort, readPatientName)
131
+	// wpdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writePatientUser, writePatientPass, writePatientHost, writePatientPort, writePatientName)
132
+
133
+	// rspdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readSgjPatientUser, readSgjPatientPass, readSgjPatientHost, readSgjPatientPort, readSgjPatientName)
134
+	// wspdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeSgjPatientUser, writeSgjPatientPass, writeSgjPatientHost, writeSgjPatientPort, writeSgjPatientName)
135
+
136
+	// rudsnT := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUserUserT, readUserPassT, readUserHostT, readUserPortT, readUserNameT)
137
+	// wudsnT := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUserUserT, writeUserPassT, writeUserHostT, writeUserPortT, writeUserNameT)
138
+
139
+	readDb, err = gorm.Open("mysql", rdsn)
140
+	if err != nil {
141
+		utils.ErrorLog("init DB err %v", err)
142
+	}
143
+	readDb.DB().SetMaxIdleConns(10)
144
+	readDb.DB().SetMaxOpenConns(100)
145
+	readDb.LogMode(true)
146
+
147
+	writeDb, err = gorm.Open("mysql", wdsn)
148
+	if err != nil {
149
+		utils.ErrorLog("init DB err %v", err)
150
+	}
151
+	writeDb.DB().SetMaxIdleConns(10)
152
+	writeDb.DB().SetMaxOpenConns(100)
153
+	writeDb.LogMode(true)
154
+
155
+	// readUserDbT, err = gorm.Open("mysql", rudsnT)
156
+	// if err != nil {
157
+	// 	//beego.Error(err)
158
+	// }
159
+	// readUserDbT.DB().SetMaxIdleConns(10)
160
+	// readUserDbT.DB().SetMaxOpenConns(100)
161
+	// readUserDbT.LogMode(true)
162
+
163
+	// writeUserDbT, err = gorm.Open("mysql", wudsnT)
164
+	// if err != nil {
165
+	// 	//beego.Error(err)
166
+	// }
167
+	// writeUserDbT.DB().SetMaxIdleConns(10)
168
+	// writeUserDbT.DB().SetMaxOpenConns(100)
169
+	// writeUserDbT.LogMode(true)
170
+
171
+	// readUserDb, err = gorm.Open("mysql", rudsn)
172
+	// if err != nil {
173
+	// 	//beego.Error(err)
174
+	// }
175
+	// readUserDb.DB().SetMaxIdleConns(10)
176
+	// readUserDb.DB().SetMaxOpenConns(100)
177
+	// readUserDb.LogMode(true)
178
+
179
+	// writeUserDb, err = gorm.Open("mysql", wudsn)
180
+	// if err != nil {
181
+	// 	//beego.Error(err)
182
+	// }
183
+	// writeUserDb.DB().SetMaxIdleConns(10)
184
+	// writeUserDb.DB().SetMaxOpenConns(100)
185
+	// writeUserDb.LogMode(true)
186
+
187
+	// readMiddleDb, err = gorm.Open("mysql", rmdsn)
188
+	// if err != nil {
189
+	// 	//beego.Error(err)
190
+	// }
191
+	// readMiddleDb.DB().SetMaxIdleConns(10)
192
+	// readMiddleDb.DB().SetMaxOpenConns(100)
193
+	// readMiddleDb.LogMode(true)
194
+
195
+	// writeMiddleDb, err = gorm.Open("mysql", wmdsn)
196
+	// if err != nil {
197
+	// 	//beego.Error(err)
198
+	// }
199
+	// writeMiddleDb.DB().SetMaxIdleConns(10)
200
+	// writeMiddleDb.DB().SetMaxOpenConns(100)
201
+	// writeMiddleDb.LogMode(true)
202
+
203
+	// readPatientDb, err = gorm.Open("mysql", rpdsn)
204
+	// if err != nil {
205
+	// 	beego.Error(err)
206
+	// }
207
+	// readPatientDb.DB().SetMaxIdleConns(10)
208
+	// readPatientDb.DB().SetMaxOpenConns(100)
209
+	// readPatientDb.LogMode(true)
210
+
211
+	// writePatientDb, err = gorm.Open("mysql", wpdsn)
212
+	// if err != nil {
213
+	// 	beego.Error(err)
214
+	// }
215
+	// writePatientDb.DB().SetMaxIdleConns(10)
216
+	// writePatientDb.DB().SetMaxOpenConns(100)
217
+	// writePatientDb.LogMode(true)
218
+
219
+	// readSgjPatientDb, err = gorm.Open("mysql", rspdsn)
220
+	// if err != nil {
221
+	// 	beego.Error(err)
222
+	// }
223
+	// readSgjPatientDb.DB().SetMaxIdleConns(10)
224
+	// readSgjPatientDb.DB().SetMaxOpenConns(100)
225
+	// readSgjPatientDb.LogMode(true)
226
+
227
+	// writeSgjPatientDb, err = gorm.Open("mysql", wspdsn)
228
+	// if err != nil {
229
+	// 	beego.Error(err)
230
+	// }
231
+	// writeSgjPatientDb.DB().SetMaxIdleConns(10)
232
+	// writeSgjPatientDb.DB().SetMaxOpenConns(100)
233
+	// writeSgjPatientDb.LogMode(true)
234
+}
235
+
236
+//func DisconnectDB() {
237
+//	if err := readDb.Close(); nil != err {
238
+//		beego.Error("Disconnect from database failed: " + err.Error())
239
+//	}
240
+//}
241
+
242
+func ReadDB() *gorm.DB {
243
+	return readDb
244
+}
245
+func WriteDB() *gorm.DB {
246
+	return writeDb
247
+}
248
+
249
+// func UserReadDB() *gorm.DB {
250
+// 	return readUserDb
251
+// }
252
+// func UserWriteDB() *gorm.DB {
253
+// 	return writeUserDb
254
+// }
255
+
256
+// func MiddleReadDB() *gorm.DB {
257
+// 	return readMiddleDb
258
+// }
259
+// func MiddleWriteDB() *gorm.DB {
260
+// 	return writeMiddleDb
261
+// }
262
+
263
+// func PatientReadDB() *gorm.DB {
264
+// 	return readPatientDb
265
+// }
266
+
267
+// func PatientWriteDB() *gorm.DB {
268
+// 	return writePatientDb
269
+// }
270
+
271
+// func SgjPatientReadDB() *gorm.DB {
272
+// 	return readSgjPatientDb
273
+// }
274
+
275
+// func SgjPatientWriteDB() *gorm.DB {
276
+// 	return writeSgjPatientDb
277
+// }

+ 25 - 0
service/redis.go View File

1
+package service
2
+
3
+import (
4
+	"fmt"
5
+	"sws_xcx/utils"
6
+
7
+	"github.com/astaxie/beego"
8
+	"github.com/go-redis/redis"
9
+)
10
+
11
+func RedisClient() *redis.Client {
12
+	address := fmt.Sprintf("%s:%s", beego.AppConfig.String("redishost"), beego.AppConfig.String("redisport"))
13
+	client := redis.NewClient(&redis.Options{
14
+		Addr:     address,
15
+		Password: beego.AppConfig.String("redispasswrod"), // no password set
16
+		DB:       0,                                       // use default DB
17
+	})
18
+	pong, err := client.Ping().Result()
19
+	if err != nil {
20
+		utils.ErrorLog("redis connect error: %v", err)
21
+	} else {
22
+		utils.SuccessLog("redis connect success: %v", pong)
23
+	}
24
+	return client
25
+}

+ 34 - 0
service/userservice.go View File

1
+package service
2
+
3
+import (
4
+	"sws_xcx/models"
5
+
6
+	"github.com/jinzhu/gorm"
7
+)
8
+
9
+type XcxUserService struct {
10
+	rdb *gorm.DB
11
+	wdb *gorm.DB
12
+}
13
+
14
+func NewXcxUserService() *XcxUserService {
15
+	u := &models.XcxUser{}
16
+	return &XcxUserService{rdb: readDb.Model(u), wdb: writeDb.Model(u)}
17
+}
18
+
19
+func (s *XcxUserService) GetOrCreate(openId string, unionId string) (*models.XcxUser, error) {
20
+
21
+	user := &models.XcxUser{OpenId: openId, UnionId: unionId}
22
+	db := readDb.Model(user).Where("open_id = ?", openId).Or("union_id = ?", unionId).FirstOrCreate(user)
23
+
24
+	return user, db.Error
25
+
26
+}
27
+
28
+func (s *XcxUserService) UpdateUser(user *models.XcxUser) error {
29
+
30
+	db := writeDb.Model(user).Where("id = ?", user.Id).Update(user)
31
+
32
+	return db.Error
33
+
34
+}

+ 20 - 0
service/wxapp.go View File

1
+package service
2
+
3
+import (
4
+	"github.com/astaxie/beego"
5
+	"github.com/medivhzhan/weapp/v3"
6
+)
7
+
8
+var wxsdk *weapp.Client
9
+
10
+func init() {
11
+
12
+	appid := beego.AppConfig.String("appid")
13
+	securet := beego.AppConfig.String("appsecuret")
14
+
15
+	wxsdk = weapp.NewClient(appid, securet)
16
+}
17
+
18
+func GetWxSdk() *weapp.Client {
19
+	return wxsdk
20
+}

+ 7 - 0
start.sh View File

1
+#!/bin/sh
2
+
3
+nohup ./sws_xcx >>log.txt &
4
+echo "starting..."
5
+sleep 1 
6
+echo "started"
7
+exit 0

BIN
swagger/favicon-16x16.png View File


BIN
swagger/favicon-32x32.png View File


+ 60 - 0
swagger/index.html View File

1
+<!-- HTML for static distribution bundle build -->
2
+<!DOCTYPE html>
3
+<html lang="en">
4
+  <head>
5
+    <meta charset="UTF-8">
6
+    <title>Swagger UI</title>
7
+    <link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
8
+    <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
9
+    <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
10
+    <style>
11
+      html
12
+      {
13
+        box-sizing: border-box;
14
+        overflow: -moz-scrollbars-vertical;
15
+        overflow-y: scroll;
16
+      }
17
+
18
+      *,
19
+      *:before,
20
+      *:after
21
+      {
22
+        box-sizing: inherit;
23
+      }
24
+
25
+      body
26
+      {
27
+        margin:0;
28
+        background: #fafafa;
29
+      }
30
+    </style>
31
+  </head>
32
+
33
+  <body>
34
+    <div id="swagger-ui"></div>
35
+
36
+    <script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
37
+    <script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
38
+    <script>
39
+    window.onload = function() {
40
+      // Begin Swagger UI call region
41
+      const ui = SwaggerUIBundle({
42
+        url: "swagger.json",
43
+        dom_id: '#swagger-ui',
44
+        deepLinking: true,
45
+        presets: [
46
+          SwaggerUIBundle.presets.apis,
47
+          SwaggerUIStandalonePreset
48
+        ],
49
+        plugins: [
50
+          SwaggerUIBundle.plugins.DownloadUrl
51
+        ],
52
+        layout: "StandaloneLayout"
53
+      });
54
+      // End Swagger UI call region
55
+
56
+      window.ui = ui;
57
+    };
58
+  </script>
59
+  </body>
60
+</html>

+ 79 - 0
swagger/oauth2-redirect.html View File

1
+<!doctype html>
2
+<html lang="en-US">
3
+<head>
4
+    <title>Swagger UI: OAuth2 Redirect</title>
5
+</head>
6
+<body>
7
+<script>
8
+    'use strict';
9
+    function run () {
10
+        var oauth2 = window.opener.swaggerUIRedirectOauth2;
11
+        var sentState = oauth2.state;
12
+        var redirectUrl = oauth2.redirectUrl;
13
+        var isValid, qp, arr;
14
+
15
+        if (/code|token|error/.test(window.location.hash)) {
16
+            qp = window.location.hash.substring(1);
17
+        } else {
18
+            qp = location.search.substring(1);
19
+        }
20
+
21
+        arr = qp.split("&");
22
+        arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
23
+        qp = qp ? JSON.parse('{' + arr.join() + '}',
24
+                function (key, value) {
25
+                    return key === "" ? value : decodeURIComponent(value);
26
+                }
27
+        ) : {};
28
+
29
+        isValid = qp.state === sentState;
30
+
31
+        if ((
32
+          oauth2.auth.schema.get("flow") === "accessCode" ||
33
+          oauth2.auth.schema.get("flow") === "authorizationCode" ||
34
+          oauth2.auth.schema.get("flow") === "authorization_code"
35
+        ) && !oauth2.auth.code) {
36
+            if (!isValid) {
37
+                oauth2.errCb({
38
+                    authId: oauth2.auth.name,
39
+                    source: "auth",
40
+                    level: "warning",
41
+                    message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
42
+                });
43
+            }
44
+
45
+            if (qp.code) {
46
+                delete oauth2.state;
47
+                oauth2.auth.code = qp.code;
48
+                oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
49
+            } else {
50
+                let oauthErrorMsg;
51
+                if (qp.error) {
52
+                    oauthErrorMsg = "["+qp.error+"]: " +
53
+                        (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
54
+                        (qp.error_uri ? "More info: "+qp.error_uri : "");
55
+                }
56
+
57
+                oauth2.errCb({
58
+                    authId: oauth2.auth.name,
59
+                    source: "auth",
60
+                    level: "error",
61
+                    message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
62
+                });
63
+            }
64
+        } else {
65
+            oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
66
+        }
67
+        window.close();
68
+    }
69
+
70
+    if (document.readyState !== 'loading') {
71
+        run();
72
+    } else {
73
+        document.addEventListener('DOMContentLoaded', function () {
74
+            run();
75
+        });
76
+    }
77
+</script>
78
+</body>
79
+</html>

File diff suppressed because it is too large
+ 3 - 0
swagger/swagger-ui-bundle.js


File diff suppressed because it is too large
+ 1 - 0
swagger/swagger-ui-bundle.js.map


File diff suppressed because it is too large
+ 2 - 0
swagger/swagger-ui-es-bundle-core.js


File diff suppressed because it is too large
+ 3 - 0
swagger/swagger-ui-es-bundle.js


File diff suppressed because it is too large
+ 3 - 0
swagger/swagger-ui-standalone-preset.js


File diff suppressed because it is too large
+ 1 - 0
swagger/swagger-ui-standalone-preset.js.map


File diff suppressed because it is too large
+ 4 - 0
swagger/swagger-ui.css


File diff suppressed because it is too large
+ 1 - 0
swagger/swagger-ui.css.map


File diff suppressed because it is too large
+ 2 - 0
swagger/swagger-ui.js


File diff suppressed because it is too large
+ 1 - 0
swagger/swagger-ui.js.map


+ 97 - 0
swagger/swagger.json View File

1
+{
2
+    "swagger": "2.0",
3
+    "info": {
4
+        "title": "sws xcx api doc",
5
+        "description": "圣卫士小程序API接口文档\n",
6
+        "version": "1.0.0",
7
+        "contact": {},
8
+        "license": {
9
+            "name": "领透科技"
10
+        }
11
+    },
12
+    "basePath": "/xcx",
13
+    "paths": {
14
+        "/api/user/getphonenumber": {
15
+            "post": {
16
+                "tags": [
17
+                    "api/user"
18
+                ],
19
+                "description": "获取小程序绑定的手机号码\n\u003cbr\u003e",
20
+                "operationId": "LoginApiController.GetPhoneNumber",
21
+                "parameters": [
22
+                    {
23
+                        "in": "body",
24
+                        "name": "body",
25
+                        "description": "小程序登录请求参数",
26
+                        "required": true,
27
+                        "schema": {
28
+                            "$ref": "#/definitions/models.WxXcxLoginReq"
29
+                        }
30
+                    }
31
+                ],
32
+                "responses": {
33
+                    "200": {
34
+                        "description": "success"
35
+                    },
36
+                    "500": {
37
+                        "description": "error"
38
+                    }
39
+                }
40
+            }
41
+        },
42
+        "/api/user/login": {
43
+            "post": {
44
+                "tags": [
45
+                    "api/user"
46
+                ],
47
+                "description": "微信小程序登录\n\u003cbr\u003e",
48
+                "operationId": "LoginApiController.WxXcxLogin",
49
+                "parameters": [
50
+                    {
51
+                        "in": "body",
52
+                        "name": "body",
53
+                        "description": "小程序登录请求参数",
54
+                        "required": true,
55
+                        "schema": {
56
+                            "$ref": "#/definitions/models.WxXcxLoginReq"
57
+                        }
58
+                    }
59
+                ],
60
+                "responses": {
61
+                    "200": {
62
+                        "description": "",
63
+                        "schema": {
64
+                            "$ref": "#/definitions/models.WxXcxLoginResp"
65
+                        }
66
+                    },
67
+                    "500": {
68
+                        "description": "error"
69
+                    }
70
+                }
71
+            }
72
+        }
73
+    },
74
+    "definitions": {
75
+        "models.WxXcxLoginReq": {
76
+            "title": "WxXcxLoginReq",
77
+            "type": "object",
78
+            "properties": {
79
+                "code": {
80
+                    "type": "string"
81
+                }
82
+            }
83
+        },
84
+        "models.WxXcxLoginResp": {
85
+            "title": "WxXcxLoginResp",
86
+            "type": "object",
87
+            "properties": {
88
+                "openid": {
89
+                    "type": "string"
90
+                },
91
+                "token": {
92
+                    "type": "string"
93
+                }
94
+            }
95
+        }
96
+    }
97
+}

+ 67 - 0
swagger/swagger.yml View File

1
+swagger: "2.0"
2
+info:
3
+  title: sws xcx api doc
4
+  description: |
5
+    圣卫士小程序API接口文档
6
+  version: 1.0.0
7
+  license:
8
+    name: 领透科技
9
+basePath: /xcx
10
+paths:
11
+  /api/user/getphonenumber:
12
+    post:
13
+      tags:
14
+      - api/user
15
+      description: |-
16
+        获取小程序绑定的手机号码
17
+        <br>
18
+      operationId: LoginApiController.GetPhoneNumber
19
+      parameters:
20
+      - in: body
21
+        name: body
22
+        description: 小程序登录请求参数
23
+        required: true
24
+        schema:
25
+          $ref: '#/definitions/models.WxXcxLoginReq'
26
+      responses:
27
+        "200":
28
+          description: success
29
+        "500":
30
+          description: error
31
+  /api/user/login:
32
+    post:
33
+      tags:
34
+      - api/user
35
+      description: |-
36
+        微信小程序登录
37
+        <br>
38
+      operationId: LoginApiController.WxXcxLogin
39
+      parameters:
40
+      - in: body
41
+        name: body
42
+        description: 小程序登录请求参数
43
+        required: true
44
+        schema:
45
+          $ref: '#/definitions/models.WxXcxLoginReq'
46
+      responses:
47
+        "200":
48
+          description: ""
49
+          schema:
50
+            $ref: '#/definitions/models.WxXcxLoginResp'
51
+        "500":
52
+          description: error
53
+definitions:
54
+  models.WxXcxLoginReq:
55
+    title: WxXcxLoginReq
56
+    type: object
57
+    properties:
58
+      code:
59
+        type: string
60
+  models.WxXcxLoginResp:
61
+    title: WxXcxLoginResp
62
+    type: object
63
+    properties:
64
+      openid:
65
+        type: string
66
+      token:
67
+        type: string

+ 395 - 0
sws_xcx.sql View File

1
+-- Active: 1721959927210@@rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com@3306@sws_xcx
2
+CREATE TABLE `xcx_user`(  
3
+  `id` bigint UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'Primary Key ID', 
4
+  `phone` varchar(32)  DEFAULT NULL COMMENT '手机号码',
5
+  `email` varchar(255)  DEFAULT NULL COMMENT '邮件',
6
+  `open_id` varchar(255)  DEFAULT NULL COMMENT 'OpenID',
7
+  `union_id` varchar(255)  DEFAULT NULL COMMENT 'unionid',  
8
+  `nick_name` varchar(64)  DEFAULT NULL COMMENT '昵称',   
9
+  `avatar` varchar(255)  DEFAULT NULL COMMENT '头像',
10
+  `status` int(11) DEFAULT '1' COMMENT '状态(1:有效 0:无效)',  
11
+  `role_type` int(2) DEFAULT NULL COMMENT '角色类型 0或空:普通 1:管理员 2:测试',
12
+  `source` varchar(255)  DEFAULT NULL COMMENT '用户来源',
13
+  `privacy_protocol_versions` int(2) DEFAULT NULL COMMENT '隐私政策版本',
14
+  `ctime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
15
+  `mtime` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间 '
16
+) DEFAULT CHARSET=utf8mb4   COMMENT '小程序用户表';
17
+
18
+CREATE TABLE `user_health_profile`(     
19
+  `id` BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'Primary Key ID', 
20
+  `user_id` BIGINT NOT NULL COMMENT '用户ID',
21
+  `real_name` varchar(64)  DEFAULT NULL COMMENT '真实姓名',
22
+  `id_card` varchar(64)  DEFAULT NULL COMMENT '身份证号',
23
+  `inpatient_reg_phone` VARCHAR(32) DEFAULT NULL COMMENT '住院登记手机号', 
24
+  `gender` int(11) DEFAULT '0' COMMENT '性别(0:未知 1:男 2:女)',
25
+  `height` int(11) DEFAULT NULL COMMENT '身高',
26
+  `weight` int(11) DEFAULT NULL COMMENT '体重',
27
+  `blood_type` varchar(32)  DEFAULT NULL COMMENT '血型',
28
+  `birthday` DATETIME COMMENT '生日',
29
+  `illness_state` varchar(255)  DEFAULT NULL COMMENT '病情',
30
+  `renal_function_status` int  DEFAULT NULL COMMENT '肾功能情况(0:未透析,1:血液透析,2:腹膜透析,3:肾脏移植)',
31
+  `creatinine` int DEFAULT 0 NOT NULL COMMENT '血肌酐',
32
+  `creatinine_unit` varchar(32)  DEFAULT NULL COMMENT '肌酐单位(umol/L,mg/dl)',
33
+  `creatine_time` DATETIME COMMENT '肌酐检测时间',
34
+`urine_protein_24h_unit` varchar(32)  DEFAULT NULL COMMENT '24小时尿蛋白单位(g/24h,mg/24h)',
35
+`urine_protein_24h` INT DEFAULT 0 NOT NULL COMMENT '24小时尿蛋白',
36
+`urine_protein_24h_time` DATETIME COMMENT '24小时尿蛋白检测时间',
37
+`urine_protein` INT DEFAULT 0 NOT NULL COMMENT '尿蛋白',
38
+`urine_protein_unit` varchar(32)  DEFAULT NULL COMMENT '尿蛋白单位(g,mg)',
39
+`urine_protein_time` DATETIME COMMENT '尿蛋白检测时间',
40
+  `status` int(11) DEFAULT'1' COMMENT '状态(1:有效 0:无效)',
41
+  `ctime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
42
+  `mtime` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间 '
43
+) DEFAULT CHARSET=utf8mb4   COMMENT '用户健康档案表';
44
+
45
+CREATE TABLE `device` (
46
+  `id` bigint(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT '设备ID',
47
+  `name` varchar(255)  DEFAULT NULL COMMENT '设备名称',
48
+  `serialno` varchar(64)  DEFAULT NULL COMMENT '设备编号',
49
+  `device_name` varchar(255)  DEFAULT NULL COMMENT '设备名称',
50
+  `device_type` varchar(11)  DEFAULT NULL COMMENT '设备类型',
51
+  `inform_type` int(1) DEFAULT NULL COMMENT '通知类型:0跳转小程序、1跳转网页、默认跳转小程序',
52
+  `mac` varchar(255)  DEFAULT NULL,
53
+  `mcu` varchar(255)  DEFAULT NULL,
54
+  `batch_number` int(10) DEFAULT NULL COMMENT '批号',
55
+  `production_date_number` int(10) DEFAULT NULL COMMENT '生产日期',
56
+  `number` int(10) DEFAULT NULL COMMENT '序号',
57
+  `qr_code_id` bigint(20) DEFAULT NULL,
58
+  `emq_password` varchar(255)  DEFAULT NULL COMMENT 'emq密码',
59
+  `status` int(2) DEFAULT '0' COMMENT '状态(0:未分配 1:已分配 2:包装中 3:待出厂 6:废弃 99:已出厂 100:销售中 101:已售出)',
60
+  `ver` varchar(255)  DEFAULT NULL COMMENT '软件版本',
61
+  `oem_company` int(11) NOT NULL DEFAULT '0' COMMENT '厂商(0:自营  1:艾玛OEM)',
62
+  `mcu_type` varchar(32)  DEFAULT NULL COMMENT 'MCU芯片类型',
63
+  `sensor_mode` varchar(32)  DEFAULT NULL COMMENT '传感放大倍数',
64
+  `language` varchar(32)  DEFAULT NULL COMMENT '语言',
65
+  `paper_check` int(11) DEFAULT NULL COMMENT '试纸检查状态',
66
+  `wifi_ver` varchar(32)  DEFAULT NULL COMMENT 'WIFI版本',
67
+  `ctime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
68
+  `mtime` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间 ',
69
+  `delete_flag` int(11) DEFAULT '0' COMMENT '删除标志'
70
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备表';
71
+
72
+CREATE TABLE `device_relate` (
73
+  `id` bigint(20) NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'id',
74
+  `name` varchar(255)  DEFAULT NULL COMMENT '名称',
75
+  `device_id` bigint DEFAULT NULL COMMENT '设备Id',
76
+  `user_id` bigint DEFAULT NULL COMMENT '会员Id',
77
+  `ctime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
78
+  `mtime` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间 ',
79
+  `delete_flag` int(11) DEFAULT '0' COMMENT '删除标志(解绑时标记为删除)'
80
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4  COMMENT='设备绑定表';
81
+
82
+CREATE TABLE `device_message_log` (
83
+  `id` bigint(20) UNSIGNED NOT NULL  PRIMARY KEY AUTO_INCREMENT,
84
+  `message_id` varchar(255)  DEFAULT NULL,
85
+  `device_name` varchar(255)  DEFAULT NULL,
86
+  `topic` varchar(255)  DEFAULT NULL,
87
+  `event_type` varchar(255)  DEFAULT NULL,
88
+  `content` text COMMENT '消息内容' ,
89
+  `ctime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
90
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4  COMMENT='设备消息日志表';
91
+
92
+CREATE TABLE `check_item` (
93
+  `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT '检测项目ID',
94
+  `check_item_number` int(11) DEFAULT NULL COMMENT '排序',
95
+  `language` varchar(255)  DEFAULT NULL COMMENT 'cn: 中文 en 英文',
96
+  `name_en` varchar(255)  DEFAULT NULL COMMENT '检测项目英文名',
97
+  `name_cn` varchar(255)  DEFAULT NULL COMMENT '检测项目中文名',
98
+  `device_type` varchar(11)  DEFAULT NULL COMMENT '设备类型',
99
+  `check_type` varchar(255)  DEFAULT NULL COMMENT '检测类型(试纸类型)',
100
+  `reference_value` varchar(255)  DEFAULT NULL COMMENT ' 参考值',
101
+  `scope_list` text  COMMENT '范围value 值,type =1为正常、2及以上为异常',
102
+  `text` varchar(255)  DEFAULT NULL COMMENT '文本',
103
+  `details` text  COMMENT '描述',
104
+  `unit` varchar(255)  DEFAULT NULL COMMENT '单位',
105
+  `remark` varchar(255)  DEFAULT NULL COMMENT '备注',
106
+  `ctime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
107
+  `mtime` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间 ',
108
+  `delete_flag` int(11) DEFAULT NULL COMMENT '删除标志'
109
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4  COMMENT='检测项目表';
110
+
111
+
112
+INSERT INTO `check_item` (`id`, `check_item_number`, `language`, `name_en`, `name_cn`, `device_type`, `check_type`, `reference_value`, `scope_list`, `text`, `details`, `unit`, `remark`, `ctime`, `mtime`, `delete_flag`) VALUES
113
+(1, 1, 'cn', 'MAL', '微量白蛋白', '1', NULL, '阴性(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":2,\"value\":\"+\",\"num\":\"0.15\"}]', NULL, '微量蛋白检测是早期发现肾病最敏感,可靠的诊断指标。通过微量白蛋白的数值,结合发病情况、症状以及病史可较为准确的诊断病情。糖尿病患者如有持续的微量白蛋白尿,出现肾病的几率,高于微量白蛋白尿排出量正常者。由于微量白蛋白浓度受饮水、饮食影响较大,一次监测结果升高,不代表身体出现问题。', 'g/L', '尿常规14项', '2019-11-20 16:49:08', '2019-11-20 16:50:24', 0),
114
+(2, 10, 'cn', 'PRO', '蛋白质', '1', NULL, '阴性(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"0.15\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"0.3\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"1\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"3\"}]', NULL, '蛋白质持续显示阳性。有可能是急、慢性肾炎,各种原因引起的肾病综合征,泌尿系感染等。不过,人体在剧烈运动、感冒、精神紧张的情况下,蛋白质也可能显示阳性,所以偶尔显示阳性,不必过于紧张。\r\n', 'g/L', '尿常规14项', '2019-11-20 16:49:10', '2019-11-20 16:50:22', 0),
115
+(3, 3, 'cn', 'CRE', '肌酐', '1', NULL, '阴性(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":2,\"value\":\"+\",\"num\":\"10\"},{\"index\":2,\"type\":3,\"value\":\"++\",\"num\":\"20\"},{\"index\":3,\"type\":4,\"value\":\"+++\",\"num\":\"30\"}]', NULL, '24小时尿肌酐,可辅助诊断临床疾病。如尿蛋白肌酐比值可帮助诊断糖尿病早期肾损害;尿淀粉酶与尿肌酐的比值可以辅助诊断急性胰腺炎。尿肌酐浓度的变异与我们的日常饮食有关,所以需要连续检测。\r\n', 'g/L', '尿常规14项', '2019-11-20 16:49:13', '2019-11-20 16:50:20', 0),
116
+(4, 11, 'cn', 'BLD', '潜血', '1', NULL, '阴性(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"10\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"25\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"80\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"200\"}]', NULL, '潜血持续显示阳性,考虑是病理性尿潜血,也就是泌尿生殖系统疾病,如肾小球肾炎、尿路感染、膀胱结石等。也可能跟剧烈运动、高烧、脱水有关,会自动消失,建议持续监测。\r\n', 'cells/uL', '尿常规14项', '2019-11-20 16:49:16', '2019-11-20 16:50:17', 0),
117
+(5, 2, 'cn', 'CAL', '钙离子', '1', NULL, '阴性(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":2,\"value\":\"+\",\"num\":\"0.15\"},{\"index\":2,\"type\":3,\"value\":\"++\",\"num\":\"0.30\"},{\"index\":3,\"type\":4,\"value\":\"+++\",\"num\":\"0.50\"}]', NULL, '钙离子减少常常与甲状旁腺功能减退、软骨病、粘液性水肿等疾病有关。而甲状旁腺功能亢进、恶性肿瘤骨转移等疾病则会引起钙离子增高。但钙离子值变化很大,钙、蛋白质的摄入和磷的排出都会影响钙的排出,因此需要综合考虑。', 'g/L', '尿常规14项', '2019-11-20 16:49:18', '2019-11-20 16:50:14', 0),
118
+(6, 13, 'cn', 'BIL', '胆红素', '1', NULL, '阴性(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":2,\"value\":\"+\",\"num\":\"17\"},{\"index\":2,\"type\":3,\"value\":\"++\",\"num\":\"50\"},{\"index\":3,\"type\":4,\"value\":\"+++\",\"num\":\"100\"}]', NULL, '胆红素是肝功能的重要指标,也是判断黄疸的主要依据。导致胆红素增高的原因有很多,例如慢性活动性肝炎、肝硬化阻塞性黄疸、肝细胞性黄疸等。这种病理性增高,常有发热、腹痛、呕吐等症状。长期饮酒、剧烈运动等也有可能引起胆红素增高。这种生理性因素引起的胆红素偏高,一般会在调节后自行恢复。', 'umol/L', '尿常规14项', '2019-11-20 16:49:21', '2019-11-20 16:50:12', 0),
119
+(7, 14, 'cn', 'URO', '尿胆原', '1', NULL, ' ±', '[{\"index\":0,\"type\":1,\"value\":\"±\",\"num\":\"3.3\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"16\"},{\"index\":2,\"type\":2,\"value\":\"+\",\"num\":\"33\"},{\"index\":3,\"type\":3,\"value\":\"++\",\"num\":\"66\"},{\"index\":4,\"type\":4,\"value\":\"+++\",\"num\":\"133\"}]', NULL, '尿胆原偏高,要注意是不是肝胆系统有疾病,比如阻塞性黄疸或者黄疸性肝炎。假如其他项目没有异常,仅是尿胆原这一项稍高,很可能是饮水太少或是感冒发烧所造成的,多喝水,多排尿,就可有效改善。', 'umol/L', '尿常规14项', '2019-11-20 16:49:23', '2019-11-20 16:50:10', 0),
120
+(8, 4, 'cn', 'VC', '抗坏血酸', '1', NULL, '阴性(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"0.6\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"1.4\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"2.8\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"5.6\"}]', NULL, '抗坏血酸也就是维生素C,作为强还原剂,可抑制各种尿液成分检测的氧化还原反应。因此当尿液中存在高浓度的抗坏血酸时,一定注意其对尿潜血、葡萄糖、胆红素和亚硝酸盐的干扰作用,可能会造成假阴性结果。应结合其他指标进行连续监测。', 'mmol/L', '尿常规14项', '2019-11-20 16:49:25', '2019-11-20 16:50:08', 0),
121
+(9, 7, 'cn', 'GLU', '葡萄糖', '1', NULL, '阴性(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"5.5\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"14\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"28\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"55\"}]', NULL, '尿液中的葡萄糖持续显示阳性,患糖尿病的可能性较大。不过,检测结果是阳性,并不代表体内血糖一定出现问题。在很多生理情况之下,例如怀孕、一次性大量进食甜食,都有可能出现阳性检测结果。', 'mmol/L', '尿常规14项', '2019-11-20 16:49:29', '2019-11-20 16:50:06', 0),
122
+(10, 12, 'cn', 'KET', '酮体', '1', NULL, '阴性(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"0.5\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"1.5\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"3.9\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"7.8\"}]', NULL, '脂肪出现大量分解的时候,尿液中酮体就会增加,这时候做检测,酮体就会显示阳性。尿酮持续显示阳性或“+”号,常与糖尿病、妊娠、营养不良、慢性疾病有关。本身已患糖尿病的患者,结果是阳性,则表示有酮症酸中毒的可能,应提高警惕,持续监测。', 'mmol/L', '尿常规14项', '2019-11-20 16:49:31', '2019-11-20 16:50:03', 0),
123
+(11, 8, 'cn', 'LEU', '白细胞', '1', NULL, '阴性(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"15\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"70\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"125\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"500\"}]', NULL, '正常尿液中,可有少量白细胞,一般为1~2个。如超过5个白细胞,则表示可能出现了泌尿系感染性疾病。也有可能是肾脏方面出现了问题,例如肾盂肾炎、肾盂积脓、肾结核等。不过服用药品,饮水量少等原因也会使尿液中的白细胞增多。因此,当白细胞为阳性时,也无需惊慌,可先查看自身有无其他症状,如水肿、小便是否正常等,进行综合判断。', 'cells/uL', '尿常规14项', '2019-11-20 16:49:34', '2019-11-20 16:50:00', 0),
124
+(12, 9, 'cn', 'NIT', '亚硝酸盐', '1', NULL, '阴性(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":2,\"value\":\"+\",\"num\":\"18.12\"}]', NULL, '亚硝酸盐检测结果呈阳性:由大肠杆菌引起的肾盂肾炎其阳性率占总数的三分之二以上;或由大肠埃希菌等肠杆菌科等细菌引起的尿路感染、膀胱炎、菌尿症等。', 'umol/L', '尿常规14项', '2019-11-20 16:49:36', '2019-11-20 16:49:58', 0),
125
+(13, 6, 'cn', 'SG', '比重', '1', NULL, '1.010-1.030', '[{\"index\":0,\"type\":1,\"value\":\"1.010\"},{\"index\":1,\"type\":1,\"value\":\"1.020\"},{\"index\":2,\"type\":1,\"value\":\"1.030\"}]', NULL, '尿比重主要取决肾脏的浓缩功能。比重增高的常见原因有急性肾炎、糖尿病、高热、脱水等;比重减低的常见原因为慢性肾炎。不过正常人的尿比重会因饮食、饮水、出汗和排尿等情况的不同,而有较大的波动。因此检查结果与正常数值接近,那就不用过于担心。', NULL, '尿常规14项', '2019-11-20 16:49:38', '2019-11-20 16:49:56', 0),
126
+(14, 5, 'cn', 'PH', 'PH值', '1', NULL, '5.0-7.0', '[{\"index\":0,\"type\":1,\"value\":\"5.0\"},{\"index\":1,\"type\":1,\"value\":\"6.0\"},{\"index\":2,\"type\":1,\"value\":\"7.0\"},{\"index\":3,\"type\":2,\"value\":\"8.0\"},{\"index\":4,\"type\":3,\"value\":\"9.0\"}]', NULL, 'pH值可反映体内酸碱平衡情况和肾脏的调节功能。尿的酸碱度在很大程度上取决于饮食种类、服用的药物及疾病类型。因此我们平时注意饮食健康,辅以适量运动,可使身体的酸碱度处于良好稳定的状态。', '', '尿常规14项', '2019-11-20 16:49:41', '2019-11-20 16:49:49', 0),
127
+(15, 1, 'en', 'MAL', 'Microalbumin', '1', NULL, '(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":2,\"value\":\"+\",\"num\":\"0.15\"}]', NULL, 'Microalbumin detection is the most sensitive and reliable diagnostic indicator for early detection of kidney disease. With the microalbumin value, combined with the incidence, symptoms and medical history, the condition can be more accurately diagnosed. If diabetic patients have persistent microalbuminuria, the chance of developing nephropathy is higher than that of those with normal microalbuminuria excretion. Since the microalbumin concentration is greatly affected by drinking water and diet, an increase in the results of one monitoring does not mean that there is a problem with the body.', 'g/L', 'Urine routine 14 items', '2019-11-20 16:49:08', '2019-11-20 16:50:24', 0),
128
+(16, 10, 'en', 'PRO', 'Protein', '1', NULL, '(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"0.15\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"0.3\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"1\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"3\"}]', NULL, 'If the protein continues to show positive, it may be acute or chronic nephritis, nephrotic syndrome caused by various reasons, urinary tract infection, etc. However, the human body may also show positive in the case of strenuous exercise, colds, and mental stress, so occasionally show positive, don’t be too nervous.', 'g/L', 'Urine routine 14 items', '2019-11-20 16:49:10', '2019-11-20 16:50:22', 0),
129
+(17, 3, 'en', 'CRE', 'Creatinine', '1', NULL, '(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":2,\"value\":\"+\",\"num\":\"10\"},{\"index\":2,\"type\":3,\"value\":\"++\",\"num\":\"20\"},{\"index\":3,\"type\":4,\"value\":\"+++\",\"num\":\"30\"}]', NULL, '24-hour urine creatinine can assist in the diagnosis of clinical diseases. For example, the ratio of urine protein to creatinine can help diagnose early kidney damage in diabetes; the ratio of urine amylase to urine creatinine can assist in the diagnosis of acute pancreatitis. The variability of urine creatinine concentration is related to our daily diet, so continuous testing is required.\r\n', 'g/L', 'Urine routine 14 items', '2019-11-20 16:49:13', '2019-11-20 16:50:20', 0),
130
+(18, 11, 'en', 'BLD', 'Blood', '1', NULL, '(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"10\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"25\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"80\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"200\"}]', NULL, 'Occult blood continues to show positive, which is considered to be pathological urinary occult blood, that is, urogenital diseases, such as glomerulonephritis, urinary tract infection, bladder stones, etc. It may also be related to strenuous exercise, high fever, and dehydration, which will disappear automatically. Continuous monitoring is recommended.', 'cells/uL', 'Urine routine 14 items', '2019-11-20 16:49:16', '2019-11-20 16:50:17', 0),
131
+(19, 2, 'en', 'CAL', 'Calcium ions', '1', NULL, '(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":2,\"value\":\"+\",\"num\":\"0.15\"},{\"index\":2,\"type\":3,\"value\":\"++\",\"num\":\"0.30\"},{\"index\":3,\"type\":4,\"value\":\"+++\",\"num\":\"0.50\"}]', NULL, 'Decreased calcium ions are often related to diseases such as hypoparathyroidism, rickets, and mucinous edema. However, diseases such as hyperparathyroidism and bone metastasis of malignant tumors can cause calcium ions to increase. However, the calcium ion value changes greatly. The intake of calcium and protein and the excretion of phosphorus will affect the excretion of calcium, so comprehensive consideration is required.', 'g/L', 'Urine routine 14 items', '2019-11-20 16:49:18', '2019-11-20 16:50:14', 0),
132
+(20, 13, 'en', 'BIL', 'Bilirubin', '1', NULL, '(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":2,\"value\":\"+\",\"num\":\"17\"},{\"index\":2,\"type\":3,\"value\":\"++\",\"num\":\"50\"},{\"index\":3,\"type\":4,\"value\":\"+++\",\"num\":\"100\"}]', NULL, 'Bilirubin is an important indicator of liver function and the main basis for judging jaundice. There are many reasons for the increase in bilirubin, such as chronic active hepatitis, obstructive jaundice due to cirrhosis, and hepatocellular jaundice. This pathological increase often has symptoms such as fever, abdominal pain, and vomiting. Long-term drinking, strenuous exercise, etc. may also cause increased bilirubin. The high bilirubin caused by this physiological factor usually recovers on its own after adjustment.', 'umol/L', 'Urine routine 14 items', '2019-11-20 16:49:21', '2019-11-20 16:50:12', 0),
133
+(21, 14, 'en', 'URO', 'Urobilinogen', '1', NULL, ' ±', '[{\"index\":0,\"type\":1,\"value\":\"±\",\"num\":\"3.3\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"16\"},{\"index\":2,\"type\":2,\"value\":\"+\",\"num\":\"33\"},{\"index\":3,\"type\":3,\"value\":\"++\",\"num\":\"66\"},{\"index\":4,\"type\":4,\"value\":\"+++\",\"num\":\"133\"}]', NULL, 'If the urobilinogen is high, please pay attention to whether there are diseases of the hepatobiliary system, such as obstructive jaundice or jaundice hepatitis. If there are no abnormalities in other items, but the urobilinogen is slightly higher, it may be caused by too little water or a cold or fever. Drinking more water and urinating more can be effectively improved.', 'umol/L', 'Urine routine 14 items', '2019-11-20 16:49:23', '2019-11-20 16:50:10', 0),
134
+(22, 4, 'en', 'VC', 'Ascorbic Acid', '1', NULL, '(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"0.6\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"1.4\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"2.8\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"5.6\"}]', NULL, 'Ascorbic acid is also vitamin C, as a strong reductant, it can inhibit the oxidation-reduction reaction of various urine components. Therefore, when there is a high concentration of ascorbic acid in urine, you must pay attention to its interference effect on urine blood, glucose, bilirubin and nitrite, which may cause false negative results. Continuous monitoring should be carried out in combination with other indicators.', 'mmol/L', 'Urine routine 14 items', '2019-11-20 16:49:25', '2019-11-20 16:50:08', 0),
135
+(23, 7, 'en', 'GLU', 'Glucose', '1', NULL, '(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"5.5\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"14\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"28\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"55\"}]', NULL, 'If the glucose in the urine continues to show positive, the possibility of diabetes is higher. However, a positive test result does not mean that there must be a problem with blood sugar in the body. In many physiological situations, such as pregnancy or eating a large amount of sweets at one time, positive test results may occur.', 'mmol/L', 'Urine routine 14 items', '2019-11-20 16:49:29', '2019-11-20 16:50:06', 0),
136
+(24, 12, 'en', 'KET', 'Ketone', '1', NULL, '(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"0.5\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"1.5\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"3.9\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"7.8\"}]', NULL, 'When a large amount of fat is broken down, ketone in the urine will increase. At this time, a test will show positive ketone. Urine ketones continue to show positive or \"+\" signs, which are often related to diabetes, pregnancy, malnutrition, and chronic diseases. For patients who have already suffered from diabetes, if the result is positive, it means that there is a possibility of ketoacidosis and should be vigilant and monitored continuously.', 'mmol/L', 'Urine routine 14 items', '2019-11-20 16:49:31', '2019-11-20 16:50:03', 0),
137
+(25, 8, 'en', 'LEU', 'Leukocyte', '1', NULL, '(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":1,\"value\":\"±\",\"num\":\"15\"},{\"index\":2,\"type\":3,\"value\":\"+\",\"num\":\"70\"},{\"index\":3,\"type\":4,\"value\":\"++\",\"num\":\"125\"},{\"index\":4,\"type\":5,\"value\":\"+++\",\"num\":\"500\"}]', NULL, 'In normal urine, there may be a small amount of white blood cells, usually 1 to 2 white blood cells. If there are more than 5 white blood cells, it means that urinary tract infectious diseases may have occurred. It may also be a problem with the kidneys, such as pyelonephritis, pyonephritis,  renal tuberculosis etc. However, taking medicines and drinking less water can also increase the number of white blood cells in the urine. Therefore, when the white blood cells are positive, there is no need to be panic. You can first check whether you have other symptoms, such as edema, urination, etc., to make a comprehensive judgment.', 'cells/uL', 'Urine routine 14 items', '2019-11-20 16:49:34', '2019-11-20 16:50:00', 0),
138
+(26, 9, 'en', 'NIT', 'Nitrite', '1', NULL, '(-)', '[{\"index\":0,\"type\":1,\"value\":\"-\",\"num\":\"0\"},{\"index\":1,\"type\":2,\"value\":\"+\",\"num\":\"18.12\"}]', NULL, 'The nitrite test result is positive: the positive rate of pyelonephritis caused by Escherichia coli accounts for more than two-thirds of the total; or urinary tract infection, cystitis, bacteriuria caused by Enterobacteriaceae such as Escherichia coli Disease and so on.', 'umol/L', 'Urine routine 14 items', '2019-11-20 16:49:36', '2019-11-20 16:49:58', 0),
139
+(27, 6, 'en', 'SG', 'Specific Gravity', '1', NULL, '1.010-1.030', '[{\"index\":0,\"type\":1,\"value\":\"1.010\"},{\"index\":1,\"type\":1,\"value\":\"1.020\"},{\"index\":2,\"type\":1,\"value\":\"1.030\"}]', NULL, 'Urine specific gravity mainly depends on the concentration function of the kidneys. The common reasons for the increase in the proportion are acute nephritis, diabetes, high fever, dehydration, etc.; the common reason for the decrease in the proportion is chronic nephritis. However, the urine specific gravity of normal people will fluctuate greatly due to different conditions such as diet, drinking, sweating and urination. Therefore, no need to worry too much if the result is close to the normal value.', NULL, 'Urine routine 14 items', '2019-11-20 16:49:38', '2019-11-20 16:49:56', 0),
140
+(28, 5, 'en', 'PH', 'pH', '1', NULL, '5.0-7.0', '[{\"index\":0,\"type\":1,\"value\":\"5.0\"},{\"index\":1,\"type\":1,\"value\":\"6.0\"},{\"index\":2,\"type\":1,\"value\":\"7.0\"},{\"index\":3,\"type\":2,\"value\":\"8.0\"},{\"index\":4,\"type\":3,\"value\":\"9.0\"}]', NULL, 'The pH value can reflect the acid-base balance in the body and the regulating function of the kidneys. The pH of urine depends to a large extent on the type of diet, medications taken and the type of disease. Therefore, we need to pay attention to a healthy diet, supplemented by appropriate exercise, to keep the body''s pH in a good and stable state.', '', 'Urine routine 14 items', '2019-11-20 16:49:41', '2019-11-20 16:49:49', 0);
141
+
142
+CREATE TABLE `check_record` (
143
+  `id` bigint(20) NOT NULL PRIMARY KEY COMMENT '检测记录ID',
144
+  `check_type` varchar(255)  DEFAULT NULL COMMENT '检测类型(试纸类型)',
145
+  `put_sources` varchar(255)  DEFAULT NULL COMMENT '上传数据来源',
146
+  `device_id` bigint(20) DEFAULT NULL COMMENT '设备ID',
147
+  `device_status` int(2) DEFAULT NULL COMMENT '设备状态',
148
+  `message_id` varchar(255)  DEFAULT NULL COMMENT '设备消息id',
149
+  `user_id` bigint(20) DEFAULT '0' COMMENT '用户ID',
150
+  `user_health_profile_id` bigint(20) DEFAULT 0 COMMENT '健康档案ID',
151
+  `view` int DEFAULT 0 COMMENT '查看:1(已查看) 0(未查看)',
152
+  `alert_item_ids` varchar(255)  DEFAULT NULL COMMENT '异常项目id (1,2,3)',
153
+  `acc` int(10) DEFAULT NULL COMMENT '设备检测次数',
154
+  `ctime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间 ',
155
+  `mtime` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
156
+  `delete_flag` int(1) DEFAULT '0' COMMENT '删除标志'
157
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='检测记录';
158
+
159
+
160
+CREATE TABLE `check_record_item` (
161
+  `id` bigint(20) NOT NULL PRIMARY KEY AUTO_INCREMENT, 
162
+  `check_id` bigint(20) DEFAULT 0 NOT NULL,
163
+  `check_item_id` int(11) DEFAULT NULL COMMENT '检测项目id',
164
+  `check_value` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '检测结果数值',
165
+  `check_value_index` int(3) DEFAULT NULL COMMENT 'check_item value index',
166
+  `ctime` datetime DEFAULT CURRENT_TIMESTAMP,
167
+  `mtime` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
168
+  `delete_flag` int DEFAULT NULL COMMENT '删除标志'
169
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4  COMMENT='检测记录详情'
170
+
171
+
172
+
173
+CREATE TABLE `sys_dictionary` (
174
+  `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
175
+  `name_en` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
176
+  `name_ch` varchar(2048) COLLATE utf8mb4_bin,
177
+  `type` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
178
+  `parent_id` int(11) DEFAULT NULL,
179
+  `ctime` datetime DEFAULT CURRENT_TIMESTAMP,
180
+  `delete_flag` int NOT NULL DEFAULT 0 COMMENT '删除标志'
181
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4  COMMENT='系统字典表';
182
+
183
+--
184
+-- 转存表中的数据 `c_dictionary`
185
+--
186
+
187
+INSERT INTO `sys_dictionary` (`id`, `name_en`, `name_ch`, `type`, `parent_id`, `ctime`, `delete_flag`) VALUES
188
+(1, 'BODY_STATUS', '身体状态', '0', 0, '2019-11-20 10:06:57', 0),
189
+(2, 'BODY_STATUS', '已怀孕', '1', 1, '2019-11-20 10:09:03', 0),
190
+(3, 'BODY_STATUS', '备孕中', '2', 1, '2019-11-20 10:09:20', 0),
191
+(4, 'BODY_STATUS', '宝宝刚出生', '3', 1, '2019-11-20 10:09:39', 0),
192
+(5, 'BODY_STATUS', '均没有', '4', 1, '2019-11-20 10:10:02', 0),
193
+(6, 'ILLNESS', '疾病', '0', 0, '2019-11-20 10:22:31', 0),
194
+(7, 'ILLNESS', '肾病', '1', 6, '2019-11-20 10:23:17', 0),
195
+(8, 'ILLNESS', '糖尿病', '2', 6, '2019-11-20 10:23:27', 0),
196
+(9, 'ILLNESS', '肝病', '3', 6, '2019-11-20 10:23:35', 0),
197
+(10, 'ILLNESS', '高血压', '4', 6, '2019-11-20 10:23:47', 0),
198
+(11, 'ILLNESS', '心脏病', '5', 6, '2019-11-20 10:24:06', 0),
199
+(12, 'ILLNESS', '均没有', '6', 6, '2019-11-20 10:24:26', 0),
200
+(13, 'DEVICE_TYPE', '设备类型', '0', 0, '2019-11-20 10:25:20', 0),
201
+(15, 'DEVICE_TYPE_ICON_URL', '设备图标', '0', 0, '2019-12-03 09:53:09', 0),
202
+(16, 'DEVICE_TYPE_ICON_URL', 'https://weedev.oss-cn-beijing.aliyuncs.com/chplatform/icon/deviceicon.png\r\n', '1', 15, '2019-12-03 10:02:43', 0),
203
+(17, 'BLOOD_GLUCOSE_TYPE', '血糖类型', '0', 0, '2020-11-19 14:08:17', 0),
204
+(18, 'BLOOD_GLUCOSE_TYPE', '凌晨', '1', 17, '2020-11-19 14:11:46', 0),
205
+(19, 'BLOOD_GLUCOSE_TYPE', '早餐前', '2', 17, '2020-11-19 14:12:08', 0),
206
+(20, 'BLOOD_GLUCOSE_TYPE', '早餐后1小时', '3', 17, '2020-11-19 14:12:08', 0),
207
+(21, 'BLOOD_GLUCOSE_TYPE', '早餐后2小时', '4', 17, '2020-11-19 14:12:08', 0),
208
+(22, 'BLOOD_GLUCOSE_TYPE', '午餐前', '5', 17, '2020-11-19 14:12:08', 0),
209
+(23, 'BLOOD_GLUCOSE_TYPE', '午餐后1小时', '6', 17, '2020-11-19 14:12:08', 0),
210
+(24, 'BLOOD_GLUCOSE_TYPE', '午餐后2小时', '7', 17, '2020-11-19 14:12:08', 0),
211
+(25, 'BLOOD_GLUCOSE_TYPE', '晚餐前', '8', 17, '2020-11-19 14:12:08', 0),
212
+(26, 'BLOOD_GLUCOSE_TYPE', '晚餐后1小时', '9', 17, '2020-11-19 14:12:08', 0),
213
+(27, 'BLOOD_GLUCOSE_TYPE', '睡前', '10', 17, '2020-11-19 14:12:08', 0),
214
+(28, 'INDICATOR_TYPE', '指标类型', '0', 0, '2020-11-25 15:28:37', 0),
215
+(29, 'INDICATOR_TYPE', '睡眠', 'sleep', 28, '2020-11-25 15:28:37', 0),
216
+(30, 'INDICATOR_TYPE', '心跳', 'pulse', 28, '2020-11-25 15:28:37', 0),
217
+(31, 'INDICATOR_TYPE', '体重', 'weight', 28, '2020-11-25 15:30:07', 0),
218
+(32, 'INDICATOR_TYPE', '体温', 'temperature', 28, '2020-11-25 15:30:27', 0),
219
+(33, 'INDICATOR_TYPE', '血压', 'blood_pressure', 28, '2020-11-25 15:30:48', 0),
220
+(34, 'INDICATOR_TYPE', '血糖', 'blood_glucose', 28, '2020-11-25 15:31:11', 0),
221
+(35, 'INDICATOR_TYPE', '病例', 'diseaseCase', 28, '2020-11-25 15:31:27', 0),
222
+(36, 'INDICATOR_TYPE', '处方', 'prescription', 28, '2020-11-25 15:31:45', 0),
223
+(37, 'INDICATOR_TYPE', '化验', 'assay', 28, '2020-11-25 15:32:19', 0),
224
+(49, 'DEVICE_CHANNEL', '渠道', '0', 0, '2020-07-13 15:54:22', 0),
225
+(50, 'DEVICE_CHANNEL', '默认', 'OFFICAL', 49, '2020-07-13 15:54:57', 0),
226
+(51, 'DEVICE_CHANNEL', '华为市场', 'HUAWEI', 49, '2020-07-13 15:55:25', 0),
227
+(52, 'DEVICE_CHANNEL', '小米市场', 'XIAOMI', 49, '2020-07-13 15:55:45', 0),
228
+(53, 'DEVICE_CHANNEL', '苹果市场', 'Apple', 49, '2020-07-13 15:56:07', 0),
229
+(54, 'DEVICE_CHANNEL', '腾讯市场(应用宝)', 'Tencent', 49, '2020-07-13 15:56:37', 0),
230
+(55, 'DEVICE_CHANNEL', 'OPPO市场', 'OPPO', 49, '2020-07-13 15:57:01', 0),
231
+(57, 'PUSH_PLATFORM', '推送平台', '0', 0, '2020-07-20 14:28:01', 0),
232
+(59, 'PUSH_PLATFORM', 'jpush', 'iphone,ipad', 57, '2020-07-20 14:35:37', 0),
233
+(60, 'PUSH_PLATFORM', 'huawei', 'huawei,honor', 57, '2020-07-20 14:36:48', 0),
234
+(61, 'PUSH_PLATFORM', 'xiaomi', 'xiaomi,redmi,blackshark', 57, '2020-07-20 14:39:10', 0),
235
+(62, 'DEVICE_CHANNEL', '百度应用市场', 'BAIDU', 49, '2020-07-21 14:27:51', 0),
236
+(63, 'DEVICE_CHANNEL', '阿里', 'ALI', 49, '2020-07-28 09:12:46', 0),
237
+(64, 'DEVICE_CHANNEL', '360', '360', 49, '2020-07-28 09:13:05', 0),
238
+(65, 'NEWS_TAG', '新闻资讯标签', '0', 0, '2021-01-05 13:15:58', 0),
239
+(72, 'NEWS_H5_URL', '新闻h5页面', '0', 0, '2021-01-22 14:27:57', 0),
240
+(73, 'NEWS_H5_URL', 'chapp-dev.ctrlhealth.com.cn\r\n', '1', 72, '2021-01-22 14:28:27', 0),
241
+(75, 'USER_AGREEMENT', '用户协议', 'https://protocol.ctrlhealth.com.cn/protocol/chapp-useragreement.html', 0, '2020-03-26 10:17:54', 0),
242
+(94, 'child1', '子索引1', '1', 87, '2021-02-23 17:32:51', 0),
243
+(95, 'OSS_IMAGE_CONVERT', '阿里云图片转换', '0', 0, '2021-03-23 19:43:33', 0),
244
+(103, 'OSS_IMAGE_CONVERT', '?x-oss-process=image/resize,w_200/quality,q_50', 'AVATAR', 95, '2021-03-24 15:56:06', 0),
245
+(104, 'OSS_IMAGE_CONVERT', '?x-oss-process=image/resize,w_400/quality,q_50', 'NORMAL', 95, '2021-03-24 15:56:27', 0),
246
+(105, 'OSS_IMAGE_CONVERT', '?x-oss-process=image/resize,w_500/quality,q_60', 'PREVIEW', 95, '2021-03-24 15:56:53', 0),
247
+(106, 'OSS_IMAGE_CONVERT', '?x-oss-process=image/resize,w_768/quality,q_50', 'HD', 95, '2021-03-24 15:57:04', 0),
248
+(108, 'KEY', '?x-oss-process=image/resize,w_768/quality,q_50', 'CHILD', 107, '2021-03-24 15:59:38', 0),
249
+(109, 'KEY', '?x-oss-process=image/resize,w_768/quality,q_50', 'PREVIEW', 107, '2021-03-24 16:24:02', 0),
250
+(120, 'test', 'a', '1', 119, '2021-03-24 16:35:07', 0),
251
+(121, 'test', 'b', '2', 119, '2021-03-24 16:35:14', 0),
252
+(124, 'NCG_NEWS_ID', '尿检知识文章ID', '0', 0, '2021-03-26 08:50:26', 0),
253
+(125, 'NCG_NEWS_ID', '1405927261470752', '1', 124, '2021-03-26 08:50:48', 0),
254
+(127, 'DEVICE_STATUS', '设备状态', '0', 0, '2021-11-30 09:06:15', 0),
255
+(128, 'DEVICE_STATUS', '未分配', '0', 127, '2021-11-30 09:08:13', 0),
256
+(129, 'DEVICE_STATUS', '已分配', '1', 127, '2021-11-30 09:08:21', 0),
257
+(131, 'DEVICE_TYPE', 'CHU100', '1', 13, '2021-11-30 09:13:06', 0),
258
+(132, 'DEVICE_TYPE', 'BW500mini', '2', 13, '2021-11-30 09:13:21', 0),
259
+(133, 'MQTT_CONFIG', 'MQTT配置', '0', 0, '2021-11-30 09:28:22', 0),
260
+(134, 'MQTT_CONFIG', 'ws://mqtt.emq.j6c.cn/mqtt', 'ws_url', 133, '2021-11-30 09:29:02', 0),
261
+(135, 'MQTT_CONFIG', 'wss://emq.j6c.cn:8084/mqtt', 'wss_url', 133, '2021-11-30 09:29:30', 0),
262
+(136, 'MQTT_CONFIG', 'emqx', 'username', 133, '2021-12-01 11:14:56', 0),
263
+(137, 'MQTT_CONFIG', 'public', 'password', 133, '2021-12-01 11:15:04', 0),
264
+(140, 'QRCODE_TYPE', '二维码类型', '0', 0, '2021-12-01 16:18:24', 0),
265
+(141, 'QRCODE_TYPE', 'CH-U100二维码(微信永久)', '0', 140, '2021-12-01 16:19:05', 1),
266
+(142, 'QRCODE_TYPE', 'CH-U100二维码(自有地址)', '1', 140, '2021-12-01 16:19:24', 0),
267
+(143, 'QRCODE_STATUS', '二维码状态', '0', 0, '2021-12-01 16:50:56', 0),
268
+(144, 'QRCODE_STATUS', '可用', '0', 143, '2021-12-01 16:51:02', 0),
269
+(145, 'QRCODE_STATUS', '已绑定', '1', 143, '2021-12-01 16:51:08', 0),
270
+(146, 'PROD_MQTT_INFO', '设备生产环境MQTT配置', '0', 0, '2021-12-02 23:30:58', 0),
271
+(147, 'PROD_MQTT_INFO', '0', 'mqtts', 146, '2021-12-02 23:31:26', 0),
272
+(148, 'PROD_MQTT_INFO', 'emq.ctrlhealth.com.cn', 'mqttHost', 146, '2021-12-02 23:31:46', 0),
273
+(149, 'PROD_MQTT_INFO', '1883', 'port', 146, '2021-12-02 23:31:55', 0),
274
+(150, 'PROD_MQTT_INFO', 'CH-U100', 'productKey', 146, '2021-12-02 23:32:07', 0),
275
+(151, 'PROD_MQTT_INFO', 'http://d.j6c.cn/', 'qrPreData', 146, '2021-12-02 23:35:20', 0),
276
+(152, 'NEWS_TAG_CN', '中文版新闻标签', '0', 0, '2021-12-03 16:49:48', 0),
277
+(153, 'NEWS_TAG_ALL', '全部新闻标签', '0', 0, '2021-12-03 16:59:20', 0),
278
+(154, 'NEWS_TAG_EN', '英文版新闻标签', '0', 0, '2021-12-03 17:02:27', 0),
279
+(155, 'NEWS_TAG_EN', 'FAQ', '22', 154, '2021-12-06 13:43:42', 0),
280
+(156, 'NEWS_TAG_EN', 'Urine Analysis', '21', 154, '2021-12-06 13:43:53', 0),
281
+(169, 'NEWS_TAG_CN', '尿常规检查', '11', 152, '2021-12-06 13:49:41', 0),
282
+(170, 'NEWS_TAG', '首页推荐', '0', 65, '2021-12-06 13:57:36', 0),
283
+(171, 'NEWS_TAG', '热点关注', '1', 65, '2021-12-06 13:57:45', 0),
284
+(172, 'NEWS_TAG', '生活健康', '2', 65, '2021-12-06 13:57:51', 0),
285
+(173, 'NEWS_TAG', '慢病管理', '4', 65, '2021-12-06 13:58:01', 0),
286
+(174, 'NEWS_TAG', '关爱女性', '5', 65, '2021-12-06 13:58:11', 0),
287
+(175, 'NEWS_TAG', '关爱男性', '6', 65, '2021-12-06 13:58:20', 0),
288
+(176, 'NEWS_TAG', '轮播图', '7', 65, '2021-12-06 13:58:32', 0),
289
+(177, 'QRCODE_TYPE_PRE', '设备自有地址前缀', '0', 0, '2021-12-07 17:10:09', 0),
290
+(178, 'QRCODE_TYPE_PRE', 'http://u.j6c.cn/d/', '1', 177, '2021-12-07 17:12:44', 0),
291
+(183, 'NEWS_TAG_INDICATOR_CN', '指标说明', '0', 0, '2021-12-17 15:30:31', 0),
292
+(184, 'NEWS_TAG_INDICATOR_EN', '指标说明英文', '0', 0, '2021-12-17 15:30:53', 0),
293
+(186, 'NEWS_TAG_INDICATOR_CN', '检测项目说明', '32', 183, '2021-12-17 15:33:23', 0),
294
+(187, 'NEWS_TAG_ALL', '首页推荐', '0', 128, '2021-12-06 13:45:09', 0),
295
+(188, 'NEWS_TAG_ALL', '热点关注', '1', 153, '2021-12-06 13:45:26', 0),
296
+(189, 'NEWS_TAG_ALL', '生活健康', '2', 153, '2021-12-06 13:45:38', 0),
297
+(190, 'NEWS_TAG_ALL', '慢病管理', '4', 153, '2021-12-06 13:46:00', 0),
298
+(191, 'NEWS_TAG_ALL', '关爱女性', '5', 153, '2021-12-06 13:46:15', 0),
299
+(192, 'NEWS_TAG_ALL', '关爱男性', '6', 153, '2021-12-06 13:46:26', 0),
300
+(193, 'NEWS_TAG_ALL', '轮播图', '7', 153, '2021-12-06 13:46:38', 0),
301
+(195, 'NEWS_TAG_ALL', '尿常规检查', '11', 153, '2021-12-06 13:47:00', 0),
302
+(196, 'NEWS_TAG_ALL', 'FAQ', '22', 153, '2021-12-06 13:47:39', 0),
303
+(197, 'NEWS_TAG_ALL', 'Urine Analysis', '21', 153, '2021-12-06 13:47:47', 0),
304
+(198, 'NEWS_TAG_ALL', '检测项目说明', '32', 153, '2021-12-17 15:45:51', 0),
305
+(199, 'NEWS_TAG_INDICATOR_EN', 'Test Parameters', '31', 184, '2021-12-17 15:46:23', 0),
306
+(200, 'NEWS_TAG_ALL', 'Test Parameters', '31', 153, '2021-12-17 15:46:35', 0),
307
+(201, 'DEVICE_ADJUST_DEFAULT', '设备校准默认值', '0', 0, '2021-12-24 17:02:51', 0),
308
+(202, 'DEVICE_ADJUST_DEFAULT', '{{\"MAL\",\"微白蛋白\",2,1,0,0,{{950,0,0}}},{\"CA\",\"钙离子\",4,0,0,0,{{1250,0,0},{1350,0,0},{1600,0,0}}},{\"CR\",\"肌酐\",4,1,0,0,{{1150,0,0},{1000,0,0},{950,0,0}}},{\"VC\",\"抗坏血酸\",5,0,0,0,{{0,700,0},{0,1000,0},{0,2000,0},{0,2500,0}}},{\"PH\",\"PH\",5,1,0,0,{{2000,0,0},{1300,0,0},{900,0,0},{800,0,0}}},{\"SG\",\"比重\",3,0,0,0,{{1400,0,0},{1600,0,0}}},{\"GLU\",\"葡萄糖\",5,0,0,1,{{0,0,900},{600,0,0},{700,0,0},{1000,0,0}}},{\"LEU\",\"白细胞\",5,0,0,0,{{0,0,1000},{1200,0,0},{1380,0,0},{1500,0,0}}},{\"NIT\",\"亚硝酸盐\",2,0,0,0,{{1200,0,0}}},{\"PRO\",\"蛋白质\",5,1,0,0,{{1110,0,0},{1050,0,0},{930,0,0},{820,0,0}}},{\"BLD\",\"潜血\",5,1,1,0,{{1900,0,0},{1700,0,0},{1100,0,0},{0,1500,0}}},{\"KET\",\"酮体\",5,0,0,0,{{0,0,900},{1700,0,0},{2300,0,0},{2800,0,0}}},{\"BIL\",\"胆红素\",4,0,0,0,{{1230,0,0},{1500,0,0},{1750,0,0}}},{\"URO\",\"尿胆原\",5,0,0,0,{{1200,0,0},{1350,0,0},{1800,0,0},{2000,0,0}}}}', '20211201', 201, '2021-12-24 17:07:41', 0),
309
+(203, 'NEWS_TAG_ALL', '常见问题', '12', 153, '2021-12-27 14:24:02', 0),
310
+(204, 'NEWS_TAG_CN', '常见问题', '12', 152, '2021-12-27 14:24:12', 0),
311
+(205, 'DEVICE_ADJUST_DEFAULT', '{{\"MAL\",\"微白蛋白\",2,1,0,0,{{950,0,0}}},{\"CA\",\"钙离子\",4,0,0,0,{{1250,0,0},{1350,0,0},{1600,0,0}}},{\"CR\",\"肌酐\",4,1,0,0,{{1050,0,0},{900,0,0},{850,0,0}}},{\"VC\",\"抗坏血酸\",5,0,0,0,{{0,700,0},{0,1000,0},{0,2000,0},{0,2500,0}}},{\"PH\",\"PH\",5,1,0,0,{{2500,0,0},{1300,0,0},{900,0,0},{800,0,0}}},{\"SG\",\"比重\",3,0,0,0,{{1400,0,0},{1800,0,0}}},{\"GLU\",\"葡萄糖\",5,0,0,1,{{0,0,900},{600,0,0},{700,0,0},{1000,0,0}}},{\"LEU\",\"白细胞\",5,0,0,0,{{0,0,1000},{1200,0,0},{1380,0,0},{1550,0,0}}},{\"NIT\",\"亚硝酸盐\",2,0,0,0,{{1200,0,0}}},{\"PRO\",\"蛋白质\",5,1,0,0,{{1110,0,0},{1050,0,0},{930,0,0},{730,0,0}}},{\"BLD\",\"潜血\",5,1,1,0,{{1900,0,0},{1700,0,0},{1100,0,0},{0,1500,0}}},{\"KET\",\"酮体\",5,0,0,0,{{0,0,900},{1700,0,0},{1900,0,0},{4000,0,0}}},{\"BIL\",\"胆红素\",4,0,0,0,{{1230,0,0},{1500,0,0},{1750,0,0}}},{\"URO\",\"尿胆原\",5,0,0,0,{{1200,0,0},{1350,0,0},{1800,0,0},{2000,0,0}}}}', '20211216', 201, '2021-12-28 15:52:32', 0),
312
+(210, 'DEVICE_ADJUST_DEFAULT', '{{\"MAL\",\"微白蛋白\",2,1,0,0,{{885,0,0}}},{\"CA\",\"钙离子\",4,0,0,0,{{1250,0,0},{1350,0,0},{1600,0,0}}},{\"CR\",\"肌酐\",4,1,0,0,{{1050,0,0},{900,0,0},{850,0,0}}},{\"VC\",\"抗坏血酸\",5,0,0,0,{{0,700,0},{0,1000,0},{0,2000,0},{0,2500,0}}},{\"PH\",\"PH\",5,1,0,0,{{4000,0,0},{1300,0,0},{900,0,0},{800,0,0}}},{\"SG\",\"比重\",3,0,0,0,{{1300,0,0},{1800,0,0}}},{\"GLU\",\"葡萄糖\",5,0,0,1,{{0,0,850},{600,0,0},{700,0,0},{1500,0,0}}},{\"LEU\",\"白细胞\",5,0,0,0,{{0,0,1000},{1230,0,0},{1300,0,0},{1600,0,0}}},{\"NIT\",\"亚硝酸盐\",2,0,0,0,{{1380,0,0}}},{\"PRO\",\"蛋白质\",5,1,0,0,{{1110,0,0},{1000,0,0},{900,0,0},{670,0,0}}},{\"BLD\",\"潜血\",5,1,1,0,{{1900,0,0},{1700,0,0},{1100,0,0},{0,1830,0}}},{\"KET\",\"酮体\",5,0,0,0,{{0,0,880},{0,0,910},{0,0,1000},{3600,0,0}}},{\"BIL\",\"胆红素\",4,0,0,0,{{1270,0,0},{1500,0,0},{2900,0,0}}},{\"URO\",\"尿胆原\",5,0,0,0,{{1200,0,0},{1350,0,0},{1800,0,0},{2000,0,0}}}}', '20211229', 201, '2021-12-29 13:37:35', 0),
313
+(211, 'USER_PRIVACY_AGREEMENT_HOMEDI', '用户隐私协议', 'https://protocol.ctrlhealth.com.cn/protocol/homedi-userprivacyagreement.html', 0, '2022-01-04 14:29:15', 0),
314
+(212, 'USER_AGREEMENT_HOMEDI', '用户协议', 'https://protocol.ctrlhealth.com.cn/protocol/homedi-useragreement.html', 0, '2022-01-04 14:48:40', 0),
315
+(213, 'DEVICE_ADJUST_DEFAULT', '{{\"MAL\",\"微白蛋白\",2,1,0,0,{{885,0,0}}},{\"CA\",\"钙离子\",4,0,0,0,{{1250,0,0},{1350,0,0},{1600,0,0}}},{\"CR\",\"肌酐\",4,1,0,0,{{1050,0,0},{900,0,0},{850,0,0}}},{\"VC\",\"抗坏血酸\",5,0,0,0,{{0,700,0},{0,1000,0},{0,2000,0},{0,2500,0}}},{\"PH\",\"PH\",5,1,0,0,{{4000,0,0},{1300,0,0},{900,0,0},{800,0,0}}},{\"SG\",\"比重\",3,0,0,0,{{1300,0,0},{1800,0,0}}},{\"GLU\",\"葡萄糖\",5,0,0,1,{{0,0,850},{600,0,0},{700,0,0},{1500,0,0}}},{\"LEU\",\"白细胞\",5,0,0,0,{{0,0,1000},{1230,0,0},{1300,0,0},{1600,0,0}}},{\"NIT\",\"亚硝酸盐\",2,0,0,0,{{1380,0,0}}},{\"PRO\",\"蛋白质\",5,1,0,0,{{1110,0,0},{1000,0,0},{900,0,0},{670,0,0}}},{\"BLD\",\"潜血\",5,1,1,0,{{0,4200,0},{0,3300,0},{0,2500,0},{0,1750,0}}},{\"KET\",\"酮体\",5,0,0,0,{{0,0,880},{0,0,910},{0,0,1000},{3600,0,0}}},{\"BIL\",\"胆红素\",4,0,0,0,{{1300,0,0},{1500,0,0},{2900,0,0}}},{\"URO\",\"尿胆原\",5,0,0,0,{{1200,0,0},{1350,0,0},{1800,0,0},{2000,0,0}}}}', '20220114', 201, '2022-01-14 14:01:28', 0),
316
+(214, 'DEVICE_STATUS', '已出厂', '99', 127, '2022-01-26 09:08:21', 0),
317
+(215, 'DEVICE_OPERATE_VIDEO_URL', '设备操作视频路径', '0', 0, '2022-02-10 09:18:29', 0),
318
+(216, 'DEVICE_OPERATE_VIDEO_URL', 'https://weedev.oss-cn-beijing.aliyuncs.com/devicedm/homedi.mp4', 'videoUri_zh', 215, '2022-02-10 09:27:11', 0),
319
+(217, 'DEVICE_ADJUST_DEFAULT', '{{\"MAL\",\"微白蛋白\",2,1,0,0,{{820,0,0}}},{\"CA\",\"钙离子\",4,0,0,0,{{1250,0,0},{1350,0,0},{1600,0,0}}},{\"CR\",\"肌酐\",4,1,0,0,{{1050,0,0},{900,0,0},{850,0,0}}},{\"VC\",\"抗坏血酸\",5,0,0,0,{{0,700,0},{0,1000,0},{0,2000,0},{0,2500,0}}},{\"PH\",\"PH\",5,1,0,0,{{4000,0,0},{1300,0,0},{900,0,0},{800,0,0}}},{\"SG\",\"比重\",3,0,0,0,{{1300,0,0},{1800,0,0}}},{\"GLU\",\"葡萄糖\",5,0,0,1,{{0,0,850},{600,0,0},{700,0,0},{1500,0,0}}},{\"LEU\",\"白细胞\",5,0,0,0,{{0,0,1000},{1230,0,0},{1300,0,0},{1600,0,0}}},{\"NIT\",\"亚硝酸盐\",2,0,0,0,{{1380,0,0}}},{\"PRO\",\"蛋白质\",5,1,0,0,{{1080,0,0},{1000,0,0},{900,0,0},{670,0,0}}},{\"BLD\",\"潜血\",5,1,1,0,{{0,4200,0},{0,3300,0},{0,2500,0},{0,1750,0}}},{\"KET\",\"酮体\",5,0,0,0,{{0,0,880},{0,0,910},{0,0,1000},{3600,0,0}}},{\"BIL\",\"胆红素\",4,0,0,0,{{1300,0,0},{1500,0,0},{2900,0,0}}},{\"URO\",\"尿胆原\",5,0,0,0,{{1200,0,0},{1350,0,0},{1800,0,0},{2000,0,0}}}}', '20220117', 201, '2022-02-17 11:57:13', 0),
320
+(218, 'EMQ_APPID_APPSECRET', 'emq密钥', '0', 0, '2022-02-21 14:32:51', 0),
321
+(219, 'EMQ_APPID_APPSECRET', 'KQLAt0rjKyzfFvaEW7YJLQNmOEvIy2nbqwIkCm49BNjE', 'd5b2f5a341063', 218, '2022-02-21 14:33:06', 0),
322
+(220, 'ISSHOW_MALL', '是否显示商城', '0', 0, '2022-02-28 09:06:10', 0),
323
+(221, 'ISSHOW_MALL', '1', 'mall', 220, '2022-02-28 09:23:09', 0),
324
+(222, 'ISSHOW_MALL', 'wx2fdff7c62c892e89', 'appId_mini', 220, '2022-03-01 10:26:15', 0),
325
+(223, 'ISSHOW_MALL', 'http://0lk.cn/j/4KBCie2', 'universalLink_bb', 220, '2022-03-01 10:26:36', 0),
326
+(224, 'ISSHOW_MALL', 'gh_2412a38d6924', 'username', 220, '2022-03-01 10:26:57', 0),
327
+(225, 'ISSHOW_MALL', 'pages/product/product?id=1', 'path', 220, '2022-03-01 10:27:15', 0),
328
+(226, 'DEVICE_OPERATE_VIDEO_URL', '1', 'isShowVideo', 215, '2022-03-04 17:10:16', 0),
329
+(227, 'ISSHOW_MALL', '1', 'productId', 220, '2022-03-29 13:09:45', 0),
330
+(228, 'MQTT_INFO', '0', '0', 0, '2022-05-09 14:56:49', 0),
331
+(229, 'MQTT_INFO', 'mqttHost', 'emq.ctrlhealth.com.cn', 228, '2022-05-09 14:57:13', 0),
332
+(230, 'MQTT_INFO', 'mqttPort', '1883', 228, '2022-05-09 14:58:07', 0),
333
+(231, 'MQTT_INFO', 'mqtts', '0', 228, '2022-05-09 14:58:17', 0),
334
+(232, 'MQTT_INFO', 'username', 'emqx', 228, '2022-05-09 14:58:28', 0),
335
+(233, 'MQTT_INFO', 'password', 'public', 228, '2022-05-09 14:58:38', 0),
336
+(234, 'MQTT_INFO', 'topic_newexam', '/homedi/user/#userId#/newexam', 228, '2022-05-09 14:59:23', 0),
337
+(235, 'EMQ_APP_INFO', '0', '0', 0, '2022-05-09 14:59:30', 0),
338
+(236, 'EMQ_APP_INFO', 'emqHost', 'http://emqx:8081', 235, '2022-05-09 15:00:05', 0),
339
+(237, 'EMQ_APP_INFO', 'appId', 'd5b2f5a341063', 235, '2022-05-09 15:00:16', 0),
340
+(238, 'EMQ_APP_INFO', 'secret', 'MzAzNTI0NTg1MTY0OTkxMjk0MTMxODUwMTIzNjU1MjQ5OTC', 235, '2022-05-09 15:00:24', 0),
341
+(239, 'EMQ_APP_INFO', 'topic_newexam', '/homedi/user/#userId#/newexam', 235, '2022-05-09 15:00:54', 0),
342
+(241, 'USER_PRIVACY_AGREEMENT', '用户隐私协议', 'https://protocol.ctrlhealth.com.cn/protocol/chapp-userprivacyagreement.html', 0, '2022-05-19 10:44:22', 0),
343
+(242, 'ISSHOW_MALL', 'https://j6clw0.xinstall.com.cn/tolink/', 'universalLink', 220, '2022-03-01 10:26:36', 0),
344
+(243, 'ISSHOW_MALL', 'wxe5d7e54f8b1e22c5', 'appId', 220, '2022-03-01 10:26:15', 0),
345
+(244, 'ISSHOW_MALL', 'gh_ec7e3e6719c6', 'username_bk', 220, '2022-03-01 10:26:57', 0),
346
+(245, 'ISSHOW_MALL', 'product/productDetail/productDetail?id=955&detailType=1', 'path_bk', 220, '2022-03-01 10:27:15', 0),
347
+(247, 'DEVICE_STATUS', '设备号已废弃', '6', 127, '2022-06-23 09:08:21', 0),
348
+(248, 'PUSH_PLATFORM', 'oppo', 'oppo', 57, '2022-06-29 14:25:01', 0),
349
+(249, 'SWITCH_TYPES', '功能开关', '0', 0, '2022-11-10 18:00:41', 0),
350
+(250, 'SWITCH_TYPES', '功能开关', 'commentOpen', 249, '2022-11-10 18:00:41', 0),
351
+(251, 'ISSHOW_MALL', '1', 'mall_app', 220, '2022-02-28 09:23:09', 0),
352
+(252, 'NEWS_TAG_ALL', '活动通知', '33', 153, '2023-05-22 10:17:09', 0),
353
+(253, 'NEWS_TAG_ALL', '健康资讯', '34', 153, '2023-05-22 10:17:30', 0),
354
+(254, 'ISSHOW_MALL', '2', 'rent_category_id', 220, '2023-06-06 13:11:55', 0),
355
+(255, 'OEM_COMPANY', 'OEM企业名称', '0', 0, '2024-03-15 08:00:41', 0),
356
+(256, 'OEM_COMPANY', '自营', '0', 255, '2024-03-15 08:00:41', 0),
357
+(257, 'OEM_COMPANY', '河南艾玛(益宝健康)', '1', 255, '2024-03-15 08:00:41', 0),
358
+(258, 'ISSHOW_MALL', '/pages/healthshop/healthshop?cid=2', 'shop_link', 220, '2022-03-29 13:09:45', 0),
359
+(259, 'ISSHOW_MALL', '购买设备和试纸', 'shop_subtitle', 220, '2022-03-29 13:09:45', 0),
360
+(260, 'ISSHOW_MALL', '9', 'position', 220, '2022-03-29 13:09:45', 0),
361
+(261, 'ISSHOW_MALL', '设备可租赁啦!', 'shop_prompts', 220, '2022-03-29 13:09:45', 0),
362
+(262, 'NEWS_TAG_ALL', '操作手册', '1001', 153, '2024-04-17 10:07:57', 0),
363
+(263, 'MANUAL_PAGES', '操作手册页面', '0', 0, '2024-04-17 11:19:47', 0),
364
+(264, 'MANUAL_PAGES', '1607750517784611', '1', 263, '2024-04-17 11:20:34', 0),
365
+(265, 'MANUAL_PAGES', '1607758304509987', '2', 263, '2024-04-17 11:20:47', 0),
366
+(266, 'MANUAL_PAGES', '1607758562459683', '3', 263, '2024-04-17 11:20:55', 0),
367
+(267, 'MANUAL_PAGES', '1607758713454627', '4', 263, '2024-04-17 11:21:04', 0),
368
+(268, 'RENT_FLOW_PAGES', '租赁流程说明页面', '0', 0, '2024-04-19 15:01:28', 0),
369
+(269, 'RENT_FLOW_PAGES', '{\"newsId\": 1608150820061219, \"title\":\"申请归还\", \"actions\": [\n{\"text\": \"我再想想\", \"action\": \"cancel\", \"class\": \"cancel\"},\n{\"text\": \"申请归还\",\"action\": \"confirm\", \"class\": \"confirm\", \"message\": \"确认申请归还吗?申请后请尽快安排寄回到归还地址\"}\n]}', 'return', 268, '2024-04-19 15:02:12', 0),
370
+(270, 'NEWS_TAG_ALL', '租用流程', '1002', 153, '2024-04-19 15:06:40', 0),
371
+(271, 'RENT_FLOW_PAGES', '	\n{\"newsId\": 1608155064696867, \"title\":\"家佳诊尿液分析仪租赁协议\", \"actions\": [ {\"text\": \"我再想想\", \"action\": \"cancel\", \"class\": \"cancel\"}, {\"text\": \"同意协议并支付\",\"action\": \"confirm\", \"class\": \"confirm\", \"message\": \"同意租赁协议并支付\"} ]}', 'protocol', 268, '2024-04-23 11:21:49', 0),
372
+(272, 'ISSHOW_MALL', '1', 'paper_product_id', 220, '2024-04-24 15:46:51', 0),
373
+(273, 'ISSHOW_HEALTHMANAGE', '是否显示健康管理', '0', 0, '2024-05-10 18:08:11', 0),
374
+(274, 'ISSHOW_HEALTHMANAGE', '1', 'healthmanage', 273, '2024-05-10 18:10:04', 0),
375
+(275, 'MINI_SUBMSG_TEMPLATES', '小程序订阅消息模板ID', '0', 0, '2024-05-15 10:52:48', 0),
376
+(276, 'MINI_SUBMSG_TEMPLATES', 'CuK8a_c6FHSANTFGowSOmKLOtfiu2k_qTVopU1uxkl4', 'use_device', 275, '2024-05-15 10:59:34', 0),
377
+(277, 'MINI_SUBMSG_TEMPLATES', 'QyDGD2wBOxu1n1pUKalmzmW-r16X1s8L0akYl_nfm6w', 'device_bind', 275, '2024-05-15 10:59:54', 0),
378
+(278, 'MINI_SUBMSG_TEMPLATES', 'HM1eLqhLOaz5XqCxe8xqdOyJd_avsFfpnTdUuKsLTcs', 'rent_start', 275, '2024-05-15 11:00:13', 0),
379
+(279, 'MALL_TOP_AD', '商城头部广告', '0', 0, '2024-05-17 18:26:55', 0),
380
+(280, 'MALL_TOP_AD', 'MALL_TOP_AD_1', 'have_device', 279, '2024-05-17 18:27:20', 0),
381
+(281, 'MALL_TOP_AD', 'MALL_TOP_AD_2', 'no_login', 279, '2024-05-17 18:27:36', 0),
382
+(282, 'DEFAULT_MINIPRO_AD', '小程序默认弹窗广告(一般不用)', '0', 0, '2024-05-20 10:47:34', 0),
383
+(283, 'ISSHOW_MALL_ADVERTISE', 'HAVE_DEVICE_AD', 'haveDevice', 282, '2024-05-20 10:50:43', 0),
384
+(284, 'ISSHOW_MALL_ADVERTISE', 'NO_HAVE_DEVICE_AD', 'noHaveDevice', 282, '2024-05-20 10:52:36', 0),
385
+(285, 'ISSHOW_MALL_ADVERTISE', 'NOT_LOGIN_AD', 'notLogin', 282, '2024-05-20 10:53:18', 0),
386
+(286, 'INDEX_POPUP_AD', '首页弹窗', '0', 0, '2024-05-20 18:17:02', 0),
387
+(287, 'INDEX_POPUP_AD', 'HAVE_DEVICE_AD', 'haveDevice', 286, '2024-05-20 18:17:17', 0),
388
+(288, 'AD_MAX_TIMESs', '广告每日最大展示次数', '0', 0, '2024-05-21 11:47:21', 0),
389
+(289, 's', '2', 'INDEX_POP_AD', 288, '2024-05-21 11:47:36', 0),
390
+(290, 's', '3', 'default', 288, '2024-05-21 11:47:43', 0),
391
+(291, 'PRODUCT_POPUP_AD_X', '产品详情页弹窗广告(X替换为产品ID)', '0', 0, '2024-05-24 09:43:21', 0),
392
+(292, 'MALL_POPUP_AD_X', '商城页弹窗广告(X替换为商品分类ID)', '0', 0, '2024-05-24 09:45:03', 0),
393
+(293, 'HOMEDI_WX_ADS', '小程序流量主广告(家家诊Homedi)', '0', 0, '2024-05-27 11:53:42', 0),
394
+(294, 'HOMEDI_WX_ADS', '{\"type\": \"banner\", \"adId\":\"adunit-0d38733a08aa4947\"}', 'netconfig-bottom', 293, '2024-05-27 11:54:05', 0);
395
+

+ 59 - 0
tests/default_test.go View File

1
+package test
2
+
3
+import (
4
+	"path/filepath"
5
+	"runtime"
6
+	_ "sws_xcx/routers"
7
+	"sws_xcx/service"
8
+	"testing"
9
+
10
+	//beego "github.com/beego/beego/v2/server/web"
11
+	//"github.com/beego/beego/v2/core/logs"
12
+	"github.com/astaxie/beego"
13
+	"github.com/medivhzhan/weapp/v3/auth"
14
+	// "github.com/smartystreets/goconvey/convey"
15
+)
16
+
17
+func init() {
18
+	_, file, _, _ := runtime.Caller(0)
19
+	apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
20
+	beego.TestBeegoInit(apppath)
21
+}
22
+
23
+// TestGet is a sample to run an endpoint test
24
+func TestGet(t *testing.T) {
25
+	// r, _ := http.NewRequest("GET", "/v1/object", nil)
26
+	// w := httptest.NewRecorder()
27
+	// beego.BeeApp.Handlers.ServeHTTP(w, r)
28
+
29
+	// logs.Info("testing", "TestGet", "Code[%d]\n%s", w.Code, w.Body.String())
30
+
31
+	// Convey("Subject: Test Station Endpoint\n", t, func() {
32
+	//         Convey("Status Code Should Be 200", func() {
33
+	//                 So(w.Code, ShouldEqual, 200)
34
+	//         })
35
+	//         Convey("The Result Should Not Be Empty", func() {
36
+	//                 So(w.Body.Len(), ShouldBeGreaterThan, 0)
37
+	//         })
38
+	// })
39
+}
40
+
41
+func TestWxappSessionCode(t *testing.T) {
42
+
43
+	sdk := service.GetWxSdk()
44
+	wxcli := sdk.NewAuth()
45
+
46
+	code := "0d3eVp100qtUES1jgD300t5yN21eVp1t"
47
+
48
+	resp, err := wxcli.Code2Session(&auth.Code2SessionRequest{JsCode: code, GrantType: "authorization_code", Appid: beego.AppConfig.String("appid"), Secret: beego.AppConfig.String("appsecret")})
49
+	if err != nil {
50
+		t.Error(err)
51
+		return
52
+	}
53
+	if resp.CommonError.ErrCode != 0 {
54
+		t.Errorf("err code:%v msg:%v", resp.CommonError.ErrCode, resp.CommonError.ErrMSG)
55
+		return
56
+	}
57
+	t.Logf("resp: %+v", *resp)
58
+
59
+}

+ 18 - 0
tests/gendb_test.go View File

1
+package test
2
+
3
+import (
4
+	"sws_xcx/service"
5
+	"testing"
6
+)
7
+
8
+func init() {
9
+	service.ConnectDB()
10
+}
11
+
12
+func TestGenDb(t *testing.T) {
13
+	db := service.ReadDB()
14
+	err := db.DB().Ping()
15
+	if err != nil {
16
+		t.Error(err)
17
+	}
18
+}

+ 13 - 0
utils/ip_helper.go View File

1
+package utils
2
+
3
+import (
4
+	"net/http"
5
+)
6
+
7
+func GetIP(r *http.Request) string {
8
+	ip := r.Header.Get("X-Forwarded-For")
9
+	if ip == "" {
10
+		ip = r.RemoteAddr
11
+	}
12
+	return ip
13
+}

+ 66 - 0
utils/log.go View File

1
+package utils
2
+
3
+import (
4
+	"fmt"
5
+	"time"
6
+)
7
+
8
+const (
9
+	color_red = uint8(iota + 91)
10
+	color_green
11
+	color_yellow
12
+	color_blue
13
+	color_magenta //洋红
14
+
15
+	// info = "[INFO]"
16
+	// trac = "[TRAC]"
17
+	// erro = "[ERRO]"
18
+	// warn = "[WARN]"
19
+	// succ = "[SUCC]"
20
+)
21
+
22
+// 根据 https://github.com/liyu4/chill 修改的
23
+// see complete color rules in document in https://en.wikipedia.org/wiki/ANSI_escape_code#cite_note-ecma48-13
24
+func TraceLog(format string, a ...interface{}) {
25
+	fmt.Println(formatLog(yellow(fmt.Sprintf(format, a...))))
26
+}
27
+
28
+func InfoLog(format string, a ...interface{}) {
29
+	fmt.Println(formatLog(blue(fmt.Sprintf(format, a...))))
30
+}
31
+
32
+func SuccessLog(format string, a ...interface{}) {
33
+	fmt.Println(formatLog(green(fmt.Sprintf(format, a...))))
34
+}
35
+
36
+func WarningLog(format string, a ...interface{}) {
37
+	fmt.Println(formatLog(magenta(fmt.Sprintf(format, a...))))
38
+}
39
+
40
+func ErrorLog(format string, a ...interface{}) {
41
+	fmt.Println(formatLog(red(fmt.Sprintf(format, a...))))
42
+}
43
+
44
+func red(s string) string {
45
+	return fmt.Sprintf("\x1b[%dm%s\x1b[0m", color_red, s)
46
+}
47
+
48
+func green(s string) string {
49
+	return fmt.Sprintf("\x1b[%dm%s\x1b[0m", color_green, s)
50
+}
51
+
52
+func yellow(s string) string {
53
+	return fmt.Sprintf("\x1b[%dm%s\x1b[0m", color_yellow, s)
54
+}
55
+
56
+func blue(s string) string {
57
+	return fmt.Sprintf("\x1b[%dm%s\x1b[0m", color_blue, s)
58
+}
59
+
60
+func magenta(s string) string {
61
+	return fmt.Sprintf("\x1b[%dm%s\x1b[0m", color_magenta, s)
62
+}
63
+
64
+func formatLog(prefix string) string {
65
+	return time.Now().Format("[2006/01/02 15:04:05]") + " " + prefix + " "
66
+}

+ 11 - 0
utils/login_token.go View File

1
+package utils
2
+
3
+import (
4
+	"strings"
5
+	"time"
6
+)
7
+
8
+func GenerateLoginToken(account string) string {
9
+	nowStr := time.Now().Format("20060102150405")
10
+	return strings.Join([]string{nowStr, RandomString(10), account}, "")
11
+}

+ 191 - 0
utils/paginator.go View File

1
+// Copyright 2013 wetalk authors
2
+//
3
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
4
+// not use this file except in compliance with the License. You may obtain
5
+// a copy of the License at
6
+//
7
+//     http://www.apache.org/licenses/LICENSE-2.0
8
+//
9
+// Unless required by applicable law or agreed to in writing, software
10
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+// License for the specific language governing permissions and limitations
13
+// under the License.
14
+
15
+package utils
16
+
17
+import (
18
+	"math"
19
+	"net/http"
20
+	"net/url"
21
+	"strconv"
22
+)
23
+
24
+type Paginator struct {
25
+	Request     *http.Request
26
+	PerPageNums int
27
+	MaxPages    int
28
+
29
+	nums      int64
30
+	pageRange []int
31
+	pageNums  int
32
+	page      int
33
+}
34
+
35
+func (p *Paginator) PageNums() int {
36
+	if p.pageNums != 0 {
37
+		return p.pageNums
38
+	}
39
+	pageNums := math.Ceil(float64(p.nums) / float64(p.PerPageNums))
40
+	if p.MaxPages > 0 {
41
+		pageNums = math.Min(pageNums, float64(p.MaxPages))
42
+	}
43
+	p.pageNums = int(pageNums)
44
+	return p.pageNums
45
+}
46
+
47
+func (p *Paginator) Nums() int64 {
48
+	return p.nums
49
+}
50
+
51
+func (p *Paginator) SetNums(nums int64) {
52
+	p.nums = nums
53
+}
54
+
55
+func (p *Paginator) Page() int {
56
+	if p.page != 0 {
57
+		return p.page
58
+	}
59
+	if p.Request.Form == nil {
60
+		p.Request.ParseForm()
61
+	}
62
+	p.page, _ = strconv.Atoi(p.Request.Form.Get("page"))
63
+	if p.page > p.PageNums() {
64
+		p.page = p.PageNums()
65
+	}
66
+	if p.page <= 0 {
67
+		p.page = 1
68
+	}
69
+	return p.page
70
+}
71
+
72
+func (p *Paginator) Pages() []int {
73
+	if p.pageRange == nil && p.nums > 0 {
74
+		var pages []int
75
+		pageNums := p.PageNums()
76
+		page := p.Page()
77
+		switch {
78
+		case page >= pageNums-4 && pageNums > 9:
79
+			start := pageNums - 9 + 1
80
+			pages = make([]int, 9)
81
+			for i, _ := range pages {
82
+				pages[i] = start + i
83
+			}
84
+		case page >= 5 && pageNums > 9:
85
+			start := page - 5 + 1
86
+			pages = make([]int, int(math.Min(9, float64(page+4+1))))
87
+			for i, _ := range pages {
88
+				pages[i] = start + i
89
+			}
90
+		default:
91
+			pages = make([]int, int(math.Min(9, float64(pageNums))))
92
+			for i, _ := range pages {
93
+				pages[i] = i + 1
94
+			}
95
+		}
96
+		p.pageRange = pages
97
+	}
98
+	return p.pageRange
99
+}
100
+
101
+func (p *Paginator) PageLink(page int) string {
102
+	link, _ := url.ParseRequestURI(p.Request.RequestURI)
103
+	values := link.Query()
104
+	if page == 1 {
105
+		values.Del("page")
106
+	} else {
107
+		values.Set("page", strconv.Itoa(page))
108
+	}
109
+	link.RawQuery = values.Encode()
110
+	return link.String()
111
+}
112
+
113
+func (p *Paginator) PageParams() url.Values {
114
+	link, _ := url.ParseRequestURI(p.Request.RequestURI)
115
+	values := link.Query()
116
+	values.Del("page")
117
+	return values
118
+}
119
+
120
+func (p *Paginator) BasePageLink() string {
121
+	link, _ := url.ParseRequestURI(p.Request.RequestURI)
122
+	values := link.Query()
123
+	values.Del("page")
124
+	link.RawQuery = values.Encode()
125
+	return link.String()
126
+}
127
+
128
+func (p *Paginator) PageLinkPrev() (link string) {
129
+	if p.HasPrev() {
130
+		link = p.PageLink(p.Page() - 1)
131
+	}
132
+	return
133
+}
134
+
135
+func (p *Paginator) PageLinkNext() (link string) {
136
+	if p.HasNext() {
137
+		link = p.PageLink(p.Page() + 1)
138
+	}
139
+	return
140
+}
141
+
142
+func (p *Paginator) PageLinkFirst() (link string) {
143
+	return p.PageLink(1)
144
+}
145
+
146
+func (p *Paginator) PageLinkLast() (link string) {
147
+	return p.PageLink(p.PageNums())
148
+}
149
+
150
+func (p *Paginator) HasPrev() bool {
151
+	return p.Page() > 1
152
+}
153
+
154
+func (p *Paginator) HasNext() bool {
155
+	return p.Page() < p.PageNums()
156
+}
157
+
158
+func (p *Paginator) IsActive(page int) bool {
159
+	return p.Page() == page
160
+}
161
+
162
+func (p *Paginator) Offset() int {
163
+	return (p.Page() - 1) * p.PerPageNums
164
+}
165
+
166
+func (p *Paginator) HasPages() bool {
167
+	return p.PageNums() > 1
168
+}
169
+
170
+func (p *Paginator) Total() int {
171
+	return p.PageNums()
172
+}
173
+func (p *Paginator) TotalSubOne() int {
174
+	return p.PageNums() - 1
175
+}
176
+
177
+func NewPaginator(req *http.Request, per int, nums int64) *Paginator {
178
+	p := Paginator{}
179
+	p.Request = req
180
+	if per <= 0 {
181
+		per = 10
182
+	}
183
+	p.PerPageNums = per
184
+	p.SetNums(nums)
185
+	return &p
186
+}
187
+
188
+func FakePaginator(currentPage int, per int, nums int64) *Paginator {
189
+	fakeReq, _ := http.NewRequest("GET", "/?page="+strconv.Itoa(currentPage), nil)
190
+	return NewPaginator(fakeReq, per, nums)
191
+}

+ 96 - 0
utils/regex_helper.go View File

1
+package utils
2
+
3
+import (
4
+	"fmt"
5
+	"regexp"
6
+	"strings"
7
+)
8
+
9
+// 正整数正则
10
+func PositiveIntegerRegexp() *regexp.Regexp {
11
+	reg, _ := regexp.Compile("^[1-9][0-9]*$")
12
+	return reg
13
+}
14
+
15
+// 手机号正则 不那么严谨的
16
+func CellPhoneRegexp() *regexp.Regexp {
17
+	reg, _ := regexp.Compile("^1\\d{10}$")
18
+	return reg
19
+}
20
+
21
+// 固话正则
22
+func TelPhoneRegexp() *regexp.Regexp {
23
+	// reg, _ := regexp.Compile("^0\\d{2,3}-?\\d{7,8}$")
24
+	reg, _ := regexp.Compile("^0\\d{2,3}-?\\d{7,8}$")
25
+	return reg
26
+}
27
+
28
+// 手机号或固话正则
29
+func PhoneRegexp() *regexp.Regexp {
30
+	reg, _ := regexp.Compile("^(0\\d{2,3}-?\\d{7,8}$)|(1\\d{10}$)")
31
+	return reg
32
+}
33
+
34
+// tests
35
+func PositiveIntegerRegexpTest() {
36
+	reg := PositiveIntegerRegexp()
37
+	fmt.Println("12 是否匹配:", reg.MatchString("12"))
38
+	fmt.Println("1 是否匹配:", reg.MatchString("1"))
39
+	fmt.Println("980030 是否匹配:", reg.MatchString("980030"))
40
+	fmt.Println("01 是否匹配:", reg.MatchString("01"))
41
+	fmt.Println("asd1asd 是否匹配:", reg.MatchString("asd1asd"))
42
+	fmt.Println("a12 是否匹配:", reg.MatchString("a12"))
43
+	fmt.Println("12a 是否匹配:", reg.MatchString("12a"))
44
+	fmt.Println("-12 是否匹配:", reg.MatchString("-12"))
45
+	fmt.Println("12.1 是否匹配:", reg.MatchString("12.1"))
46
+	fmt.Println("14j2a 是否匹配:", reg.MatchString("14j2a"))
47
+}
48
+
49
+func CellPhoneRegexpTest() {
50
+	reg := CellPhoneRegexp()
51
+	fmt.Println("13632250447 是否匹配:", reg.MatchString("13632250447"))
52
+	fmt.Println("12000000000 是否匹配:", reg.MatchString("12000000000"))
53
+	fmt.Println("30001212325 是否匹配:", reg.MatchString("30001212325"))
54
+	fmt.Println("1233123 是否匹配:", reg.MatchString("1233123"))
55
+	fmt.Println("123312312344 是否匹配:", reg.MatchString("123312312344"))
56
+	fmt.Println("13345678a12 是否匹配:", reg.MatchString("13345678a12"))
57
+	fmt.Println("a13345678a1 是否匹配:", reg.MatchString("a13345678a1"))
58
+	fmt.Println("1334a678a12 是否匹配:", reg.MatchString("1334a678a12"))
59
+	fmt.Println("1345678a12a 是否匹配:", reg.MatchString("1345678a12a"))
60
+	fmt.Println("aqwertyuioo 是否匹配:", reg.MatchString("aqwertyuioo"))
61
+}
62
+
63
+func TelPhoneRegexpTest() {
64
+	reg := TelPhoneRegexp()
65
+	fmt.Println("020-39006917 是否匹配:", reg.MatchString("020-39006917"))
66
+	fmt.Println("02039006917 是否匹配:", reg.MatchString("02039006917"))
67
+	fmt.Println("0754-5916612 是否匹配:", reg.MatchString("0754-5916612"))
68
+	fmt.Println("07545916612 是否匹配:", reg.MatchString("07545916612"))
69
+	fmt.Println("123-39006917 是否匹配:", reg.MatchString("123-39006917"))
70
+	fmt.Println("1754-5916612 是否匹配:", reg.MatchString("1754-5916612"))
71
+	fmt.Println("0a0-39006917 是否匹配:", reg.MatchString("0a0-39006917"))
72
+	fmt.Println("0a039006917 是否匹配:", reg.MatchString("0a039006917"))
73
+	fmt.Println("010-39s06917 是否匹配:", reg.MatchString("010-39s06917"))
74
+	fmt.Println("020-390069171 是否匹配:", reg.MatchString("020-390069171"))
75
+	fmt.Println("020-3900691 是否匹配:", reg.MatchString("020-3900691"))
76
+}
77
+
78
+var (
79
+	coefficient []int32 = []int32{7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2}
80
+	code        []byte  = []byte{'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'}
81
+)
82
+
83
+// 校验一个身份证是否是合法的身份证
84
+func Verification(idCardNo string) bool {
85
+	if len(idCardNo) != 18 {
86
+		return false
87
+	}
88
+
89
+	idByte := []byte(strings.ToUpper(idCardNo))
90
+
91
+	sum := int32(0)
92
+	for i := 0; i < 17; i++ {
93
+		sum += int32(byte(idByte[i])-byte('0')) * coefficient[i]
94
+	}
95
+	return code[sum%11] == idByte[17]
96
+}

+ 115 - 0
utils/stringtool.go View File

1
+package utils
2
+
3
+import (
4
+	"bytes"
5
+	"crypto/aes"
6
+	"crypto/cipher"
7
+	"crypto/md5"
8
+	"encoding/base64"
9
+	"fmt"
10
+	"math/rand"
11
+	"strconv"
12
+	"strings"
13
+	"time"
14
+
15
+	"github.com/astaxie/beego"
16
+)
17
+
18
+// 将字符串加密成 md5
19
+func String2md5(str string) string {
20
+	data := []byte(str)
21
+	has := md5.Sum(data)
22
+	return fmt.Sprintf("%x", has) //将[]byte转成16进制
23
+}
24
+
25
+// RandomString 在数字、大写字母、小写字母范围内生成num位的随机字符串
26
+func RandomString(length int) string {
27
+	// 48 ~ 57 数字
28
+	// 65 ~ 90 A ~ Z
29
+	// 97 ~ 122 a ~ z
30
+	// 一共62个字符,在0~61进行随机,小于10时,在数字范围随机,
31
+	// 小于36在大写范围内随机,其他在小写范围随机
32
+	rand.Seed(time.Now().UnixNano())
33
+	result := make([]string, 0, length)
34
+	for i := 0; i < length; i++ {
35
+		t := rand.Intn(62)
36
+		if t < 10 {
37
+			result = append(result, strconv.Itoa(rand.Intn(10)))
38
+		} else if t < 36 {
39
+			result = append(result, string(rand.Intn(26)+65))
40
+		} else {
41
+			result = append(result, string(rand.Intn(26)+97))
42
+		}
43
+	}
44
+	return strings.Join(result, "")
45
+}
46
+
47
+func RandomNumberString(length int) string {
48
+	var str string
49
+	for i := 0; i < length; i++ {
50
+		rand.Seed(time.Now().UnixNano())
51
+		str += strconv.Itoa(rand.Intn(10))
52
+	}
53
+	return str
54
+}
55
+
56
+// AES加密
57
+func AESEncrypt(origin string) string {
58
+	aes_key := beego.AppConfig.String("aes_key")
59
+	fmt.Println(aes_key)
60
+	xpass, _ := _aesEncrypt([]byte(origin), []byte(aes_key))
61
+	fmt.Println(_aesEncrypt([]byte(origin), []byte(aes_key)))
62
+	fmt.Println(xpass)
63
+	pass64 := base64.StdEncoding.EncodeToString(xpass)
64
+	fmt.Println(pass64)
65
+	return pass64
66
+}
67
+
68
+func AESDecrypt(crypted []byte) string {
69
+	aes_key := beego.AppConfig.String("aes_key")
70
+	origData, err := _aesDecrypt(crypted, []byte(aes_key))
71
+	if err != nil {
72
+		return ""
73
+	}
74
+	return string(origData)
75
+}
76
+
77
+func _PKCS5Padding(ciphertext []byte, blockSize int) []byte {
78
+	padding := blockSize - len(ciphertext)%blockSize
79
+	padtext := bytes.Repeat([]byte{byte(padding)}, padding)
80
+	return append(ciphertext, padtext...)
81
+}
82
+
83
+func _PKCS5UnPadding(origData []byte) []byte {
84
+	length := len(origData)
85
+	unpadding := int(origData[length-1])
86
+	return origData[:(length - unpadding)]
87
+}
88
+
89
+func _aesEncrypt(origData, key []byte) ([]byte, error) {
90
+	block, err := aes.NewCipher(key)
91
+	if err != nil {
92
+		return nil, err
93
+	}
94
+
95
+	blockSize := block.BlockSize()
96
+	origData = _PKCS5Padding(origData, blockSize)
97
+	blockMode := cipher.NewCBCEncrypter(block, key[:blockSize])
98
+	crypted := make([]byte, len(origData))
99
+	blockMode.CryptBlocks(crypted, origData)
100
+	return crypted, nil
101
+}
102
+
103
+func _aesDecrypt(crypted, key []byte) ([]byte, error) {
104
+	block, err := aes.NewCipher(key)
105
+	if err != nil {
106
+		return nil, err
107
+	}
108
+
109
+	blockSize := block.BlockSize()
110
+	blockMode := cipher.NewCBCDecrypter(block, key[:blockSize])
111
+	origData := make([]byte, len(crypted))
112
+	blockMode.CryptBlocks(origData, crypted)
113
+	origData = _PKCS5UnPadding(origData)
114
+	return origData, nil
115
+}

+ 27 - 0
utils/time_helper.go View File

1
+package utils
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+// day 当天凌晨0点
8
+func ZeroHourTimeOfDay(day time.Time) time.Time {
9
+	dayStr := day.Format("2006-01-02")
10
+	zeroHourTime, _ := ParseTimeStringToTime("2006-01-02", dayStr)
11
+	return *zeroHourTime
12
+}
13
+
14
+// day 当月一号凌晨0点
15
+func BeginningOfMonth(day time.Time) time.Time {
16
+	dayStr := day.Format("2006-01")
17
+	monthTime, _ := ParseTimeStringToTime("2006-01", dayStr)
18
+	return *monthTime
19
+}
20
+
21
+// 指定年月的月份的月初凌晨0点和月末23点59分59秒
22
+func MonthBeginningToEnd(year int, month int) (time.Time, time.Time) {
23
+	beginningOfMonth := time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.Local)
24
+	beginningOfNextMonth := beginningOfMonth.AddDate(0, 1, 0)
25
+	endOfMonth := beginningOfNextMonth.Add(time.Duration(-1))
26
+	return beginningOfMonth, endOfMonth
27
+}

+ 261 - 0
utils/tools.go View File

1
+package utils
2
+
3
+import (
4
+	"crypto/sha1"
5
+	"encoding/base64"
6
+	"errors"
7
+	"fmt"
8
+	"io"
9
+	"math/rand"
10
+	"regexp"
11
+	"sort"
12
+	"strconv"
13
+	"strings"
14
+	"time"
15
+
16
+	"github.com/astaxie/beego"
17
+)
18
+
19
+func TimeSub(t1, t2 time.Time) int {
20
+	t1 = time.Date(t1.Year(), t1.Month(), t1.Day(), 0, 0, 0, 0, time.Local)
21
+	t2 = time.Date(t2.Year(), t2.Month(), t2.Day(), 0, 0, 0, 0, time.Local)
22
+
23
+	return int(t1.Sub(t2).Hours() / 24)
24
+}
25
+
26
+func MarkBackUrl(backUrl, defaultUrl string) string {
27
+	if len(backUrl) == 0 {
28
+		backUrl = defaultUrl
29
+	} else {
30
+		backURLByte, err := base64.URLEncoding.DecodeString(backUrl)
31
+		if err != nil {
32
+			backUrl = backUrl
33
+		} else {
34
+			backUrl = string(backURLByte)
35
+		}
36
+	}
37
+	return backUrl
38
+}
39
+
40
+func CheckMobile(mobile string) (match bool) {
41
+
42
+	//过滤手机
43
+	match, _ = regexp.MatchString("^1\\d{10}$", mobile)
44
+	return
45
+}
46
+
47
+func RandCode(min, max int64) string {
48
+	if min >= max || min == 0 || max == 0 {
49
+		return strconv.FormatInt(max, 10)
50
+	}
51
+	rand.Seed(time.Now().UnixNano())
52
+	randNum := rand.Int63n(max-min) + min
53
+	return strconv.FormatInt(randNum, 10)
54
+}
55
+
56
+func TimeAgo(timeUnix int64) string {
57
+	timeUnixS := time.Unix(timeUnix, 0)
58
+	timeNow := time.Now()
59
+	timeSub := timeNow.Sub(timeUnixS)
60
+
61
+	if timeSub < time.Minute*1 {
62
+		return "刚刚"
63
+	} else if timeSub < time.Hour*1 {
64
+		return strconv.Itoa(int(timeSub.Minutes())) + "分钟前"
65
+	} else if timeSub < time.Hour*24 {
66
+		return strconv.Itoa(int(timeSub.Hours())) + "小时前"
67
+	} else if timeSub < time.Hour*24*7 {
68
+		return strconv.Itoa(int(timeSub.Hours()/24)) + "天前"
69
+	} else {
70
+		return timeUnixS.Format("2006-01-02 15:04")
71
+	}
72
+	return ""
73
+}
74
+
75
+//Signature sha1签名
76
+func Signature(params ...string) string {
77
+	sort.Strings(params)
78
+	h := sha1.New()
79
+	for _, s := range params {
80
+		io.WriteString(h, s)
81
+	}
82
+	return fmt.Sprintf("%x", h.Sum(nil))
83
+}
84
+
85
+//RandomStr 随机生成字符串
86
+func RandomStr(length int) string {
87
+	str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
88
+	bytes := []byte(str)
89
+	result := []byte{}
90
+	r := rand.New(rand.NewSource(time.Now().UnixNano()))
91
+	for i := 0; i < length; i++ {
92
+		result = append(result, bytes[r.Intn(len(bytes))])
93
+	}
94
+	return string(result)
95
+}
96
+
97
+//GetCurrTs return current timestamps
98
+func GetCurrTs() int64 {
99
+	return time.Now().Unix()
100
+}
101
+
102
+func SetThisRequestURI(uri string) string {
103
+	return fmt.Sprintf("%v%v", beego.AppConfig.String("httpdomain"), uri)
104
+}
105
+
106
+func SetThisBasr64RequestURI(uri string) string {
107
+	backUrl := fmt.Sprintf("%v%v", beego.AppConfig.String("httpdomain"), uri)
108
+	backUrl = base64.URLEncoding.EncodeToString([]byte(backUrl))
109
+
110
+	return backUrl
111
+}
112
+
113
+func TransNum2Str(read int64) (transRead string) {
114
+	if read < 0 {
115
+		transRead = "0"
116
+	} else if read < 10000 {
117
+		transRead = fmt.Sprintf("%v", read)
118
+	} else {
119
+		var c float64 = 10000
120
+		var rc float64 = float64(read)
121
+		transRead = fmt.Sprintf("%.2f万", rc/c)
122
+	}
123
+
124
+	return
125
+}
126
+
127
+func GenMobileToken(mobile string) (token string) {
128
+	st := strings.Split(mobile, "")
129
+
130
+	s := fmt.Sprintf("%s%v%v%v%v%v%v", mobile, st[0], st[1], st[3], st[7], st[6], st[9])
131
+
132
+	h := sha1.New()
133
+	h.Write([]byte(s))
134
+	bs := h.Sum(nil)
135
+
136
+	token = fmt.Sprintf("%x", bs)
137
+
138
+	return
139
+}
140
+
141
+func CheckMobileToken(mobile, token string) bool {
142
+	o := GenMobileToken(mobile)
143
+	if token == o {
144
+		return true
145
+	}
146
+
147
+	return false
148
+}
149
+
150
+type jSapiConfig struct {
151
+	AppID     string `json:"app_id"`
152
+	Timestamp int64  `json:"timestamp"`
153
+	NonceStr  string `json:"nonce_str"`
154
+	Signature string `json:"signature"`
155
+}
156
+
157
+//GetAJTConfig jsapi_ticket config
158
+func GetAJTConfig(jsapiTicket, uri string) (jSapiConfig, error) {
159
+	var config jSapiConfig
160
+	nonceStr := RandomStr(16)
161
+	timestamp := GetCurrTs()
162
+	str := fmt.Sprintf("jsapi_ticket=%s&noncestr=%s&timestamp=%d&url=%s", jsapiTicket, nonceStr, timestamp, uri)
163
+	sigStr := Signature(str)
164
+
165
+	config.AppID = beego.AppConfig.String("wxappId")
166
+	config.NonceStr = nonceStr
167
+	config.Timestamp = timestamp
168
+	config.Signature = sigStr
169
+	return config, nil
170
+}
171
+
172
+func TrimHtml(src string) string {
173
+	//将HTML标签全转换成小写
174
+	re, _ := regexp.Compile("\\<[\\S\\s]+?\\>")
175
+	src = re.ReplaceAllStringFunc(src, strings.ToLower)
176
+	//去除STYLE
177
+	re, _ = regexp.Compile("\\<style[\\S\\s]+?\\</style\\>")
178
+	src = re.ReplaceAllString(src, "")
179
+	//去除SCRIPT
180
+	re, _ = regexp.Compile("\\<script[\\S\\s]+?\\</script\\>")
181
+	src = re.ReplaceAllString(src, "")
182
+	//去除所有尖括号内的HTML代码,并换成换行符
183
+	re, _ = regexp.Compile("\\<[\\S\\s]+?\\>")
184
+	src = re.ReplaceAllString(src, "\n")
185
+	//去除连续的换行符
186
+	re, _ = regexp.Compile("\\s{2,}")
187
+	src = re.ReplaceAllString(src, "\n")
188
+	return strings.TrimSpace(src)
189
+}
190
+
191
+func SubString(str string, begin, length int) string {
192
+	rs := []rune(str)
193
+	lth := len(rs)
194
+	if begin < 0 {
195
+		begin = 0
196
+	}
197
+	if begin >= lth {
198
+		begin = lth
199
+	}
200
+	end := begin + length
201
+
202
+	if end > lth {
203
+		end = lth
204
+	}
205
+	return string(rs[begin:end])
206
+}
207
+
208
+func ParseTimeStringToTime(layout string, timeStr string) (*time.Time, error) {
209
+	if len(layout) == 0 || len(timeStr) == 0 {
210
+		return nil, errors.New("layout 或 日期字符串 为空,无法解析")
211
+	}
212
+	loc, _ := time.LoadLocation("Local")
213
+	date, parseDateErr := time.ParseInLocation(layout, timeStr, loc)
214
+	return &date, parseDateErr
215
+}
216
+
217
+// 获取 date 所在周的周一和周日,以周一0点为一周的开始,周日24点为一周的结束
218
+func GetMondayAndSundayOfWeekDate(date *time.Time) (time.Time, time.Time) {
219
+	if date == nil {
220
+		now := time.Now()
221
+		date = &now
222
+	}
223
+	weekday := int(date.Weekday())
224
+	if weekday == 0 {
225
+		weekday = 7
226
+	}
227
+	loc, _ := time.LoadLocation("Local")
228
+	monday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 1-weekday).Format("2006-01-02")+" 00:00:00", loc)
229
+	sunday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 7-weekday).Format("2006-01-02")+" 23:59:59", loc)
230
+	return monday, sunday
231
+}
232
+
233
+func GetMondayAndSundayOfNextWeekDate(date *time.Time) (time.Time, time.Time) {
234
+	if date == nil {
235
+		now := time.Now()
236
+		date = &now
237
+	}
238
+	weekday := int(date.Weekday())
239
+	if weekday == 0 {
240
+		weekday = 7
241
+	}
242
+	loc, _ := time.LoadLocation("Local")
243
+	monday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 8-weekday).Format("2006-01-02")+" 00:00:00", loc)
244
+	sunday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 14-weekday).Format("2006-01-02")+" 23:59:59", loc)
245
+	return monday, sunday
246
+}
247
+
248
+func GetMondayAndSundayOfNextNextWeekDate(date *time.Time) (time.Time, time.Time) {
249
+	if date == nil {
250
+		now := time.Now()
251
+		date = &now
252
+	}
253
+	weekday := int(date.Weekday())
254
+	if weekday == 0 {
255
+		weekday = 7
256
+	}
257
+	loc, _ := time.LoadLocation("Local")
258
+	monday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 15-weekday).Format("2006-01-02")+" 00:00:00", loc)
259
+	sunday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 21-weekday).Format("2006-01-02")+" 23:59:59", loc)
260
+	return monday, sunday
261
+}