csx vor 4 Jahren
Ursprung
Commit
39cdcda494

+ 29 - 2
conf/app.conf Datei anzeigen

72
 writeuserpass = xhPECP2nFObR8aUK
72
 writeuserpass = xhPECP2nFObR8aUK
73
 writeusername = sgj_users
73
 writeusername = sgj_users
74
 
74
 
75
+readsqlhost = shengws1.mysql.rds.aliyuncs.com
76
+readsqlport = 3306
77
+readsqluser = syh
78
+readsqlpass = xhPECP2nFObR8aUK
79
+readsqlname = sgj_xt
80
+
81
+writesqlhost = shengws1.mysql.rds.aliyuncs.com
82
+writesqlport = 3306
83
+writesqluser = syh
84
+writesqlpass = xhPECP2nFObR8aUK
85
+writesqlname = sgj_xt
86
+
87
+
75
 qiniu_accesskey = -l_Pcc1YJs0gh3w0YwN2uoaZO_5fY5J9SIYnSjg0
88
 qiniu_accesskey = -l_Pcc1YJs0gh3w0YwN2uoaZO_5fY5J9SIYnSjg0
76
 qiniu_secretkey = DmZSp_Bmnp-9aUB7xUvoyViZpzmx1Rs2RL69GvlW
89
 qiniu_secretkey = DmZSp_Bmnp-9aUB7xUvoyViZpzmx1Rs2RL69GvlW
77
 qiniu_domain = https://images.shengws.com/
90
 qiniu_domain = https://images.shengws.com/
87
 # submodule_domain_mall_manage = "http://mall.kuyicloud.com"
100
 # submodule_domain_mall_manage = "http://mall.kuyicloud.com"
88
 # submodule_domain_cdm_manage = "http://cdm.kuyicloud.com"
101
 # submodule_domain_cdm_manage = "http://cdm.kuyicloud.com"
89
 submodule_domain_patient_manage = "https://test1.sgjyun.com"
102
 submodule_domain_patient_manage = "https://test1.sgjyun.com"
90
-submodule_domain_dialysis_manage = "https://xt.test.sgjyun.com"
103
+submodule_domain_dialysis_manage = "http://xt.test.sgjyun.com"
91
 submodule_domain_mall_manage = "https://mall.test.sgjyun.com"
104
 submodule_domain_mall_manage = "https://mall.test.sgjyun.com"
92
 submodule_domain_cdm_manage = "https://cdm.test.sgjyun.com"
105
 submodule_domain_cdm_manage = "https://cdm.test.sgjyun.com"
93
 
106
 
121
 writeuserpass = 1Q2W3e4r!@#$
134
 writeuserpass = 1Q2W3e4r!@#$
122
 writeusername = sgj_users
135
 writeusername = sgj_users
123
 
136
 
137
+readsqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
138
+readsqlport = 3306
139
+readsqluser = root
140
+readsqlpass = 1Q2W3e4r!@#$
141
+readsqlname = sgj_xt
142
+
143
+writesqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
144
+writesqlport = 3306
145
+writesqluser = root
146
+writesqlpass = 1Q2W3e4r!@#$
147
+writesqlname = sgj_xt
148
+
149
+
150
+
124
 qiniu_accesskey = -l_Pcc1YJs0gh3w0YwN2uoaZO_5fY5J9SIYnSjg0
151
 qiniu_accesskey = -l_Pcc1YJs0gh3w0YwN2uoaZO_5fY5J9SIYnSjg0
125
 qiniu_secretkey = DmZSp_Bmnp-9aUB7xUvoyViZpzmx1Rs2RL69GvlW
152
 qiniu_secretkey = DmZSp_Bmnp-9aUB7xUvoyViZpzmx1Rs2RL69GvlW
126
 qiniu_domain = https://images.shengws.com/
153
 qiniu_domain = https://images.shengws.com/
127
 
154
 
128
-redishost = 120.77.235.13
155
+redishost = 127.0.0.1
129
 redisport = 6379
156
 redisport = 6379
130
 redispasswrod = syh@#$%123456!
157
 redispasswrod = syh@#$%123456!
131
 redisdb = 0
158
 redisdb = 0

+ 3 - 14
controllers/login_controller.go Datei anzeigen

35
 		returnURL = ""
35
 		returnURL = ""
36
 	}
36
 	}
37
 	utils.TraceLog("login token: %v", token)
37
 	utils.TraceLog("login token: %v", token)
38
-
39
 	if len(token) == 0 {
38
 	if len(token) == 0 {
40
 		this.Data["app_type"] = appType
39
 		this.Data["app_type"] = appType
41
 		this.Data["return_url"] = returnURL
40
 		this.Data["return_url"] = returnURL
236
 	admin := service.GetAdminUserWithMobile(mobile)
235
 	admin := service.GetAdminUserWithMobile(mobile)
237
 	if admin != nil {
236
 	if admin != nil {
238
 		if admin.IsSuperAdmin { // 如果是超级管理员用户
237
 		if admin.IsSuperAdmin { // 如果是超级管理员用户
239
-			// 那么需要检查是否创建了机构和应用,如未创建,则前往创建
238
+			// 那么需要检查是否创建了机构,如未创建,则前往创建
240
 			// 如果都创建了,那么和普通管理员用户一样,需要经过其他判断得出下一步跳转的链接
239
 			// 如果都创建了,那么和普通管理员用户一样,需要经过其他判断得出下一步跳转的链接
241
 			if didCreateOrg, findOrgErr := service.DidAdminUserCreateOrg(admin.Id); findOrgErr != nil {
240
 			if didCreateOrg, findOrgErr := service.DidAdminUserCreateOrg(admin.Id); findOrgErr != nil {
242
 				utils.ErrorLog("数据错误:查找mobile = %v的用户创建的机构时错误:%v", mobile, findOrgErr)
241
 				utils.ErrorLog("数据错误:查找mobile = %v的用户创建的机构时错误:%v", mobile, findOrgErr)
243
 				return "", &enums.SGJError{Code: enums.ErrorCodeDataException}, nil
242
 				return "", &enums.SGJError{Code: enums.ErrorCodeDataException}, nil
244
 			} else {
243
 			} else {
245
-				if didCreateOrg {
246
-					if didCreateApp, findAppErr := service.DidAdminUserOrgCreateApp(admin.Id, app_type); findAppErr != nil {
247
-						utils.ErrorLog("数据错误:查找mobile = %v的用户创建的应用时错误:%v", mobile, findOrgErr)
248
-						return "", &enums.SGJError{Code: enums.ErrorCodeDataException}, nil
249
-					} else {
250
-						if !didCreateApp {
251
-							url := this.appendTokenParamToReturnURL(beego.URLFor("OrgController.ViewApps"), token)
252
-							return url, nil, admin
253
-						}
254
-					}
255
-
256
-				} else {
244
+				if !didCreateOrg {
257
 					url := this.appendTokenParamToReturnURL(beego.URLFor("OrgController.Create"), token) // 前往创建机构的 url
245
 					url := this.appendTokenParamToReturnURL(beego.URLFor("OrgController.Create"), token) // 前往创建机构的 url
258
 					return url, nil, admin
246
 					return url, nil, admin
259
 				}
247
 				}
260
 			}
248
 			}
261
 		}
249
 		}
250
+
262
 		if len(returnURL) != 0 {
251
 		if len(returnURL) != 0 {
263
 			url := this.appendTokenParamToReturnURL(returnURL, token)
252
 			url := this.appendTokenParamToReturnURL(returnURL, token)
264
 			return url, nil, admin
253
 			return url, nil, admin

+ 237 - 57
controllers/mobile_login_controller.go Datei anzeigen

37
 
37
 
38
 	if service.IsPasswordRight(mobile, password) {
38
 	if service.IsPasswordRight(mobile, password) {
39
 		// 只取最近被创建的 admin_role
39
 		// 只取最近被创建的 admin_role
40
-		adminUser, getAdminErr := service.GetValidAdminUserByMobileReturnErr(mobile)
40
+		adminUser, getAdminErr := service.GetValidAdminUserByMobileReturnErr(mobile) //账号信息唯一值
41
 		if getAdminErr != nil {
41
 		if getAdminErr != nil {
42
 			utils.ErrorLog("获取管理员失败:%v", getAdminErr)
42
 			utils.ErrorLog("获取管理员失败:%v", getAdminErr)
43
 			this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
43
 			this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
49
 			this.ServeJSON()
49
 			this.ServeJSON()
50
 			return
50
 			return
51
 		} else {
51
 		} else {
52
-			appRole, getAppRoleErr := service.GetLastXTAdminRole(adminUser.Id, appType)
52
+
53
+			//优先获取最近登录的数据,没有登录的话获取被邀请的用户数据,如果既没有登录信息,也没有用户信息则属于全新用户,
54
+
55
+			loginLogs, _ := service.GetLastXTAdminRoleLoginRole(adminUser.Id, appType)
56
+			var appRole *models.App_Role
57
+			var org *models.Org
58
+			var subscibe *models.ServeSubscibe
59
+			var app *models.OrgApp
60
+
61
+			if loginLogs == nil { //登录信息不存在,获取被邀请的用户
62
+				tempAppRole, getAppRoleErr := service.GetLastXTAdminRole(adminUser.Id, appType)
63
+				if getAppRoleErr != nil {
64
+					utils.ErrorLog("获取 app_role 失败:%v", getAppRoleErr)
65
+					this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
66
+					this.ServeJSON()
67
+					return
68
+				}
69
+				appRole = tempAppRole
70
+
71
+				if appRole == nil { //如果用户信息不存在,说明没有创建机构和用户信息
72
+					org = nil
73
+					subscibe = nil
74
+					app = nil
75
+
76
+				} else { //用户信息存在则可能属于被邀请的
77
+
78
+					tempOrg, getOrgErr := service.GetOrgById(appRole.OrgId)
79
+					if getOrgErr != nil {
80
+						utils.ErrorLog("获取机构失败:%v", getOrgErr)
81
+						this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
82
+						this.ServeJSON()
83
+						return
84
+					}
85
+
86
+					tempSubscibe, getSubscibeErr := service.GetOrgServeSubscibe(tempOrg.Id)
87
+					if getSubscibeErr != nil {
88
+						utils.ErrorLog("获取机构订阅信息失败:%v", getSubscibeErr)
89
+						this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
90
+						this.ServeJSON()
91
+						return
92
+					}
93
+
94
+					tempApp, getAppErr := service.GetOrgApp(tempOrg.Id, appType)
95
+					if getAppErr != nil {
96
+						utils.ErrorLog("获取应用失败:%v", getAppErr)
97
+						this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
98
+						this.ServeJSON()
99
+						return
100
+					}
101
+
102
+					subscibe = tempSubscibe
103
+					org = tempOrg
104
+					app = tempApp
105
+				}
106
+
107
+			} else {
108
+				//根据登录信息的机构和用户id,去获取对应用户信息和机构信息
109
+				tempApp, _ := service.GetOrgApp(loginLogs.OrgId, appType)
110
+				tempRole, _ := service.GetAppRole(adminUser.Id, loginLogs.OrgId, tempApp.Id)
111
+				if tempRole.Status != 1 {
112
+					admin_user_info, _ := service.GetLastUserRole(int64(loginLogs.OrgId), int64(adminUser.Id))
113
+					tempRole = admin_user_info
114
+					app, _ := service.GetOrgApp(tempRole.OrgId, 3)
115
+					tempApp = app
116
+
117
+					tempOrg, getOrgErr := service.GetOrgById(tempRole.OrgId)
118
+					if getOrgErr != nil {
119
+						utils.ErrorLog("获取机构失败:%v", getOrgErr)
120
+						this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
121
+						this.ServeJSON()
122
+						return
123
+					}
124
+					tempSubscibe, getSubscibeErr := service.GetOrgServeSubscibe(tempOrg.Id)
125
+					if getSubscibeErr != nil {
126
+						utils.ErrorLog("获取机构订阅信息失败:%v", getSubscibeErr)
127
+						this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
128
+						this.ServeJSON()
129
+						return
130
+					}
131
+
132
+					subscibe = tempSubscibe
133
+					org = tempOrg
134
+					appRole = tempRole
135
+					app = tempApp
136
+
137
+				} else {
138
+					tempOrg, getOrgErr := service.GetOrgById(loginLogs.OrgId)
139
+					if getOrgErr != nil {
140
+						utils.ErrorLog("获取机构失败:%v", getOrgErr)
141
+						this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
142
+						this.ServeJSON()
143
+						return
144
+					}
145
+					tempSubscibe, getSubscibeErr := service.GetOrgServeSubscibe(tempOrg.Id)
146
+					if getSubscibeErr != nil {
147
+						utils.ErrorLog("获取机构订阅信息失败:%v", getSubscibeErr)
148
+						this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
149
+						this.ServeJSON()
150
+						return
151
+					}
152
+					subscibe = tempSubscibe
153
+					org = tempOrg
154
+					appRole = tempRole
155
+					app = tempApp
156
+				}
157
+			}
158
+
159
+			if org != nil && appRole != nil {
160
+				// 插入一条登录记录
161
+				ip := this.GetString("ip")
162
+				loginLog := &models.AdminUserLoginLog{
163
+					AdminUserId: adminUser.Id,
164
+					OrgId:       org.Id,
165
+					AppId:       appRole.AppId,
166
+					IP:          ip,
167
+					OperateType: 1,
168
+					AppType:     int8(appType),
169
+					CreateTime:  time.Now().Unix(),
170
+				}
171
+				if insertErr := service.InsertLoginLog(loginLog); insertErr != nil {
172
+					utils.ErrorLog("为手机号为%v的用户插入一条登录记录失败:%v", mobile, insertErr)
173
+				}
174
+			}
175
+
176
+			this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
177
+				"admin":    adminUser,
178
+				"org":      org,
179
+				"app":      app,
180
+				"app_role": appRole,
181
+				"subscibe": subscibe,
182
+			})
183
+			this.ServeJSON()
184
+		}
185
+
186
+	} else {
187
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
188
+		this.ServeJSON()
189
+	}
190
+}
191
+
192
+func (this *MobileLoginController) LoginByCode() {
193
+	appType, _ := this.GetInt("app_type")
194
+	if appType != 3 { // 暂时只支持血透系统
195
+		appType = 3
196
+	}
197
+	mobile := this.GetString("mobile")
198
+	if len(mobile) == 0 {
199
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
200
+		this.ServeJSON()
201
+		return
202
+	}
203
+
204
+	// 只取最近被创建的 admin_role
205
+	adminUser, getAdminErr := service.GetValidAdminUserByMobileReturnErr(mobile) //账号信息唯一值
206
+	if getAdminErr != nil {
207
+		utils.ErrorLog("获取管理员失败:%v", getAdminErr)
208
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
209
+		this.ServeJSON()
210
+		return
211
+	} else if adminUser == nil {
212
+		utils.ErrorLog("查找不到 mobile = %v 的用户", mobile)
213
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
214
+		this.ServeJSON()
215
+		return
216
+	} else {
217
+
218
+		//优先获取最近登录的数据,没有登录的话获取被邀请的用户数据,如果既没有登录信息,也没有用户信息则属于全新用户,
219
+
220
+		loginLogs, _ := service.GetLastXTAdminRoleLoginRole(adminUser.Id, appType)
221
+		var appRole *models.App_Role
222
+		var org *models.Org
223
+		var subscibe *models.ServeSubscibe
224
+		var app *models.OrgApp
225
+
226
+		if loginLogs == nil { //登录信息不存在,获取被邀请的用户
227
+			tempAppRole, getAppRoleErr := service.GetLastXTAdminRole(adminUser.Id, appType)
53
 			if getAppRoleErr != nil {
228
 			if getAppRoleErr != nil {
54
 				utils.ErrorLog("获取 app_role 失败:%v", getAppRoleErr)
229
 				utils.ErrorLog("获取 app_role 失败:%v", getAppRoleErr)
55
 				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
230
 				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
56
 				this.ServeJSON()
231
 				this.ServeJSON()
57
 				return
232
 				return
58
-			} else if appRole == nil {
59
-				utils.ErrorLog("该管理员没有开通或被授权 app_type = %v 的应用", appType)
60
-				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
61
-				this.ServeJSON()
62
-				return
63
 			}
233
 			}
64
-			org, getOrgErr := service.GetOrgById(appRole.OrgId)
234
+			appRole = tempAppRole
235
+
236
+			if appRole == nil { //如果用户信息不存在,说明没有创建机构和用户信息
237
+				org = nil
238
+				subscibe = nil
239
+				app = nil
240
+
241
+			} else { //用户信息存在则可能属于被邀请的
242
+
243
+				tempOrg, getOrgErr := service.GetOrgById(appRole.OrgId)
244
+				if getOrgErr != nil {
245
+					utils.ErrorLog("获取机构失败:%v", getOrgErr)
246
+					this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
247
+					this.ServeJSON()
248
+					return
249
+				}
250
+
251
+				tempSubscibe, getSubscibeErr := service.GetOrgServeSubscibe(tempOrg.Id)
252
+				if getSubscibeErr != nil {
253
+					utils.ErrorLog("获取机构订阅信息失败:%v", getSubscibeErr)
254
+					this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
255
+					this.ServeJSON()
256
+					return
257
+				}
258
+
259
+				tempApp, getAppErr := service.GetOrgApp(tempOrg.Id, appType)
260
+				if getAppErr != nil {
261
+					utils.ErrorLog("获取应用失败:%v", getAppErr)
262
+					this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
263
+					this.ServeJSON()
264
+					return
265
+				}
266
+
267
+				subscibe = tempSubscibe
268
+				org = tempOrg
269
+				app = tempApp
270
+			}
271
+
272
+		} else {
273
+			//根据登录信息的机构和用户id,去获取对应用户信息和机构信息
274
+			tempApp, _ := service.GetOrgApp(loginLogs.OrgId, appType)
275
+			tempRole, _ := service.GetAppRole(adminUser.Id, loginLogs.OrgId, tempApp.Id)
276
+
277
+			tempOrg, getOrgErr := service.GetOrgById(loginLogs.OrgId)
65
 			if getOrgErr != nil {
278
 			if getOrgErr != nil {
66
 				utils.ErrorLog("获取机构失败:%v", getOrgErr)
279
 				utils.ErrorLog("获取机构失败:%v", getOrgErr)
67
 				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
280
 				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
68
 				this.ServeJSON()
281
 				this.ServeJSON()
69
 				return
282
 				return
70
-			} else if org == nil {
71
-				utils.ErrorLog("该机构不存在或被删除")
72
-				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
73
-				this.ServeJSON()
74
-				return
75
-			}
76
-			app, getAppErr := service.GetAppById(appRole.AppId)
77
-			if getAppErr != nil {
78
-				utils.ErrorLog("获取应用失败:%v", getAppErr)
79
-				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
80
-				this.ServeJSON()
81
-				return
82
-			} else if app == nil {
83
-				utils.ErrorLog("该应用不存在或被删除")
84
-				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
85
-				this.ServeJSON()
86
-				return
87
 			}
283
 			}
88
-			subscibe, getSubscibeErr := service.GetOrgServeSubscibe(org.Id)
284
+			tempSubscibe, getSubscibeErr := service.GetOrgServeSubscibe(tempOrg.Id)
89
 			if getSubscibeErr != nil {
285
 			if getSubscibeErr != nil {
90
 				utils.ErrorLog("获取机构订阅信息失败:%v", getSubscibeErr)
286
 				utils.ErrorLog("获取机构订阅信息失败:%v", getSubscibeErr)
91
 				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
287
 				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
92
 				this.ServeJSON()
288
 				this.ServeJSON()
93
 				return
289
 				return
94
-			} else if subscibe == nil {
95
-				now := time.Now()
96
-				nextMonthDate := now.AddDate(0, 0, 30)
97
-				subscibe = &models.ServeSubscibe{
98
-					OrgId:       int64(org.Id),
99
-					PeriodStart: now.Unix(),
100
-					PeriodEnd:   nextMonthDate.Unix(),
101
-					Status:      1,
102
-					CreatedTime: now.Unix(),
103
-					UpdatedTime: now.Unix(),
104
-					State:       2,
105
-				}
106
-				createErr := service.CreateOrgServeSubscibe(subscibe)
107
-				if createErr != nil {
108
-					utils.ErrorLog("创建机构订阅信息失败:%v", createErr)
109
-					this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
110
-					this.ServeJSON()
111
-					return
112
-				}
113
 			}
290
 			}
114
 
291
 
292
+			subscibe = tempSubscibe
293
+			org = tempOrg
294
+			appRole = tempRole
295
+			app = tempApp
296
+		}
297
+
298
+		if org != nil && appRole != nil {
115
 			// 插入一条登录记录
299
 			// 插入一条登录记录
116
 			ip := this.GetString("ip")
300
 			ip := this.GetString("ip")
117
 			loginLog := &models.AdminUserLoginLog{
301
 			loginLog := &models.AdminUserLoginLog{
118
 				AdminUserId: adminUser.Id,
302
 				AdminUserId: adminUser.Id,
119
 				OrgId:       org.Id,
303
 				OrgId:       org.Id,
120
-				AppId:       app.Id,
304
+				AppId:       appRole.AppId,
121
 				IP:          ip,
305
 				IP:          ip,
122
 				OperateType: 1,
306
 				OperateType: 1,
123
 				AppType:     int8(appType),
307
 				AppType:     int8(appType),
126
 			if insertErr := service.InsertLoginLog(loginLog); insertErr != nil {
310
 			if insertErr := service.InsertLoginLog(loginLog); insertErr != nil {
127
 				utils.ErrorLog("为手机号为%v的用户插入一条登录记录失败:%v", mobile, insertErr)
311
 				utils.ErrorLog("为手机号为%v的用户插入一条登录记录失败:%v", mobile, insertErr)
128
 			}
312
 			}
129
-
130
-			this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
131
-				"admin":    adminUser,
132
-				"org":      org,
133
-				"app":      app,
134
-				"app_role": appRole,
135
-				"subscibe": subscibe,
136
-			})
137
-			this.ServeJSON()
138
 		}
313
 		}
139
 
314
 
140
-	} else {
141
-		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
315
+		this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
316
+			"admin":    adminUser,
317
+			"org":      org,
318
+			"app":      app,
319
+			"app_role": appRole,
320
+			"subscibe": subscibe,
321
+		})
142
 		this.ServeJSON()
322
 		this.ServeJSON()
143
 	}
323
 	}
144
 }
324
 }

+ 2 - 1
controllers/mobile_regist_controller.go Datei anzeigen

165
 		this.ServeJSON()
165
 		this.ServeJSON()
166
 		return
166
 		return
167
 	}
167
 	}
168
+	user_name := this.GetString("user_name")
168
 
169
 
169
 	name := this.GetString("name")
170
 	name := this.GetString("name")
170
 	shortName := name
171
 	shortName := name
243
 		ModifyTime:   time.Now().Unix(),
244
 		ModifyTime:   time.Now().Unix(),
244
 	}
245
 	}
245
 
246
 
246
-	createErr := service.CreateOrg(&org, adminUser.Mobile, openXT, openCDM, openSCRM, openMall) // 创建机构以及所有类型的 app,如果有新类型的平台,则需要在这个方法里面把创建这一新类型的 app 的代码加上
247
+	createErr := service.CreateOrg(&org, adminUser.Mobile, openXT, openCDM, openSCRM, openMall, user_name) // 创建机构以及所有类型的 app,如果有新类型的平台,则需要在这个方法里面把创建这一新类型的 app 的代码加上
247
 	if createErr != nil {
248
 	if createErr != nil {
248
 		utils.ErrorLog("mobile=%v的超级管理员创建机构失败:%v", adminUser.Mobile, createErr)
249
 		utils.ErrorLog("mobile=%v的超级管理员创建机构失败:%v", adminUser.Mobile, createErr)
249
 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
250
 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)

Datei-Diff unterdrückt, da er zu groß ist
+ 822 - 124
controllers/org_controller.go


+ 163 - 0
controllers/patient.json Datei anzeigen

1
+{
2
+  "patients": [
3
+    {
4
+      "avatar": "https://images.shengws.com/201809182128111.png",
5
+      "patient_type": 1,
6
+      "dialysis_no": "001",
7
+      "admission_number": "",
8
+      "source": 1,
9
+      "lapseto": 1,
10
+      "partition_id": 0,
11
+      "bed_id": 0,
12
+      "name": "演示患者一",
13
+      "alias": "",
14
+      "gender": 1,
15
+      "nation": "汉",
16
+      "native_place": "广东深圳",
17
+      "marital_status": 1,
18
+      "id_card_no": "431230199808081111",
19
+      "birthday": -312537600,
20
+      "reimbursement_way_id": 7,
21
+      "health_care_type": 0,
22
+      "health_care_no": "604324517",
23
+      "health_care_due_date": 0,
24
+      "height": 158,
25
+      "blood_type": 0,
26
+      "rh": 0,
27
+      "health_care_due_alert_date": 0,
28
+      "education_level": 5,
29
+      "profession": 10,
30
+      "phone": "13800000001",
31
+      "home_telephone": "",
32
+      "relative_phone": "",
33
+      "relative_relations": "",
34
+      "home_address": "深圳市罗湖区鸿翔花园",
35
+      "work_unit": "无",
36
+      "unit_address": "无",
37
+      "children": 2,
38
+      "receiving_date": 0,
39
+      "is_hospital_first_dialysis": 1,
40
+      "first_dialysis_date": 1110816000,
41
+      "first_dialysis_hospital": "深圳市人民医院",
42
+      "predialysis_condition": "",
43
+      "pre_hospital_dialysis_frequency": "每周3次",
44
+      "pre_hospital_dialysis_times": 1820,
45
+      "hospital_first_dialysis_date": 1511366400,
46
+      "induction_period": 0,
47
+      "initial_dialysis": 0,
48
+      "total_dialysis": 14,
49
+      "attending_doctor_id": 0,
50
+      "head_nurse_id": 0,
51
+      "evaluate": "",
52
+      "diagnose": "慢病肾功能不全(尿毒症期)",
53
+      "remark": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
54
+      "registrars_id": 185,
55
+      "registrars": "",
56
+      "qr_code": "",
57
+      "binding_state": 2,
58
+      "patient_complains": "慢病肾功能不全(尿毒症期)",
59
+      "present_history": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
60
+      "past_history": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
61
+      "temperature": 39,
62
+      "pulse": 60,
63
+      "respiratory": 100,
64
+      "sbp": 0,
65
+      "dbp": 0,
66
+      "status": 1,
67
+      "created_time": 1537347970,
68
+      "updated_time": 1584343696,
69
+      "solutions": null,
70
+      "age": 60,
71
+      "schedules": null,
72
+      "contagions": null,
73
+      "diseases": null,
74
+      "response_result": "",
75
+      "is_open_remind": 1,
76
+      "dialysis_age": 0,
77
+      "expense_kind": 3,
78
+      "tell_phone": "21212",
79
+      "first_treatment_date": 1582560000,
80
+      "contact_name": "21221"
81
+    },
82
+    {
83
+      "avatar": "https://images.shengws.com/201809182128111.png",
84
+      "patient_type": 1,
85
+      "dialysis_no": "002",
86
+      "admission_number": "",
87
+      "source": 1,
88
+      "lapseto": 1,
89
+      "partition_id": 0,
90
+      "bed_id": 0,
91
+      "name": "演示患者二",
92
+      "alias": "",
93
+      "gender": 2,
94
+      "nation": "汉",
95
+      "native_place": "广东深圳",
96
+      "marital_status": 1,
97
+      "id_card_no": "4312301999090952222",
98
+      "birthday": -312537600,
99
+      "reimbursement_way_id": 7,
100
+      "health_care_type": 0,
101
+      "health_care_no": "604324517",
102
+      "health_care_due_date": 0,
103
+      "height": 158,
104
+      "blood_type": 0,
105
+      "rh": 0,
106
+      "health_care_due_alert_date": 0,
107
+      "education_level": 5,
108
+      "profession": 10,
109
+      "phone": "13800000001",
110
+      "home_telephone": "",
111
+      "relative_phone": "",
112
+      "relative_relations": "哥哥",
113
+      "home_address": "深圳市罗湖区鸿翔花园",
114
+      "work_unit": "无",
115
+      "unit_address": "无",
116
+      "children": 2,
117
+      "receiving_date": 0,
118
+      "is_hospital_first_dialysis": 1,
119
+      "first_dialysis_date": 1110816000,
120
+      "first_dialysis_hospital": "深圳市人民医院",
121
+      "predialysis_condition": "",
122
+      "pre_hospital_dialysis_frequency": "每周3次",
123
+      "pre_hospital_dialysis_times": 1820,
124
+      "hospital_first_dialysis_date": 1511366400,
125
+      "induction_period": 0,
126
+      "initial_dialysis": 0,
127
+      "total_dialysis": 14,
128
+      "attending_doctor_id": 0,
129
+      "head_nurse_id": 0,
130
+      "evaluate": "",
131
+      "diagnose": "慢病肾功能不全(尿毒症期)",
132
+      "remark": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
133
+      "registrars_id": 185,
134
+      "registrars": "",
135
+      "qr_code": "",
136
+      "binding_state": 2,
137
+      "patient_complains": "慢病肾功能不全(尿毒症期)",
138
+      "present_history": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
139
+      "past_history": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
140
+      "temperature": 39,
141
+      "pulse": 60,
142
+      "respiratory": 100,
143
+      "sbp": 0,
144
+      "dbp": 0,
145
+      "status": 1,
146
+      "created_time": 1537347970,
147
+      "updated_time": 1584343696,
148
+      "solutions": null,
149
+      "age": 60,
150
+      "schedules": null,
151
+      "contagions": null,
152
+      "diseases": null,
153
+      "response_result": "",
154
+      "is_open_remind": 1,
155
+      "dialysis_age": 0,
156
+      "expense_kind": 3,
157
+      "tell_phone": "21212",
158
+      "first_treatment_date": 1582560000,
159
+      "contact_name": "21221"
160
+    }
161
+  ]
162
+}
163
+

+ 87 - 0
controllers/role.json Datei anzeigen

1
+{
2
+  "roles": [
3
+    {
4
+      "role_name": "子管理员",
5
+      "role_introduction": "子管理员角色具备平台全部功能的使用权限,请谨慎配置",
6
+      "is_super_admin": false,
7
+      "status": 1,
8
+      "is_system": 1,
9
+      "number": 9999,
10
+      "purview_ids": "49,71,72,70,74,75,73,127,128,48,52,110,94,111,112,113,114,115,116,117,118,119,129,84,93,121,122,124,125,120,77,78,79,80,76,156,157,158,159,155,82,83,108,149,154,190,81,101,100,102,161,160,162,163,165,170,169,171,172,173,174,177,175,178,180,179,181,186,185,187,188,189,192,81,82,83,104,106,107,108,149,154,190,191",
11
+      "func_ids": "20001,20002,20003,20004,20005,20006,20007,20008,20009,20010,20011,20012,20024,20025,20026,20027,20028,20029,20030,20031,20032,20033,20034,20035,20036,20037,20038,20039,20040,20041,20042,20043,20044,20045"
12
+    },
13
+    {
14
+      "role_name": "医生",
15
+      "role_introduction": "医生角色能够进行建立患者档案,制定和调整患者透析治疗方案,定期评价病人的透析质量等",
16
+      "is_super_admin": false,
17
+      "status": 1,
18
+      "is_system": 2,
19
+      "number": 9998,
20
+      "purview_ids": "49,71,72,70,74,75,73,127,128,48,52,110,93,121,122,124,125,120,101,100,102,156,157,158,159,15571,72,70,74,75,73,127,128,48,52,110,93,121,122,124,125,120,101,100,102,156,157,158,159,155",
21
+      "func_ids": "20001,20002,20003,20004,20005,20006,20007,20008,20009,20010,20011,20012,20024,20025,20026,20027,20028,20029,20030,20031,20032,20033"
22
+
23
+
24
+    },
25
+    {
26
+      "role_name": "护士",
27
+      "role_introduction": "护士角色能够进行病人透析管理,以及医院的感染控制与消毒记录等",
28
+      "is_super_admin": false,
29
+      "status": 1,
30
+      "is_system": 3,
31
+      "number": 9997,
32
+      "purview_ids": "49,74,75,73,48,52,110,93,121,122,124,125,120",
33
+      "func_ids": "20007,20008,20010,20011,20012,20013,20014,20016,20017,20019,20021,20022,20024,20025,20027,20028"
34
+
35
+
36
+
37
+    },
38
+    {
39
+      "role_name": "库存",
40
+      "role_introduction": "库存角色负责透析耗材的日常管理,对耗材的入库、出库、退库的登记操作",
41
+      "is_super_admin": false,
42
+      "status": 1,
43
+      "is_system": 0,
44
+      "number": 9996,
45
+      "purview_ids": "94,111,112,113,114,115,116,117,118,119,129,84",
46
+      "func_ids": ""
47
+
48
+
49
+
50
+    },{
51
+      "role_name": "运营",
52
+      "role_introduction": "运营角色能够在SCRM中管理微网站、使用营销工具、做会员管理和分销商品经营的操作",
53
+      "is_super_admin": false,
54
+      "status": 1,
55
+      "is_system": 0,
56
+      "number": 9995,
57
+      "purview_ids": "161,160,162,163,165,170,169,171,172,173,174,177,175,178,180,179,181,186,185,187,188,189,192",
58
+      "func_ids": ""
59
+
60
+
61
+
62
+    },{
63
+      "role_name": "技师",
64
+      "role_introduction": "技师角色能够进行设备的管理,日常维护维修记录等",
65
+      "is_super_admin": false,
66
+      "status": 1,
67
+      "is_system": 0,
68
+      "number": 9994,
69
+      "purview_ids": "77,78,79,80,76,191",
70
+      "func_ids": ""
71
+
72
+
73
+    },
74
+    {
75
+      "role_name": "院长",
76
+      "role_introduction": "院长角色了解血透患者血液透析质量和相关的大数据,以及掌握透析中心整体运营情况",
77
+      "is_super_admin": false,
78
+      "status": 1,
79
+      "is_system": 0,
80
+      "number": 9993,
81
+      "purview_ids": "49,71,72,70,74,75,73,127,128,48,52,110,94,111,112,113,114,115,116,117,118,119,129,84,93,121,122,124,125,120,77,78,79,80,76,156,157,158,159,155,82,83,108,149,154,190,81,101,100,102,161,160,162,163,165,170,169,171,172,173,174,177,175,178,180,179,181,186,185,187,188,189,192",
82
+      "func_ids": ""
83
+
84
+
85
+    }
86
+  ]
87
+}

+ 86 - 0
controllers/schedule_template.json Datei anzeigen

1
+{
2
+  "item": [
3
+    {
4
+      "treat_mode": 1,
5
+      "weekday": 1,
6
+      "time_type": 1
7
+    },
8
+    {
9
+      "treat_mode": 1,
10
+      "weekday": 1,
11
+      "time_type": 2
12
+    },
13
+    {
14
+
15
+      "treat_mode": 1,
16
+      "weekday": 2,
17
+      "time_type": 1
18
+    },
19
+
20
+    {
21
+
22
+      "treat_mode": 1,
23
+      "weekday": 2,
24
+      "time_type": 2
25
+    },
26
+    {
27
+
28
+      "treat_mode": 1,
29
+      "weekday": 3,
30
+      "time_type": 1
31
+    },
32
+    {
33
+
34
+      "treat_mode": 1,
35
+      "weekday": 3,
36
+      "time_type": 2
37
+    },
38
+    {
39
+
40
+      "treat_mode": 1,
41
+      "weekday": 4,
42
+      "time_type": 1
43
+    },
44
+    {
45
+
46
+      "treat_mode": 1,
47
+      "weekday": 4,
48
+      "time_type": 2
49
+    },
50
+    {
51
+
52
+      "treat_mode": 1,
53
+      "weekday": 5,
54
+      "time_type": 1
55
+    },
56
+    {
57
+
58
+      "treat_mode": 1,
59
+      "weekday": 5,
60
+      "time_type": 2
61
+    },
62
+    {
63
+
64
+      "treat_mode": 1,
65
+      "weekday": 6,
66
+      "time_type": 1
67
+    },
68
+    {
69
+
70
+      "treat_mode": 1,
71
+      "weekday": 6,
72
+      "time_type": 2
73
+    },
74
+    {
75
+
76
+      "treat_mode": 1,
77
+      "weekday": 7,
78
+      "time_type": 1
79
+    },
80
+    {
81
+      "treat_mode": 1,
82
+      "weekday": 7,
83
+      "time_type": 2
84
+    }
85
+  ]
86
+}

+ 57 - 0
controllers/system_dialysis_prescription.json Datei anzeigen

1
+{
2
+  "prescription": [
3
+    {
4
+      "anticoagulant": 3,
5
+      "anticoagulant_shouji": 4000,
6
+      "anticoagulant_weichi": 0,
7
+      "anticoagulant_zongliang": 4000,
8
+      "mode_id": 1,
9
+      "blood_flow_volume": 250,
10
+      "kalium": 2,
11
+      "sodium": 135,
12
+      "calcium": 1.5,
13
+      "status": 1,
14
+      "dialysis_duration_hour": 4,
15
+      "dialysis_duration_minute": 0
16
+    },{
17
+      "anticoagulant": 3,
18
+      "anticoagulant_shouji": 4000,
19
+      "anticoagulant_weichi": 0,
20
+      "anticoagulant_zongliang": 4000,
21
+      "mode_id": 2,
22
+      "blood_flow_volume": 250,
23
+      "kalium": 2,
24
+      "sodium": 135,
25
+      "calcium": 1.5,
26
+      "status": 1,
27
+      "dialysis_duration_hour": 4,
28
+      "dialysis_duration_minute": 0
29
+    },{
30
+      "anticoagulant": 3,
31
+      "anticoagulant_shouji": 4000,
32
+      "anticoagulant_weichi": 0,
33
+      "anticoagulant_zongliang": 4000,
34
+      "mode_id": 3,
35
+      "blood_flow_volume": 200,
36
+      "kalium": 2,
37
+      "sodium": 135,
38
+      "calcium": 1.5,
39
+      "status": 1,
40
+      "dialysis_duration_hour": 4,
41
+      "dialysis_duration_minute": 0
42
+    },{
43
+      "anticoagulant": 3,
44
+      "anticoagulant_shouji": 4000,
45
+      "anticoagulant_weichi": 0,
46
+      "anticoagulant_zongliang": 4000,
47
+      "mode_id": 12,
48
+      "blood_flow_volume": 200,
49
+      "kalium": 2,
50
+      "sodium": 135,
51
+      "calcium": 1.5,
52
+      "status": 1,
53
+      "dialysis_duration_hour": 4,
54
+      "dialysis_duration_minute": 0
55
+    }
56
+  ]
57
+}

+ 151 - 126
controllers/verify_token_controller.go Datei anzeigen

35
 	// 	this.ServeJSON()
35
 	// 	this.ServeJSON()
36
 	// 	return
36
 	// 	return
37
 	// }
37
 	// }
38
+	app_type = 3
38
 	if url := service.GetAppURLWithAppType(app_type); len(url) == 0 {
39
 	if url := service.GetAppURLWithAppType(app_type); len(url) == 0 {
39
 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
40
 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
40
 		this.ServeJSON()
41
 		this.ServeJSON()
71
 			utils.TraceLog("%v data is from operation", "sso_admin_user_info_"+mobile)
72
 			utils.TraceLog("%v data is from operation", "sso_admin_user_info_"+mobile)
72
 			isUserInfoFromRedis = false
73
 			isUserInfoFromRedis = false
73
 			info, getInfoErr := this.GetAdminUserAllInfo(mobile)
74
 			info, getInfoErr := this.GetAdminUserAllInfo(mobile)
75
+
74
 			if getInfoErr != nil {
76
 			if getInfoErr != nil {
75
 				this.Data["json"] = enums.MakeFailResponseJSONWithSGJError(getInfoErr)
77
 				this.Data["json"] = enums.MakeFailResponseJSONWithSGJError(getInfoErr)
76
 				this.ServeJSON()
78
 				this.ServeJSON()
101
 			currentAppId = lastLoginLog.AppId
103
 			currentAppId = lastLoginLog.AppId
102
 		} else {
104
 		} else {
103
 			if isUserInfoFromRedis {
105
 			if isUserInfoFromRedis {
104
-				orgIds := userInfo["org_ids"].([]interface{})
105
-				for _, oid := range orgIds {
106
-					orgApps := userInfo["org_apps"].(map[string]interface{})[oid.(string)]
107
-					for _, appMapJSON := range orgApps.(map[string]interface{}) {
108
-						var appMap map[string]interface{}
109
-						json.Unmarshal([]byte(appMapJSON.(string)), &appMap)
110
 
106
 
111
-						a_t := int(appMap["app_type"].(float64))
112
-						if a_t == app_type {
113
-							currentOrgId = int(appMap["org_id"].(float64))
114
-							currentAppId = int(appMap["id"].(float64))
115
-							break
116
-						}
117
-					}
118
-					if currentOrgId != 0 && currentAppId != 0 {
119
-						break
120
-					}
121
-				}
107
+				role, _ := service.GetLastXTAdminRole(adminUser.Id, app_type)
108
+				currentAppId = role.AppId
109
+				currentOrgId = role.OrgId
122
 
110
 
123
-			} else {
124
-				orgIds := userInfo["org_ids"].([]string)
125
-				for _, oid := range orgIds {
126
-					orgApps := userInfo["org_apps"].(map[string]interface{})[oid]
127
-					for _, appMapJSON := range orgApps.(map[string]string) {
128
-						var appMap map[string]interface{}
129
-						json.Unmarshal([]byte(appMapJSON), &appMap)
111
+				//orgIds := userInfo["org_ids"].([]interface{})
112
+				//for _, oid := range orgIds {
113
+				//	orgApps := userInfo["org_apps"].(map[string]interface{})[oid.(string)]
114
+				//	for _, appMapJSON := range orgApps.(map[string]interface{}) {
115
+				//		var appMap map[string]interface{}
116
+				//		json.Unmarshal([]byte(appMapJSON.(string)), &appMap)
117
+				//
118
+				//		a_t := int(appMap["app_type"].(float64))
119
+				//		if a_t == app_type {
120
+				//			currentOrgId = int(appMap["org_id"].(float64))
121
+				//			currentAppId = int(appMap["id"].(float64))
122
+				//			break
123
+				//		}
124
+				//	}
125
+				//	if currentOrgId != 0 && currentAppId != 0 {
126
+				//		break
127
+				//	}
128
+				//}
130
 
129
 
131
-						a_t := int(appMap["app_type"].(float64))
132
-						if a_t == app_type {
133
-							currentOrgId = int(appMap["org_id"].(float64))
134
-							currentAppId = int(appMap["id"].(float64))
135
-							break
136
-						}
137
-					}
138
-					if currentOrgId != 0 && currentAppId != 0 {
139
-						break
140
-					}
141
-				}
130
+			} else {
131
+				role, _ := service.GetLastXTAdminRole(adminUser.Id, app_type)
132
+				currentAppId = role.AppId
133
+				currentOrgId = role.OrgId
134
+				//orgIds := userInfo["org_ids"].([]string)
135
+				//for _, oid := range orgIds {
136
+				//	orgApps := userInfo["org_apps"].(map[string]interface{})[oid]
137
+				//	for _, appMapJSON := range orgApps.(map[string]string) {
138
+				//		var appMap map[string]interface{}
139
+				//		json.Unmarshal([]byte(appMapJSON), &appMap)
140
+				//
141
+				//		a_t := int(appMap["app_type"].(float64))
142
+				//		if a_t == app_type {
143
+				//			currentOrgId = int(appMap["org_id"].(float64))
144
+				//			currentAppId = int(appMap["id"].(float64))
145
+				//			break
146
+				//		}
147
+				//	}
148
+				//	if currentOrgId != 0 && currentAppId != 0 {
149
+				//		break
150
+				//	}
151
+				//}
142
 			}
152
 			}
143
 		}
153
 		}
144
-		// for key, value := range userInfo {
145
-		// 	if key == "purviews" || key == "purview_urlfors" {
146
-		// 		continue
147
-		// 	}
148
-		// 	utils.TraceLog("%v: %v", key, value)
149
-		// }
154
+
150
 		utils.TraceLog("lastLoginLog : %v", lastLoginLog)
155
 		utils.TraceLog("lastLoginLog : %v", lastLoginLog)
151
 		utils.TraceLog("currentOrgId : %v", currentOrgId)
156
 		utils.TraceLog("currentOrgId : %v", currentOrgId)
152
 		utils.TraceLog("currentAppId : %v", currentAppId)
157
 		utils.TraceLog("currentAppId : %v", currentAppId)
168
 		returnJSON["orgs"] = userInfo["orgs"]
173
 		returnJSON["orgs"] = userInfo["orgs"]
169
 		returnJSON["org_app_ids"] = userInfo["org_app_ids"]
174
 		returnJSON["org_app_ids"] = userInfo["org_app_ids"]
170
 		returnJSON["org_apps"] = userInfo["org_apps"]
175
 		returnJSON["org_apps"] = userInfo["org_apps"]
171
-		returnJSON["app_to_org_ids"] = userInfo["app_to_org_ids"]
172
 		returnJSON["current_org_id"] = strconv.Itoa(currentOrgId)
176
 		returnJSON["current_org_id"] = strconv.Itoa(currentOrgId)
173
 		returnJSON["current_app_id"] = strconv.Itoa(currentAppId)
177
 		returnJSON["current_app_id"] = strconv.Itoa(currentAppId)
174
 		returnJSON["purviews"] = userInfo["purviews"]
178
 		returnJSON["purviews"] = userInfo["purviews"]
175
 		returnJSON["purview_urlfors"] = userInfo["purview_urlfors"]
179
 		returnJSON["purview_urlfors"] = userInfo["purview_urlfors"]
176
 		returnJSON["app_roles"] = userInfo["app_roles"]
180
 		returnJSON["app_roles"] = userInfo["app_roles"]
177
-		returnJSON["org_subscibes"] = userInfo["org_subscibes"]
178
 		this.Data["json"] = enums.MakeSuccessResponseJSON(returnJSON)
181
 		this.Data["json"] = enums.MakeSuccessResponseJSON(returnJSON)
179
 		this.ServeJSON()
182
 		this.ServeJSON()
180
 
183
 
262
 		utils.ErrorLog("数据错误:查找不到mobile = %v的用户", mobile)
265
 		utils.ErrorLog("数据错误:查找不到mobile = %v的用户", mobile)
263
 		return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
266
 		return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
264
 	}
267
 	}
265
-	orgs, getOrgErr := service.GetAdminUserAllOrgWithUID(adminUser.Id, adminUser.IsSuperAdmin)
268
+	orgs, getOrgErr := service.GetAdminUserAllOrgWithUID(adminUser.Id)
269
+	//去重
270
+	orgs = RemoveRepeatedPurviewElement(orgs)
271
+
266
 	if getOrgErr != nil {
272
 	if getOrgErr != nil {
267
 		utils.ErrorLog("数据错误:查找不到mobile = %v的用户所属的机构:%v", mobile, getOrgErr)
273
 		utils.ErrorLog("数据错误:查找不到mobile = %v的用户所属的机构:%v", mobile, getOrgErr)
268
 		return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
274
 		return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
272
 		return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
278
 		return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
273
 	}
279
 	}
274
 	orgIds := make([]string, 0, len(orgs))
280
 	orgIds := make([]string, 0, len(orgs))
281
+
275
 	orgJSONs := make(map[string]string)
282
 	orgJSONs := make(map[string]string)
276
 	orgAppIds := make(map[string]interface{})
283
 	orgAppIds := make(map[string]interface{})
277
 	orgApps := make(map[string]interface{})
284
 	orgApps := make(map[string]interface{})
278
-	app_to_org_ids := make(map[string]string)
279
 	app_purviewJSONs := make(map[string]string)
285
 	app_purviewJSONs := make(map[string]string)
280
 	app_purview_urls := make(map[string]string)
286
 	app_purview_urls := make(map[string]string)
281
 	app_roles := make(map[string]string)
287
 	app_roles := make(map[string]string)
282
 	org_subscibes := make(map[string]string)
288
 	org_subscibes := make(map[string]string)
289
+
283
 	for _, org := range orgs {
290
 	for _, org := range orgs {
284
 		apps, getAppsErr := service.GetAdminUserAllOrgApp(adminUser.Id, org.Id)
291
 		apps, getAppsErr := service.GetAdminUserAllOrgApp(adminUser.Id, org.Id)
285
 		if getAppsErr != nil {
292
 		if getAppsErr != nil {
286
 			utils.ErrorLog("数据错误:查找mobile = %v的用户所属机构ID为%v下的应用时错误:%v", mobile, org.Id, getAppsErr)
293
 			utils.ErrorLog("数据错误:查找mobile = %v的用户所属机构ID为%v下的应用时错误:%v", mobile, org.Id, getAppsErr)
287
 			return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
294
 			return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
288
 		}
295
 		}
289
-		if adminUser.IsSuperAdmin {
290
-			didCreateNewApp, createAppErr := this._createAppIfNeeded(adminUser.Id, org.Id, apps)
291
-			if createAppErr != nil {
292
-				return nil, createAppErr
293
-			}
294
-			if didCreateNewApp {
295
-				apps, getAppsErr = service.GetAdminUserAllOrgApp(adminUser.Id, org.Id)
296
-				if getAppsErr != nil {
297
-					utils.ErrorLog("数据错误:查找mobile = %v的用户所属机构ID为%v下的应用时错误:%v", mobile, org.Id, getAppsErr)
298
-					return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
299
-				}
300
-			}
301
-
302
-		} else {
303
-			if len(apps) == 0 {
304
-				continue
305
-			}
306
-		}
307
-
296
+		//if adminUser.IsSuperAdmin {
297
+		//	didCreateNewApp, createAppErr := this._createAppIfNeeded(adminUser.Id, org.Id, apps)
298
+		//	if createAppErr != nil {
299
+		//		return nil, createAppErr
300
+		//	}
301
+		//	if didCreateNewApp {
302
+		//		apps, getAppsErr = service.GetAdminUserAllOrgApp(org.Id)
303
+		//		if getAppsErr != nil {
304
+		//			utils.ErrorLog("数据错误:查找mobile = %v的用户所属机构ID为%v下的应用时错误:%v", mobile, org.Id, getAppsErr)
305
+		//			return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
306
+		//		}
307
+		//	}
308
+		//
309
+		//} else {
310
+		//	if len(apps) == 0 {
311
+		//		continue
312
+		//	}
313
+		//}
314
+		//
308
 		subscibe, getSubscibeErr := service.GetOrgServeSubscibe(org.Id)
315
 		subscibe, getSubscibeErr := service.GetOrgServeSubscibe(org.Id)
309
 		if getSubscibeErr != nil {
316
 		if getSubscibeErr != nil {
310
 			utils.ErrorLog("获取机构订阅信息失败:%v", getSubscibeErr)
317
 			utils.ErrorLog("获取机构订阅信息失败:%v", getSubscibeErr)
339
 		appIds := make([]string, 0, len(apps))
346
 		appIds := make([]string, 0, len(apps))
340
 		appJSONs := make(map[string]string)
347
 		appJSONs := make(map[string]string)
341
 		for _, app := range apps {
348
 		for _, app := range apps {
342
-			appJSON_b, _ := json.Marshal(app)
343
-			appJSONStr := string(appJSON_b)
344
-			appJSONs[strconv.Itoa(app.Id)] = appJSONStr
345
-			appIds = append(appIds, strconv.Itoa(app.Id))
346
-			app_to_org_ids[strconv.Itoa(app.Id)] = strconv.Itoa(org.Id)
349
+			//appJSON_b, _ := json.Marshal(app)
350
+			//appJSONStr := string(appJSON_b)
351
+			//appJSONs[strconv.Itoa(app.Id)] = appJSONStr
352
+			//appIds = append(appIds, strconv.Itoa(app.Id))
353
+			//app_to_org_ids[strconv.Itoa(app.Id)] = strconv.Itoa(org.Id)
347
 
354
 
348
 			if adminUser.IsSuperAdmin {
355
 			if adminUser.IsSuperAdmin {
349
 				urlfors, purviews, getPurviewErr := service.GetSuperAdminUsersPurviewTreeAndUrlfors(app.AppType)
356
 				urlfors, purviews, getPurviewErr := service.GetSuperAdminUsersPurviewTreeAndUrlfors(app.AppType)
369
 				}
376
 				}
370
 			}
377
 			}
371
 
378
 
372
-			appRole, getAppRoleErr := service.GetAppRole(adminUser.Id, org.Id, app.Id)
373
-			if getAppRoleErr != nil {
374
-				utils.ErrorLog("数据错误:查找id=%v,orgid=%v,appid=%v的用户信息时失败:%v", adminUser.Id, org.Id, app.Id, getAppRoleErr)
375
-				return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
379
+			appRole, _ := service.GetAppRole(adminUser.Id, org.Id, app.Id)
380
+			//if getAppRoleErr != nil {
381
+			//	utils.ErrorLog("数据错误:查找id=%v,orgid=%v,appid=%v的用户信息时失败:%v", adminUser.Id, org.Id, app.Id, getAppRoleErr)
382
+			//	return nil, &enums.SGJError{Code: enums.ErrorCodeDataException}
383
+			//}
384
+			var appRoleJSON_b []byte
385
+			if appRole != nil {
386
+				appRoleJSON_b, _ = json.Marshal(appRole)
387
+				app_roles[strconv.Itoa(app.Id)] = string(appRoleJSON_b)
376
 			}
388
 			}
377
-			appRoleJSON_b, _ := json.Marshal(appRole)
378
-			app_roles[strconv.Itoa(app.Id)] = string(appRoleJSON_b)
379
 		}
389
 		}
380
 		orgAppIds[strconv.Itoa(org.Id)] = appIds
390
 		orgAppIds[strconv.Itoa(org.Id)] = appIds
381
 		orgApps[strconv.Itoa(org.Id)] = appJSONs
391
 		orgApps[strconv.Itoa(org.Id)] = appJSONs
388
 	info["orgs"] = orgJSONs
398
 	info["orgs"] = orgJSONs
389
 	info["org_app_ids"] = orgAppIds
399
 	info["org_app_ids"] = orgAppIds
390
 	info["org_apps"] = orgApps
400
 	info["org_apps"] = orgApps
391
-	info["app_to_org_ids"] = app_to_org_ids
392
 	info["app_roles"] = app_roles
401
 	info["app_roles"] = app_roles
393
 	info["purviews"] = app_purviewJSONs
402
 	info["purviews"] = app_purviewJSONs
394
 	info["purview_urlfors"] = app_purview_urls
403
 	info["purview_urlfors"] = app_purview_urls
395
-	info["org_subscibes"] = org_subscibes
396
 	return info, nil
404
 	return info, nil
397
 }
405
 }
398
 
406
 
399
-func (this *VerifyTokenController) _createAppIfNeeded(adminUserID int, orgID int, didCreatedApps []*models.OrgApp) (bool, *enums.SGJError) {
400
-	// 已创建的应用的信息
401
-	did_patient_manage_create := false
402
-	did_dialysis_manage_create := false
403
-	did_cdm_manage_create := false
404
-	did_mall_manage_create := false
405
-	for _, app := range didCreatedApps {
406
-		if app.AppType == 1 {
407
-			did_patient_manage_create = true
408
-		} else if app.AppType == 3 {
409
-			did_dialysis_manage_create = true
410
-		} else if app.AppType == 4 {
411
-			did_cdm_manage_create = true
412
-		} else if app.AppType == 5 {
413
-			did_mall_manage_create = true
414
-		}
415
-	}
407
+//func (this *VerifyTokenController) _createAppIfNeeded(adminUserID int, orgID int, didCreatedApps []*models.OrgApp) (bool, *enums.SGJError) {
408
+//	// 已创建的应用的信息
409
+//	//did_patient_manage_create := false
410
+//	//did_dialysis_manage_create := false
411
+//	//did_cdm_manage_create := false
412
+//	//did_mall_manage_create := false
413
+//	//for _, app := range didCreatedApps {
414
+//	//	if app.AppType == 1 {
415
+//	//		did_patient_manage_create = true
416
+//	//	} else if app.AppType == 3 {
417
+//	//		did_dialysis_manage_create = true
418
+//	//	} else if app.AppType == 4 {
419
+//	//		did_cdm_manage_create = true
420
+//	//	} else if app.AppType == 5 {
421
+//	//		did_mall_manage_create = true
422
+//	//	}
423
+//	//}
424
+//
425
+//	//// 自动创建所有应用
426
+//	//didCreateNew := false
427
+//	//if did_dialysis_manage_create == false {
428
+//	//	err := service.CreateOrgApp(adminUserID, orgID, 3, false)
429
+//	//	if err != nil {
430
+//	//		utils.ErrorLog("自动创建透析管理应用失败:%v", err)
431
+//	//		return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
432
+//	//	}
433
+//	//	didCreateNew = true
434
+//	//}
435
+//	//if did_cdm_manage_create == false {
436
+//	//	err := service.CreateOrgApp(adminUserID, orgID, 4, false)
437
+//	//	if err != nil {
438
+//	//		utils.ErrorLog("自动创建慢病管理应用失败:%v", err)
439
+//	//		return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
440
+//	//	}
441
+//	//	didCreateNew = true
442
+//	//}
443
+//	//if did_patient_manage_create == false {
444
+//	//	err := service.CreateOrgApp(adminUserID, orgID, 1, false)
445
+//	//	if err != nil {
446
+//	//		utils.ErrorLog("自动创建酷医聚客应用失败:%v", err)
447
+//	//		return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
448
+//	//	}
449
+//	//	didCreateNew = true
450
+//	//}
451
+//	//if did_mall_manage_create == false {
452
+//	//	err := service.CreateOrgApp(adminUserID, orgID, 5, false)
453
+//	//	if err != nil {
454
+//	//		utils.ErrorLog("自动创建微商城应用失败:%v", err)
455
+//	//		return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
456
+//	//	}
457
+//	//	didCreateNew = true
458
+//	//}
459
+//	return true, nil
460
+//}
416
 
461
 
417
-	// 自动创建所有应用
418
-	didCreateNew := false
419
-	if did_dialysis_manage_create == false {
420
-		err := service.CreateOrgApp(adminUserID, orgID, 3, false)
421
-		if err != nil {
422
-			utils.ErrorLog("自动创建透析管理应用失败:%v", err)
423
-			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
424
-		}
425
-		didCreateNew = true
426
-	}
427
-	if did_cdm_manage_create == false {
428
-		err := service.CreateOrgApp(adminUserID, orgID, 4, false)
429
-		if err != nil {
430
-			utils.ErrorLog("自动创建慢病管理应用失败:%v", err)
431
-			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
432
-		}
433
-		didCreateNew = true
434
-	}
435
-	if did_patient_manage_create == false {
436
-		err := service.CreateOrgApp(adminUserID, orgID, 1, false)
437
-		if err != nil {
438
-			utils.ErrorLog("自动创建酷医聚客应用失败:%v", err)
439
-			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
462
+func RemoveRepeatedPurviewElement(org []*models.Org) (orgs []*models.Org) {
463
+	orgs = make([]*models.Org, 0)
464
+	for i := 0; i < len(org); i++ {
465
+		repeat := false
466
+		for j := i + 1; j < len(org); j++ {
467
+			if org[i].Id == org[j].Id {
468
+				repeat = true
469
+				break
470
+			}
440
 		}
471
 		}
441
-		didCreateNew = true
442
-	}
443
-	if did_mall_manage_create == false {
444
-		err := service.CreateOrgApp(adminUserID, orgID, 5, false)
445
-		if err != nil {
446
-			utils.ErrorLog("自动创建微商城应用失败:%v", err)
447
-			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
472
+		if !repeat {
473
+			orgs = append(orgs, org[i])
448
 		}
474
 		}
449
-		didCreateNew = true
450
 	}
475
 	}
451
-	return didCreateNew, nil
476
+	return
452
 }
477
 }

+ 1 - 0
models/admin_user_models.go Datei anzeigen

8
 	Status       int8   `json:"status"`                                      // 状态 0.无效 1.有效
8
 	Status       int8   `json:"status"`                                      // 状态 0.无效 1.有效
9
 	CreateTime   int64  `gorm:"column:ctime" json:"ctime"`                   // 创建时间
9
 	CreateTime   int64  `gorm:"column:ctime" json:"ctime"`                   // 创建时间
10
 	ModifyTime   int64  `gorm:"column:mtime" json:"mtime"`                   // 修改时间
10
 	ModifyTime   int64  `gorm:"column:mtime" json:"mtime"`                   // 修改时间
11
+	Name         string `gorm:"column:name" json:"name" form:"name"`
11
 }
12
 }
12
 
13
 
13
 func (AdminUser) TableName() string {
14
 func (AdminUser) TableName() string {

+ 1 - 0
models/associative_table_models.go Datei anzeigen

14
 	Status      int8   // 状态 0.无效 1.有效
14
 	Status      int8   // 状态 0.无效 1.有效
15
 	CreateTime  int64  `gorm:"column:ctime" json:"ctime"` // 创建时间
15
 	CreateTime  int64  `gorm:"column:ctime" json:"ctime"` // 创建时间
16
 	ModifyTime  int64  `gorm:"column:mtime" json:"mtime"` // 修改时间
16
 	ModifyTime  int64  `gorm:"column:mtime" json:"mtime"` // 修改时间
17
+	RoleIds     string `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
17
 }
18
 }
18
 
19
 
19
 func (App_Role) TableName() string {
20
 func (App_Role) TableName() string {

+ 17 - 0
models/role_models.go Datei anzeigen

11
 	Status       int8  // 状态 0.无效 1.有效 2.禁用
11
 	Status       int8  // 状态 0.无效 1.有效 2.禁用
12
 	CreateTime   int64 `gorm:"column:ctime"` // 创建时间
12
 	CreateTime   int64 `gorm:"column:ctime"` // 创建时间
13
 	ModifyTime   int64 `gorm:"column:mtime"` // 修改时间
13
 	ModifyTime   int64 `gorm:"column:mtime"` // 修改时间
14
+	Number       int64 `gorm:"number" json:"number"`
15
+	IsSystem     int64 `gorm:"column:is_system" json:"is_system" form:"is_system"`
14
 }
16
 }
15
 
17
 
16
 func (Role) TableName() string {
18
 func (Role) TableName() string {
51
 func (RolePurview) TableName() string {
53
 func (RolePurview) TableName() string {
52
 	return "sgj_user_role_purview"
54
 	return "sgj_user_role_purview"
53
 }
55
 }
56
+
57
+type SgjUserRoleFuncPurview struct {
58
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
59
+	OrgId      int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
60
+	AppId      int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
61
+	RoleId     int64  `gorm:"column:role_id" json:"role_id" form:"role_id"`
62
+	PurviewIds string `gorm:"column:purview_ids" json:"purview_ids" form:"purview_ids"`
63
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
64
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
65
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
66
+}
67
+
68
+func (SgjUserRoleFuncPurview) TableName() string {
69
+	return "sgj_user_role_func_purview"
70
+}

+ 315 - 0
models/vm_models.go Datei anzeigen

1
+package models
2
+
3
+type VMOrgPatients struct {
4
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	UserId                       int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
7
+	Avatar                       string  `gorm:"column:avatar" json:"avatar" form:"avatar"`
8
+	PatientType                  int64   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
9
+	DialysisNo                   string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
10
+	AdmissionNumber              string  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
11
+	Source                       int64   `gorm:"column:source" json:"source" form:"source"`
12
+	Lapseto                      int64   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
13
+	PartitionId                  int64   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
14
+	BedId                        int64   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
15
+	Name                         string  `gorm:"column:name" json:"name" form:"name"`
16
+	Alias                        string  `gorm:"column:alias" json:"alias" form:"alias"`
17
+	Gender                       int64   `gorm:"column:gender" json:"gender" form:"gender"`
18
+	Nation                       string  `gorm:"column:nation" json:"nation" form:"nation"`
19
+	NativePlace                  string  `gorm:"column:native_place" json:"native_place" form:"native_place"`
20
+	MaritalStatus                int64   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
21
+	IdCardNo                     string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
22
+	Birthday                     int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
23
+	ReimbursementWayId           int64   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
24
+	HealthCareType               int64   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
25
+	HealthCareNo                 string  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
26
+	HealthCareDueDate            int64   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
27
+	Height                       int64   `gorm:"column:height" json:"height" form:"height"`
28
+	BloodType                    int64   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
29
+	Rh                           int64   `gorm:"column:rh" json:"rh" form:"rh"`
30
+	HealthCareDueAlertDate       int64   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
31
+	EducationLevel               int64   `gorm:"column:education_level" json:"education_level" form:"education_level"`
32
+	Profession                   int64   `gorm:"column:profession" json:"profession" form:"profession"`
33
+	Phone                        string  `gorm:"column:phone" json:"phone" form:"phone"`
34
+	HomeTelephone                string  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
35
+	RelativePhone                string  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
36
+	RelativeRelations            string  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
37
+	HomeAddress                  string  `gorm:"column:home_address" json:"home_address" form:"home_address"`
38
+	WorkUnit                     string  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
39
+	UnitAddress                  string  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
40
+	Children                     int64   `gorm:"column:children" json:"children" form:"children"`
41
+	ReceivingDate                int64   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
42
+	IsHospitalFirstDialysis      int64   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
43
+	FirstDialysisDate            int64   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
44
+	FirstDialysisHospital        string  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
45
+	PredialysisCondition         string  `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
46
+	PreHospitalDialysisFrequency string  `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
47
+	PreHospitalDialysisTimes     int64   `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
48
+	HospitalFirstDialysisDate    int64   `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
49
+	InductionPeriod              int64   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
50
+	InitialDialysis              int64   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
51
+	TotalDialysis                int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
52
+	AttendingDoctorId            int64   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
53
+	HeadNurseId                  int64   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
54
+	Evaluate                     string  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
55
+	Diagnose                     string  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
56
+	Remark                       string  `gorm:"column:remark" json:"remark" form:"remark"`
57
+	RegistrarsId                 int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
58
+	Registrars                   string  `gorm:"column:registrars" json:"registrars" form:"registrars"`
59
+	QrCode                       string  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
60
+	BindingState                 int64   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
61
+	PatientComplains             string  `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
62
+	PresentHistory               string  `gorm:"column:present_history" json:"present_history"`     // 现病史
63
+	PastHistory                  string  `gorm:"column:past_history" json:"past_history"`           // 既往史
64
+	Temperature                  float64 `gorm:"column:temperature" json:"temperature"`             // 体格检查-体温
65
+	Pulse                        int64   `gorm:"column:pulse" json:"pulse"`                         // 体格检查-脉搏
66
+	Respiratory                  int64   `gorm:"column:respiratory" json:"respiratory"`             // 体格检查-呼吸频率
67
+	SBP                          int64   `gorm:"column:sbp" json:"sbp"`                             // 体格检查-收缩压
68
+	DBP                          int64   `gorm:"column:dbp" json:"dbp"`                             // 体格检查-舒张压
69
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
70
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
71
+	UpdatedTime                  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
72
+	Age                          int64   `gorm:"column:age" json:"age"`
73
+
74
+	InfectiousNextRecordTime int64  `gorm:"column:infectious_next_record_time" json:"infectious_next_record_time"`
75
+	IsInfectious             int64  `gorm:"column:is_infectious" json:"is_infectious"`
76
+	RemindCycle              int64  `gorm:"column:remind_cycle" json:"remind_cycle"`
77
+	ResponseResult           string `gorm:"column:response_result" json:"response_result"`
78
+	IsOpenRemind             int64  `gorm:"column:is_open_remind" json:"is_open_remind"`
79
+	DialysisAge              int64  `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
80
+	ExpenseKind              int64  `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
81
+	TellPhone                string `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
82
+	FirstTreatmentDate       int64  `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
83
+	ContactName              string `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
84
+}
85
+
86
+func (VMOrgPatients) TableName() string {
87
+	return "xt_patients"
88
+}
89
+
90
+type VMDeviceGroup struct {
91
+	ID     int64  `gorm:"column:id" json:"id" form:"id"`
92
+	OrgId  int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
93
+	Name   string `gorm:"column:name" json:"name" form:"name"`
94
+	Status int64  `gorm:"column:status" json:"status" form:"status"`
95
+	Ctime  int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
96
+	Mtime  int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
97
+}
98
+
99
+func (VMDeviceGroup) TableName() string {
100
+	return "xt_device_group"
101
+}
102
+
103
+type VMDeviceZone struct {
104
+	ID     int64  `gorm:"column:id" json:"id" form:"id"`
105
+	OrgId  int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
106
+	Name   string `gorm:"column:name" json:"name" form:"name"`
107
+	Type   int64  `gorm:"column:type" json:"type" form:"type"`
108
+	Status int64  `gorm:"column:status" json:"status" form:"status"`
109
+	Ctime  int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
110
+	Mtime  int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
111
+}
112
+
113
+func (VMDeviceZone) TableName() string {
114
+	return "xt_device_zone"
115
+}
116
+
117
+type VMDeviceNumber struct {
118
+	ID      int64  `gorm:"column:id" json:"id" form:"id"`
119
+	OrgId   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
120
+	Number  string `gorm:"column:number" json:"number" form:"number"`
121
+	GroupId int64  `gorm:"column:group_id" json:"group_id" form:"group_id"`
122
+	ZoneId  int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
123
+	Status  int64  `gorm:"column:status" json:"status" form:"status"`
124
+	Ctime   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
125
+	Mtime   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
126
+}
127
+
128
+func (VMDeviceNumber) TableName() string {
129
+	return "xt_device_number"
130
+}
131
+
132
+type VMSchedule struct {
133
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
134
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
135
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
136
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
137
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
138
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
139
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
140
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
141
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
142
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
143
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
144
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
145
+}
146
+
147
+func (VMSchedule) TableName() string {
148
+	return "xt_schedule"
149
+}
150
+
151
+type VMApp_Role struct {
152
+	Id          int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
153
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id"`
154
+	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
155
+	Org         []*Org `gorm:"ForeignKey:ID;AssociationForeignKey:OrgId" json:"orgs"`
156
+}
157
+
158
+func (VMApp_Role) TableName() string {
159
+	return "sgj_user_admin_role"
160
+}
161
+
162
+type VMAdminUser struct {
163
+	ID         int64         `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"` // 管理员用户 ID
164
+	Org        []*Org        `gorm:"ForeignKey:Creator;AssociationForeignKey:ID" json:"orgs"`
165
+	VMApp_Role []*VMApp_Role `gorm:"ForeignKey:AdminUserId;AssociationForeignKey:ID" json:"roles"`
166
+}
167
+
168
+func (VMAdminUser) TableName() string {
169
+	return "sgj_user_admin"
170
+}
171
+
172
+type VMAdminBanner struct {
173
+	ID     int64  `gorm:"column:id" json:"id" form:"id"`
174
+	Thumb  string `gorm:"column:thumb" json:"thumb" form:"thumb"`
175
+	Url    string `gorm:"column:url" json:"url" form:"url"`
176
+	Status int64  `gorm:"column:status" json:"status" form:"status"`
177
+	Ctime  int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
178
+	Mtime  int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
179
+	Title  string `gorm:"column:title" json:"title" form:"title"`
180
+	Desc   string `gorm:"column:desc" json:"desc" form:"desc"`
181
+}
182
+
183
+func (VMAdminBanner) TableName() string {
184
+	return "sgj_admin_banner"
185
+}
186
+
187
+type VMPatientScheduleTemplateId struct {
188
+	ID     int64 `gorm:"column:id" json:"id" form:"id"`
189
+	OrgId  int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
190
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
191
+	Ctime  int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
192
+	Mtime  int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
193
+}
194
+
195
+func (VMPatientScheduleTemplateId) TableName() string {
196
+	return "xt_patient_schedule_template_id"
197
+}
198
+
199
+type VMPatientScheduleTemplateItem struct {
200
+	ID             int64 `gorm:"column:id" json:"id" form:"id"`
201
+	OrgId          int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
202
+	TemplateId     int64 `gorm:"column:template_id" json:"template_id" form:"template_id"`
203
+	DeviceNumberId int64 `gorm:"column:device_number_id" json:"device_number_id" form:"device_number_id"`
204
+	PatientId      int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
205
+	TreatMode      int64 `gorm:"column:treat_mode" json:"treat_mode" form:"treat_mode"`
206
+	Weekday        int64 `gorm:"column:weekday" json:"weekday" form:"weekday"`
207
+	TimeType       int64 `gorm:"column:time_type" json:"time_type" form:"time_type"`
208
+	Status         int64 `gorm:"column:status" json:"status" form:"status"`
209
+	Ctime          int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
210
+	Mtime          int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
211
+}
212
+
213
+func (VMPatientScheduleTemplateItem) TableName() string {
214
+	return "xt_patient_schedule_template_item"
215
+}
216
+
217
+type VMPatientScheduleTemplateMode struct {
218
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
219
+	OrgId        int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
220
+	Mode         int64 `gorm:"column:mode" json:"mode" form:"mode"`
221
+	ExecuteTimes int64 `gorm:"column:execute_times" json:"execute_times" form:"execute_times"`
222
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
223
+	Ctime        int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
224
+	Mtime        int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
225
+}
226
+
227
+func (VMPatientScheduleTemplateMode) TableName() string {
228
+	return "xt_patient_schedule_template_mode"
229
+}
230
+
231
+type VMDeviceMode struct {
232
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
233
+	DeviceMode string `gorm:"column:device_mode" json:"device_mode" form:"device_mode"`
234
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
235
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
236
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
237
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
238
+}
239
+
240
+func (VMDeviceMode) TableName() string {
241
+	return "xt_device_mode"
242
+}
243
+
244
+type VmDeviceAddmacher struct {
245
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
246
+	SerialNumber        string `gorm:"column:serial_number" json:"serial_number" form:"serial_number"`
247
+	DeviceType          int64  `gorm:"column:device_type" json:"device_type" form:"device_type"`
248
+	BedNumber           string `gorm:"column:bed_number" json:"bed_number" form:"bed_number"`
249
+	DeviceName          string `gorm:"column:device_name" json:"device_name" form:"device_name"`
250
+	ManufactureFactory  string `gorm:"column:manufacture_factory" json:"manufacture_factory" form:"manufacture_factory"`
251
+	ServiceManufacturer string `gorm:"column:service_manufacturer" json:"service_manufacturer" form:"service_manufacturer"`
252
+	UnitType            int64  `gorm:"column:unit_type" json:"unit_type" form:"unit_type"`
253
+	UseSection          string `gorm:"column:use_section" json:"use_section" form:"use_section"`
254
+	SectionNumber       string `gorm:"column:section_number" json:"section_number" form:"section_number"`
255
+	BuyDate             int64  `gorm:"column:buy_date" json:"buy_date" form:"buy_date"`
256
+	InstallDate         int64  `gorm:"column:install_date" json:"install_date" form:"install_date"`
257
+	StartDate           int64  `gorm:"column:start_date" json:"start_date" form:"start_date"`
258
+	MaintenaceEngineer  string `gorm:"column:maintenace_engineer" json:"maintenace_engineer" form:"maintenace_engineer"`
259
+	Telephone           string `gorm:"column:telephone" json:"telephone" form:"telephone"`
260
+	GuaranteeDate       string `gorm:"column:guarantee_date" json:"guarantee_date" form:"guarantee_date"`
261
+	MachineStatus       int64  `gorm:"column:machine_status" json:"machine_status" form:"machine_status"`
262
+	UserTotal           string `gorm:"column:user_total" json:"user_total" form:"user_total"`
263
+	DisinfectionMode    int64  `gorm:"column:disinfection_mode" json:"disinfection_mode" form:"disinfection_mode"`
264
+	Remarks             string `gorm:"column:remarks" json:"remarks" form:"remarks"`
265
+	RubbishDate         int64  `gorm:"column:rubbish_date" json:"rubbish_date" form:"rubbish_date"`
266
+	RubbishReason       int64  `gorm:"column:rubbish_reason" json:"rubbish_reason" form:"rubbish_reason"`
267
+	UserYear            string `gorm:"column:user_year" json:"user_year" form:"user_year"`
268
+	WorkTime            string `gorm:"column:work_time" json:"work_time" form:"work_time"`
269
+	ReversMode          int64  `gorm:"column:revers_mode" json:"revers_mode" form:"revers_mode"`
270
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
271
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
272
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
273
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
274
+	ZoneId              int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
275
+	BedId               int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
276
+}
277
+
278
+func (VmDeviceAddmacher) TableName() string {
279
+	return "xt_device_addmacher"
280
+}
281
+
282
+type VmDeviceTreatmentmode struct {
283
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
284
+	MachineId  int64 `gorm:"column:machine_id" json:"machine_id" form:"machine_id"`
285
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
286
+	Ctime      int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
287
+	Mtime      int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
288
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
289
+	TreateMode int64 `gorm:"column:treate_mode" json:"treate_mode" form:"treate_mode"`
290
+}
291
+
292
+func (VmDeviceTreatmentmode) TableName() string {
293
+	return "xt_device_treatmentmode"
294
+}
295
+
296
+type VMUserRoleAndPurview struct {
297
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
298
+	RoleName         string `gorm:"column:role_name" json:"role_name" form:"role_name"`
299
+	RoleIntroduction string `gorm:"column:role_introduction" json:"role_introduction" form:"role_introduction"`
300
+	Creator          int64  `gorm:"column:creator" json:"creator" form:"creator"`
301
+	OrgId            int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
302
+	AppId            int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
303
+	IsSuperAdmin     int64  `gorm:"column:is_super_admin" json:"is_super_admin" form:"is_super_admin"`
304
+	Status           int64  `gorm:"column:status" json:"status" form:"status"`
305
+	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
306
+	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
307
+	Number           int64  `gorm:"column:number" json:"number" form:"number"`
308
+	PurviewIds       string `gorm:"column:-" json:"purview_ids" form:"purview_ids"`
309
+	FuncIds          string `gorm:"column:-" json:"func_ids" form:"func_ids"`
310
+	IsSystem         int64  `gorm:"column:is_system" json:"is_system" form:"is_system"`
311
+}
312
+
313
+func (VMUserRoleAndPurview) TableName() string {
314
+	return "sgj_user_role"
315
+}

+ 159 - 0
models/xt_models.go Datei anzeigen

1
+package models
2
+
3
+type SystemPrescription struct {
4
+	ID                         int64   `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	PatientId                  int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
7
+	Anticoagulant              int64   `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
8
+	AnticoagulantShouji        float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji" form:"anticoagulant_shouji"`
9
+	AnticoagulantWeichi        float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi" form:"anticoagulant_weichi"`
10
+	AnticoagulantZongliang     float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
11
+	AnticoagulantGaimingcheng  string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng" form:"anticoagulant_gaimingcheng"`
12
+	AnticoagulantGaijiliang    string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang" form:"anticoagulant_gaijiliang"`
13
+	ModeId                     int64   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
14
+	DialysisDuration           float64 `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
15
+	ReplacementWay             int64   `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
16
+	HemodialysisMachine        int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
17
+	BloodFilter                int64   `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
18
+	PerfusionApparatus         int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
19
+	BloodFlowVolume            float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
20
+	Dewater                    float64 `gorm:"column:dewater" json:"dewater" form:"dewater"`
21
+	DisplaceLiqui              float64 `gorm:"column:displace_liqui" json:"displace_liqui" form:"displace_liqui"`
22
+	Glucose                    float64 `gorm:"column:glucose" json:"glucose" form:"glucose"`
23
+	DryWeight                  float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
24
+	DialysateFlow              float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
25
+	Kalium                     float64 `gorm:"column:kalium" json:"kalium" form:"kalium"`
26
+	Sodium                     float64 `gorm:"column:sodium" json:"sodium" form:"sodium"`
27
+	Calcium                    float64 `gorm:"column:calcium" json:"calcium" form:"calcium"`
28
+	Bicarbonate                float64 `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
29
+	Doctor                     int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
30
+	FirstDialysis              int64   `gorm:"column:first_dialysis" json:"first_dialysis" form:"first_dialysis"`
31
+	Remark                     string  `gorm:"column:remark" json:"remark" form:"remark"`
32
+	InitiateMode               int64   `gorm:"column:initiate_mode" json:"initiate_mode" form:"initiate_mode"`
33
+	AffirmState                int64   `gorm:"column:affirm_state" json:"affirm_state" form:"affirm_state"`
34
+	UseState                   int64   `gorm:"column:use_state" json:"use_state" form:"use_state"`
35
+	Status                     int64   `gorm:"column:status" json:"status" form:"status"`
36
+	RegistrarsId               int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
37
+	CreatedTime                int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
38
+	UpdatedTime                int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
39
+	SolutionType               int64   `gorm:"column:solution_type" json:"solution_type" form:"solution_type"`
40
+	DialysateTemperature       float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature" form:"dialysate_temperature"`
41
+	Conductivity               float64 `gorm:"column:conductivity" json:"conductivity" form:"conductivity"`
42
+	DialysisDurationHour       int64   `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour" form:"dialysis_duration_hour"`
43
+	DialysisDurationMinute     int64   `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute" form:"dialysis_duration_minute"`
44
+	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration" form:"target_ultrafiltration"`
45
+	DialysateFormulation       int64   `gorm:"column:dialysate_formulation" json:"dialysate_formulation" form:"dialysate_formulation"`
46
+	Dialyzer                   int64   `gorm:"column:dialyzer" json:"dialyzer" form:"dialyzer"`
47
+	ReplacementTotal           float64 `gorm:"column:replacement_total" json:"replacement_total" form:"replacement_total"`
48
+	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
49
+	BodyFluid                  int64   `gorm:"column:body_fluid" json:"body_fluid" form:"body_fluid"`
50
+	SpecialMedicine            int64   `gorm:"column:special_medicine" json:"special_medicine" form:"special_medicine"`
51
+	SpecialMedicineOther       string  `gorm:"column:special_medicine_other" json:"special_medicine_other" form:"special_medicine_other"`
52
+	DisplaceLiquiPart          int64   `gorm:"column:displace_liqui_part" json:"displace_liqui_part" form:"displace_liqui_part"`
53
+	DisplaceLiquiValue         float64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value" form:"displace_liqui_value"`
54
+	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access" form:"blood_access"`
55
+	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration" form:"ultrafiltration"`
56
+	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other" form:"body_fluid_other"`
57
+	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv" form:"target_ktv"`
58
+}
59
+
60
+func (SystemPrescription) TableName() string {
61
+	return "xt_system_prescription"
62
+}
63
+
64
+type XtPatientsNew struct {
65
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
66
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
67
+	UserId                       int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
68
+	Avatar                       string  `gorm:"column:avatar" json:"avatar" form:"avatar"`
69
+	PatientType                  int64   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
70
+	DialysisNo                   string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
71
+	AdmissionNumber              string  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
72
+	Source                       int64   `gorm:"column:source" json:"source" form:"source"`
73
+	Lapseto                      int64   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
74
+	PartitionId                  int64   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
75
+	BedId                        int64   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
76
+	Name                         string  `gorm:"column:name" json:"name" form:"name"`
77
+	Alias                        string  `gorm:"column:alias" json:"alias" form:"alias"`
78
+	Gender                       int64   `gorm:"column:gender" json:"gender" form:"gender"`
79
+	MaritalStatus                int64   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
80
+	IdCardNo                     string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
81
+	Birthday                     int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
82
+	ReimbursementWayId           int64   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
83
+	HealthCareType               int64   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
84
+	HealthCareNo                 string  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
85
+	HealthCareDueDate            int64   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
86
+	Height                       int64   `gorm:"column:height" json:"height" form:"height"`
87
+	BloodType                    int64   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
88
+	Rh                           int64   `gorm:"column:rh" json:"rh" form:"rh"`
89
+	HealthCareDueAlertDate       int64   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
90
+	EducationLevel               int64   `gorm:"column:education_level" json:"education_level" form:"education_level"`
91
+	Profession                   int64   `gorm:"column:profession" json:"profession" form:"profession"`
92
+	Phone                        string  `gorm:"column:phone" json:"phone" form:"phone"`
93
+	HomeTelephone                string  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
94
+	RelativePhone                string  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
95
+	RelativeRelations            string  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
96
+	HomeAddress                  string  `gorm:"column:home_address" json:"home_address" form:"home_address"`
97
+	WorkUnit                     string  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
98
+	UnitAddress                  string  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
99
+	Children                     int64   `gorm:"column:children" json:"children" form:"children"`
100
+	ReceivingDate                int64   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
101
+	IsHospitalFirstDialysis      int64   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
102
+	FirstDialysisDate            int64   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
103
+	FirstDialysisHospital        string  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
104
+	PredialysisCondition         string  `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
105
+	PreHospitalDialysisFrequency string  `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
106
+	PreHospitalDialysisTimes     int64   `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
107
+	HospitalFirstDialysisDate    int64   `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
108
+	InductionPeriod              int64   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
109
+	InitialDialysis              int64   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
110
+	TotalDialysis                int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
111
+	AttendingDoctorId            int64   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
112
+	HeadNurseId                  int64   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
113
+	Evaluate                     string  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
114
+	Diagnose                     string  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
115
+	Remark                       string  `gorm:"column:remark" json:"remark" form:"remark"`
116
+	RegistrarsId                 int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
117
+	Registrars                   string  `gorm:"column:registrars" json:"registrars" form:"registrars"`
118
+	QrCode                       string  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
119
+	BindingState                 int64   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
120
+	PatientComplains             string  `gorm:"column:patient_complains" json:"patient_complains" form:"patient_complains"`
121
+	PresentHistory               string  `gorm:"column:present_history" json:"present_history" form:"present_history"`
122
+	PastHistory                  string  `gorm:"column:past_history" json:"past_history" form:"past_history"`
123
+	Temperature                  float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
124
+	Pulse                        int64   `gorm:"column:pulse" json:"pulse" form:"pulse"`
125
+	Respiratory                  int64   `gorm:"column:respiratory" json:"respiratory" form:"respiratory"`
126
+	Sbp                          int64   `gorm:"column:sbp" json:"sbp" form:"sbp"`
127
+	Dbp                          int64   `gorm:"column:dbp" json:"dbp" form:"dbp"`
128
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
129
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
130
+	UpdatedTime                  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
131
+	Nation                       string  `gorm:"column:nation" json:"nation" form:"nation"`
132
+	NativePlace                  string  `gorm:"column:native_place" json:"native_place" form:"native_place"`
133
+	Age                          int64   `gorm:"column:age" json:"age" form:"age"`
134
+	InfectiousNextRecordTime     int64   `gorm:"column:infectious_next_record_time" json:"infectious_next_record_time" form:"infectious_next_record_time"`
135
+	IsInfectious                 int64   `gorm:"column:is_infectious" json:"is_infectious" form:"is_infectious"`
136
+	RemindCycle                  int64   `gorm:"column:remind_cycle" json:"remind_cycle" form:"remind_cycle"`
137
+	ResponseResult               string  `gorm:"column:response_result" json:"response_result" form:"response_result"`
138
+	IsOpenRemind                 int64   `gorm:"column:is_open_remind" json:"is_open_remind" form:"is_open_remind"`
139
+	FirstTreatmentDate           int64   `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
140
+	DialysisAge                  int64   `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
141
+	ExpenseKind                  int64   `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
142
+	TellPhone                    string  `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
143
+	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
144
+	BloodPatients                int64   `gorm:"column:blood_patients" json:"blood_patients" form:"blood_patients"`
145
+	SlowPatients                 int64   `gorm:"column:slow_patients" json:"slow_patients" form:"slow_patients"`
146
+	MemberPatients               int64   `gorm:"column:member_patients" json:"member_patients" form:"member_patients"`
147
+	EcommerPatients              string  `gorm:"column:ecommer_patients" json:"ecommer_patients" form:"ecommer_patients"`
148
+	BloodId                      int64   `gorm:"column:blood_id" json:"blood_id" form:"blood_id"`
149
+	SlowId                       int64   `gorm:"column:slow_id" json:"slow_id" form:"slow_id"`
150
+	MemberId                     int64   `gorm:"column:member_id" json:"member_id" form:"member_id"`
151
+	MemberFistdate               int64   `gorm:"column:member_fistdate" json:"member_fistdate" form:"member_fistdate"`
152
+	MemberPatienttype            int64   `gorm:"column:member_patienttype" json:"member_patienttype" form:"member_patienttype"`
153
+	MemberTreatement             int64   `gorm:"column:member_treatement" json:"member_treatement" form:"member_treatement"`
154
+	EquitmentId                  string  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
155
+}
156
+
157
+func (XtPatientsNew) TableName() string {
158
+	return "xt_patients_new"
159
+}

+ 2 - 1
routers/router.go Datei anzeigen

43
 
43
 
44
 	beego.Router("/org/create", &controllers.OrgController{}, "get:Create")
44
 	beego.Router("/org/create", &controllers.OrgController{}, "get:Create")
45
 	beego.Router("/org/create/submit", &controllers.OrgController{}, "post:CreateSubmit")
45
 	beego.Router("/org/create/submit", &controllers.OrgController{}, "post:CreateSubmit")
46
-	beego.Router("/org/admin/apps", &controllers.OrgController{}, "get:ViewApps")
46
+	//beego.Router("/org/admin/apps", &controllers.OrgController{}, "get:ViewApps")
47
 	beego.Router("/org/app/create", &controllers.OrgController{}, "get:CreateApp")
47
 	beego.Router("/org/app/create", &controllers.OrgController{}, "get:CreateApp")
48
 	// beego.Router("/org/app/create/submit", &controllers.OrgController{}, "post:CreateAppSubmit")
48
 	// beego.Router("/org/app/create/submit", &controllers.OrgController{}, "post:CreateAppSubmit")
49
 	beego.Router("/app/open", &controllers.OrgController{}, "post:OpenAppSubmit")
49
 	beego.Router("/app/open", &controllers.OrgController{}, "post:OpenAppSubmit")
63
 	})
63
 	})
64
 
64
 
65
 	beego.Router("/m/login/pwd", &controllers.MobileLoginController{}, "post:LoginByPwd")
65
 	beego.Router("/m/login/pwd", &controllers.MobileLoginController{}, "post:LoginByPwd")
66
+	beego.Router("/m/login/code", &controllers.MobileLoginController{}, "post:LoginByCode")
66
 
67
 
67
 	beego.Router("/mobile/regist", &controllers.MobileRegistController{}, "get:Register")
68
 	beego.Router("/mobile/regist", &controllers.MobileRegistController{}, "get:Register")
68
 	beego.Router("/mobile/regist/submit", &controllers.MobileRegistController{}, "post:RegistSubmit")
69
 	beego.Router("/mobile/regist/submit", &controllers.MobileRegistController{}, "post:RegistSubmit")

+ 33 - 0
service/db.go Datei anzeigen

28
 var writeDb *gorm.DB
28
 var writeDb *gorm.DB
29
 var readUserDb *gorm.DB
29
 var readUserDb *gorm.DB
30
 var writeUserDb *gorm.DB
30
 var writeUserDb *gorm.DB
31
+var readXTDb *gorm.DB
32
+var writeXTDb *gorm.DB
31
 var err error
33
 var err error
32
 
34
 
33
 // var gormDb *gorm.DB
35
 // var gormDb *gorm.DB
57
 	writeUserPass := beego.AppConfig.String("writeuserpass")
59
 	writeUserPass := beego.AppConfig.String("writeuserpass")
58
 	writeUserName := beego.AppConfig.String("writeusername")
60
 	writeUserName := beego.AppConfig.String("writeusername")
59
 
61
 
62
+	readXTHost := beego.AppConfig.String("readsqlhost")
63
+	readXTPort := beego.AppConfig.String("readsqlport")
64
+	readXTUser := beego.AppConfig.String("readsqluser")
65
+	readXTPass := beego.AppConfig.String("readsqlpass")
66
+	readXTName := beego.AppConfig.String("readsqlname")
67
+
68
+	writeXTHost := beego.AppConfig.String("writesqlhost")
69
+	writeXTPort := beego.AppConfig.String("writesqlport")
70
+	writeXTUser := beego.AppConfig.String("writesqluser")
71
+	writeXTPass := beego.AppConfig.String("writesqlpass")
72
+	writeXTName := beego.AppConfig.String("writesqlname")
73
+
74
+	rxdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readXTUser, readXTPass, readXTHost, readXTPort, readXTName)
75
+	wxdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeXTUser, writeXTPass, writeXTHost, writeXTPort, writeXTName)
76
+
60
 	rdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser, readPass, readHost, readPort, readName)
77
 	rdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser, readPass, readHost, readPort, readName)
61
 	wdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUser, writePass, writeHost, writePort, writeName)
78
 	wdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUser, writePass, writeHost, writePort, writeName)
62
 
79
 
95
 	writeUserDb.DB().SetMaxOpenConns(100)
112
 	writeUserDb.DB().SetMaxOpenConns(100)
96
 	writeUserDb.LogMode(true)
113
 	writeUserDb.LogMode(true)
97
 
114
 
115
+	readXTDb, err = gorm.Open("mysql", rxdsn)
116
+	if err != nil {
117
+		beego.Error(err)
118
+	}
119
+	readXTDb.DB().SetMaxIdleConns(10)
120
+	readXTDb.DB().SetMaxOpenConns(100)
121
+	readXTDb.LogMode(true)
122
+
123
+	writeXTDb, err = gorm.Open("mysql", wxdsn)
124
+	if err != nil {
125
+		beego.Error(err)
126
+	}
127
+	writeXTDb.DB().SetMaxIdleConns(10)
128
+	writeXTDb.DB().SetMaxOpenConns(100)
129
+	writeXTDb.LogMode(true)
130
+
98
 	// gormDb,err = gorm.Open("mysql", "shenyh:syh@#$%123456!@tcp(112.74.16.180:3306)/sgj_patient?charset=utf8mb4&parseTime=true&loc=Local")
131
 	// gormDb,err = gorm.Open("mysql", "shenyh:syh@#$%123456!@tcp(112.74.16.180:3306)/sgj_patient?charset=utf8mb4&parseTime=true&loc=Local")
99
 	// gormDb.DB().SetMaxIdleConns(10)
132
 	// gormDb.DB().SetMaxIdleConns(10)
100
 	// gormDb.DB().SetMaxOpenConns(100)
133
 	// gormDb.DB().SetMaxOpenConns(100)

+ 64 - 27
service/login_service.go Datei anzeigen

61
 	var record models.AdminUserLoginLog
61
 	var record models.AdminUserLoginLog
62
 	var err error
62
 	var err error
63
 	if appType > 0 {
63
 	if appType > 0 {
64
-		err = readUserDb.Last(&record, "admin_user_id = ? AND operate_type <> 2 AND app_type = ?", adminUserID, appType).Error
64
+		err = readUserDb.Last(&record, "admin_user_id = ? AND operate_type <> 2 AND app_type = 3", adminUserID).Error
65
 	} else {
65
 	} else {
66
 		err = readUserDb.Last(&record, "admin_user_id = ? AND operate_type <> 2", adminUserID).Error
66
 		err = readUserDb.Last(&record, "admin_user_id = ? AND operate_type <> 2", adminUserID).Error
67
 	}
67
 	}
88
 	}
88
 	}
89
 }
89
 }
90
 
90
 
91
-func GetAdminUserAllOrgWithUID(adminUserID int, isSuperAdmin bool) ([]*models.Org, error) {
92
-	if isSuperAdmin {
93
-		var org models.Org
94
-		err := readUserDb.Preload("OrgGallery", "status = 1").Where("creator = ? AND status <> 0", adminUserID).First(&org).Error
95
-		if err != nil {
96
-			return nil, err
97
-		}
98
-		return []*models.Org{&org}, nil
91
+func GetAdminUserAllOrgWithUID(adminUserID int) ([]*models.Org, error) {
92
+	//var org []*models.Org
93
+
94
+	orgs := make([]*models.Org, 0)
95
+	//
96
+	//var org []*models.Org
97
+	//err := readUserDb.Preload("OrgGallery", "status = 1").Where("creator = ? AND status <> 0", adminUserID).Find(&org).Error
99
 
98
 
99
+	//orgs = append(orgs, org...)
100
+	rows, err := readUserDb.Raw("SELECT org.*, COUNT(DISTINCT org.id) FROM sgj_user_admin_role AS u_r, sgj_user_org AS org WHERE u_r.admin_user_id = ? AND u_r.org_id = org.id AND u_r.status = 1 AND org.status <> 0 GROUP BY org.id ORDER BY org.id;", adminUserID).Rows()
101
+	defer rows.Close()
102
+	if err != nil {
103
+		return nil, err
100
 	} else {
104
 	} else {
101
-		rows, err := readUserDb.Raw("SELECT org.*, COUNT(DISTINCT org.id) FROM sgj_user_admin_role AS u_r, sgj_user_org AS org WHERE u_r.admin_user_id = ? AND u_r.org_id = org.id AND u_r.status = 1 AND org.status <> 0 GROUP BY org.id ORDER BY org.id;", adminUserID).Rows()
102
-		defer rows.Close()
103
-		if err != nil {
104
-			return nil, err
105
-		} else {
106
-			orgs := make([]*models.Org, 0)
107
-			for rows.Next() {
108
-				var org models.Org
109
-				if scanErr := readUserDb.Preload("OrgGallery", "status = 1").ScanRows(rows, &org); scanErr != nil {
110
-					return nil, scanErr
111
-
112
-				} else {
113
-					orgs = append(orgs, &org)
114
-				}
105
+		for rows.Next() {
106
+			var org models.Org
107
+			if scanErr := readUserDb.Preload("OrgGallery", "status = 1").ScanRows(rows, &org); scanErr != nil {
108
+				return nil, scanErr
109
+
110
+			} else {
111
+				orgs = append(orgs, &org)
115
 			}
112
 			}
116
-			return orgs, nil
117
 		}
113
 		}
114
+		return orgs, nil
118
 	}
115
 	}
119
-}
120
 
116
 
117
+}
121
 func GetAdminUserAllOrgApp(adminUserID int, orgID int) ([]*models.OrgApp, error) {
118
 func GetAdminUserAllOrgApp(adminUserID int, orgID int) ([]*models.OrgApp, error) {
122
 	rows, err := readUserDb.Raw("SELECT app.* from sgj_user_admin_role AS u_r, sgj_user_org_app AS app WHERE u_r.admin_user_id = ? AND u_r.org_id = ? AND u_r.app_id = app.id AND u_r.status = 1 AND app.status = 1 ORDER BY app_type ASC;", adminUserID, orgID).Rows()
119
 	rows, err := readUserDb.Raw("SELECT app.* from sgj_user_admin_role AS u_r, sgj_user_org_app AS app WHERE u_r.admin_user_id = ? AND u_r.org_id = ? AND u_r.app_id = app.id AND u_r.status = 1 AND app.status = 1 ORDER BY app_type ASC;", adminUserID, orgID).Rows()
123
 	defer rows.Close()
120
 	defer rows.Close()
148
 
145
 
149
 func GetAppRole(adminUserID int, orgID int, appID int) (*models.App_Role, error) {
146
 func GetAppRole(adminUserID int, orgID int, appID int) (*models.App_Role, error) {
150
 	var appRole models.App_Role
147
 	var appRole models.App_Role
151
-	err := readUserDb.Where("admin_user_id = ? AND org_id = ? AND app_id = ? AND status = 1", adminUserID, orgID, appID).First(&appRole).Error
148
+	err := readUserDb.Where("admin_user_id = ? AND org_id = ? AND app_id = ?", adminUserID, orgID, appID).First(&appRole).Error
152
 	if err != nil {
149
 	if err != nil {
153
 		return nil, err
150
 		return nil, err
154
 	}
151
 	}
166
 		Select("sgj_user_admin_role.*").
163
 		Select("sgj_user_admin_role.*").
167
 		Joins("join sgj_user_admin as a on a.id = sgj_user_admin_role.admin_user_id").
164
 		Joins("join sgj_user_admin as a on a.id = sgj_user_admin_role.admin_user_id").
168
 		Joins("join sgj_user_org_app as app on app.id = sgj_user_admin_role.app_id and app.status = 1 and app.app_type = ?", appType).
165
 		Joins("join sgj_user_org_app as app on app.id = sgj_user_admin_role.app_id and app.status = 1 and app.app_type = ?", appType).
169
-		Where("sgj_user_admin_role.status = 1 and sgj_user_admin_role.admin_user_id = ?", adminUserID).
166
+		Where("sgj_user_admin_role.admin_user_id = ?", adminUserID).
170
 		Order("sgj_user_admin_role.id desc").
167
 		Order("sgj_user_admin_role.id desc").
171
 		First(&appRole).
168
 		First(&appRole).
172
 		Error
169
 		Error
205
 	}
202
 	}
206
 	return &app, nil
203
 	return &app, nil
207
 }
204
 }
205
+
206
+// 获取最后登录的信息(AppType为3)
207
+func GetLastXTAdminRoleLoginRole(adminUserID int, appType int) (*models.AdminUserLoginLog, error) {
208
+	var log models.AdminUserLoginLog
209
+
210
+	err := readUserDb.Table("sgj_user_admin_login_log").
211
+		Select("sgj_user_admin_login_log.*").
212
+		Where("sgj_user_admin_login_log.admin_user_id = ? AND sgj_user_admin_login_log.app_type = 3  AND (sgj_user_admin_login_log.operate_type = 1 OR sgj_user_admin_login_log.operate_type = 3)", adminUserID).
213
+		Order("sgj_user_admin_login_log.id desc").
214
+		First(&log).
215
+		Error
216
+	if err != nil {
217
+		if err == gorm.ErrRecordNotFound {
218
+			return nil, nil
219
+		} else {
220
+			return nil, err
221
+		}
222
+	}
223
+	return &log, nil
224
+}
225
+
226
+func GetOrgApp(orgID int, app_type int) (*models.OrgApp, error) {
227
+	var apps models.OrgApp
228
+	err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
229
+	if err != nil {
230
+		return nil, err
231
+	}
232
+	return &apps, nil
233
+}
234
+
235
+//
236
+
237
+func GetLastUserRole(org_id int64, admin_user_id int64) (*models.App_Role, error) {
238
+	var admin_user models.App_Role
239
+	err := readUserDb.Where("org_id != ? AND status = 1 AND admin_user_id = ?", org_id, admin_user_id).First(&admin_user).Error
240
+	if err != nil {
241
+		return nil, err
242
+	}
243
+	return &admin_user, nil
244
+}

+ 70 - 30
service/org_service.go Datei anzeigen

2
 
2
 
3
 import (
3
 import (
4
 	"SSO/models"
4
 	"SSO/models"
5
+	"strconv"
5
 	"time"
6
 	"time"
6
 
7
 
7
 	"github.com/jinzhu/gorm"
8
 	"github.com/jinzhu/gorm"
8
 )
9
 )
9
 
10
 
10
-func CreateOrg(org *models.Org, mobile string, openXT bool, openCDM bool, openSCRM bool, openMall bool) error {
11
+func CreateOrg(org *models.Org, mobile string, openXT bool, openCDM bool, openSCRM bool, openMall bool, user_name string) error {
11
 	now := time.Now()
12
 	now := time.Now()
12
 	tx_admin := writeUserDb.Begin()
13
 	tx_admin := writeUserDb.Begin()
13
 	if err := tx_admin.Create(org).Error; err != nil {
14
 	if err := tx_admin.Create(org).Error; err != nil {
31
 	}
32
 	}
32
 
33
 
33
 	// app 的创建顺序也决定了登录后前往 app 的优先级
34
 	// app 的创建顺序也决定了登录后前往 app 的优先级
34
-	if err := createOrgApp(tx_admin, &role, mobile, 3, openXT); err != nil {
35
-		tx_admin.Rollback()
36
-		return err
37
-	}
38
-	if err := createOrgApp(tx_admin, &role, mobile, 4, openCDM); err != nil {
39
-		tx_admin.Rollback()
40
-		return err
41
-	}
42
-	if err := createOrgApp(tx_admin, &role, mobile, 1, openSCRM); err != nil {
43
-		tx_admin.Rollback()
44
-		return err
45
-	}
46
-	if err := createOrgApp(tx_admin, &role, mobile, 5, openMall); err != nil {
35
+	if err := createOrgApp(tx_admin, &role, user_name, 3, openXT); err != nil {
47
 		tx_admin.Rollback()
36
 		tx_admin.Rollback()
48
 		return err
37
 		return err
49
 	}
38
 	}
178
 
167
 
179
 //  如果出错,没有 rollback,需自行 rollback
168
 //  如果出错,没有 rollback,需自行 rollback
180
 func createOrgApp(tx *gorm.DB, superAdminRole *models.Role, userName string, appType int, open bool) error {
169
 func createOrgApp(tx *gorm.DB, superAdminRole *models.Role, userName string, appType int, open bool) error {
181
-	openStatus := 0
182
-	if open {
183
-		openStatus = 1
184
-	}
170
+	//创建应用
185
 	now := time.Now().Unix()
171
 	now := time.Now().Unix()
186
-	app := models.OrgApp{
187
-		Creator:    superAdminRole.Creator,
188
-		OrgId:      superAdminRole.OrgId,
189
-		AppType:    appType,
190
-		OpenStatus: openStatus,
191
-		Status:     1,
192
-		CreateTime: now,
193
-		ModifyTime: now,
194
-	}
195
-	if createAppErr := tx.Create(&app).Error; createAppErr != nil {
196
-		return createAppErr
172
+	var app_id int64
173
+	apps, _ := FindSystemOrgApp()
174
+	for _, item := range apps {
175
+		app := &VMOrgApp{
176
+			AppType:    item.AppType,
177
+			Creator:    int(superAdminRole.Creator),
178
+			OrgId:      int(superAdminRole.OrgId),
179
+			OpenStatus: item.OpenStatus,
180
+			Status:     1,
181
+			CreateTime: now,
182
+			ModifyTime: now,
183
+			Name:       item.Name,
184
+			Url:        item.Url,
185
+			Number:     item.Number,
186
+			Pid:        0,
187
+		}
188
+		writeUserDb.Create(&app)
189
+		if app.AppType == 3 {
190
+			app_id = app.ID
191
+
192
+		}
193
+
194
+		for _, subItem := range item.VMOrgApp {
195
+			app := &VMOrgApp{
196
+				AppType:    subItem.AppType,
197
+				Creator:    int(superAdminRole.Creator),
198
+				OrgId:      int(superAdminRole.OrgId),
199
+				OpenStatus: subItem.OpenStatus,
200
+				Status:     1,
201
+				CreateTime: now,
202
+				ModifyTime: now,
203
+				Name:       subItem.Name,
204
+				Url:        subItem.Url,
205
+				Number:     subItem.Number,
206
+				Pid:        app.ID,
207
+			}
208
+			writeUserDb.Create(&app)
209
+		}
197
 	}
210
 	}
211
+
198
 	app_role := models.App_Role{
212
 	app_role := models.App_Role{
199
 		AdminUserId: superAdminRole.Creator,
213
 		AdminUserId: superAdminRole.Creator,
200
 		OrgId:       superAdminRole.OrgId,
214
 		OrgId:       superAdminRole.OrgId,
201
-		AppId:       app.Id,
215
+		AppId:       int(app_id),
202
 		RoleId:      superAdminRole.Id,
216
 		RoleId:      superAdminRole.Id,
203
 		Avatar:      "",
217
 		Avatar:      "",
218
+		RoleIds:     strconv.Itoa(superAdminRole.Id),
204
 		UserName:    userName,
219
 		UserName:    userName,
205
 		Intro:       "",
220
 		Intro:       "",
206
 		UserType:    1,
221
 		UserType:    1,
269
 func SaveOrgApp(app *models.OrgApp) error {
284
 func SaveOrgApp(app *models.OrgApp) error {
270
 	return writeUserDb.Save(app).Error
285
 	return writeUserDb.Save(app).Error
271
 }
286
 }
287
+
288
+type VMOrgApp struct {
289
+	ID         int64       `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"` // ID
290
+	AppType    int         `gorm:"column:app_type" json:"app_type"`
291
+	Creator    int         `json:"creator"` // 创建者,即管理员用户的 id
292
+	OrgId      int         `gorm:"column:org_id" json:"org_id"`
293
+	OpenStatus int         `gorm:"column:open_status" json:"open_status"`
294
+	Status     int8        `json:"status"`                    // 状态 0.无效 1.有效 2.禁用
295
+	CreateTime int64       `gorm:"column:ctime" json:"ctime"` // 创建时间
296
+	ModifyTime int64       `gorm:"column:mtime" json:"mtime"` // 修改时间
297
+	Name       string      `gorm:"column:name" json:"name" form:"name"`
298
+	Url        string      `gorm:"column:url" json:"url" form:"url"`
299
+	Pid        int64       `gorm:"column:pid" json:"pid" form:"pid"`
300
+	Number     int64       `gorm:"column:number" json:"order" form:"number"`
301
+	VMOrgApp   []*VMOrgApp `gorm:"ForeignKey:Pid;AssociationForeignKey:Id" `
302
+}
303
+
304
+func (VMOrgApp) TableName() string {
305
+	return "sgj_user_org_app"
306
+}
307
+
308
+func FindSystemOrgApp() (app []*VMOrgApp, err error) {
309
+	err = readUserDb.Model(&VMOrgApp{}).Preload("VMOrgApp", "org_id = 0 AND status =1 AND pid > 0").Where("status = 1 AND org_id = 0 AND pid = 0").Find(&app).Error
310
+	return
311
+}

+ 3 - 35
service/purview_service.go Datei anzeigen

20
 	return purviews, nil
20
 	return purviews, nil
21
 }
21
 }
22
 
22
 
23
-func GetAllPurviewsProcessed(appType int) ([]*models.Purview, error) {
24
-	originPurviews, getPurviewErr := getAllOriginPurviews(appType)
25
-	if getPurviewErr != nil {
26
-		return nil, getPurviewErr
27
-	}
28
-	return processPurviews2Tree(originPurviews), nil
29
-}
30
-
31
-// 加工这些规则:树形化
32
-// 正确结果的前提是 originPurviews 以 parentid asc 排好序了的
33
-func processPurviews2Tree(originPurviews []*models.Purview) []*models.Purview {
34
-	processedPurviews := make([]*models.Purview, 0)
35
-	pid_childs := make(map[int][]*models.Purview)
36
-	for _, purview := range originPurviews {
37
-		// warning:下面这个算法只适用最多两层树形结构的菜单,对于两层以上的会丢失掉第三层及其以下的节点
38
-		// 因为取出 originPurviews 的时候已经排过序了,所以顶级节点肯定最先处理,不需要担心子节点比父节点先处理
39
-		if purview.Parentid == 0 {
40
-			processedPurviews = append(processedPurviews, purview)
41
-		} else {
42
-			childs := pid_childs[purview.Parentid]
43
-			if pid_childs[purview.Parentid] == nil {
44
-				childs = make([]*models.Purview, 0)
45
-			}
46
-			childs = append(childs, purview)
47
-			pid_childs[purview.Parentid] = childs
48
-		}
49
-	}
50
-
51
-	for _, proPurview := range processedPurviews {
52
-		proPurview.Childs = pid_childs[proPurview.Id]
53
-	}
54
-
55
-	return processedPurviews
56
-}
57
-
58
 func GetSuperAdminUsersPurviewTreeAndUrlfors(appType int) ([]string, []*models.Purview, error) {
23
 func GetSuperAdminUsersPurviewTreeAndUrlfors(appType int) ([]string, []*models.Purview, error) {
59
 	originPurviews, getPurviewErr := getAllOriginPurviews(appType)
24
 	originPurviews, getPurviewErr := getAllOriginPurviews(appType)
60
 	if getPurviewErr != nil {
25
 	if getPurviewErr != nil {
65
 }
30
 }
66
 
31
 
67
 func GetGeneralAdminUsersPurviewTreeAndUrlfors(adminUserID int, appId int) ([]string, []*models.Purview, error) {
32
 func GetGeneralAdminUsersPurviewTreeAndUrlfors(adminUserID int, appId int) ([]string, []*models.Purview, error) {
33
+	//查出该用户所有角色的权限全集
34
+
68
 	rows, err := readUserDb.Raw("SELECT p.purview_ids AS pids FROM sgj_user_admin_role AS a_r, sgj_user_role_purview AS p WHERE a_r.admin_user_id = ? AND  a_r.app_id = ? AND a_r.role_id = p.role_id AND a_r.status = 1 AND p.`status` = 1;", adminUserID, appId).Rows()
35
 	rows, err := readUserDb.Raw("SELECT p.purview_ids AS pids FROM sgj_user_admin_role AS a_r, sgj_user_role_purview AS p WHERE a_r.admin_user_id = ? AND  a_r.app_id = ? AND a_r.role_id = p.role_id AND a_r.status = 1 AND p.`status` = 1;", adminUserID, appId).Rows()
69
 	defer rows.Close()
36
 	defer rows.Close()
70
 	if err != nil {
37
 	if err != nil {
74
 			return nil, nil, err
41
 			return nil, nil, err
75
 		}
42
 		}
76
 	}
43
 	}
44
+
77
 	pids := ""
45
 	pids := ""
78
 	if rows.Next() {
46
 	if rows.Next() {
79
 		rows.Scan(&pids)
47
 		rows.Scan(&pids)

+ 105 - 0
service/vm_service.go Datei anzeigen

1
+package service
2
+
3
+import (
4
+	"SSO/models"
5
+)
6
+
7
+func CreateVMOrgPatient(patients *models.VMOrgPatients) {
8
+	writeXTDb.Model(&models.VMOrgPatients{}).Create(&patients)
9
+}
10
+
11
+func CreateVMOrgNewPatient(patientsNew *models.XtPatientsNew) {
12
+	writeXTDb.Model(&models.XtPatientsNew{}).Create(&patientsNew)
13
+}
14
+
15
+func CreateVMZone(zone *models.VMDeviceZone) {
16
+	writeXTDb.Model(&models.VMDeviceZone{}).Create(&zone)
17
+}
18
+
19
+func CreateVMGroup(group *models.VMDeviceGroup) {
20
+	writeXTDb.Model(&models.VMDeviceGroup{}).Create(&group)
21
+}
22
+
23
+func CreateVMDeviceNumber(number *models.VMDeviceNumber) {
24
+	writeXTDb.Model(&models.VMDeviceNumber{}).Create(&number)
25
+}
26
+
27
+func CreateVMSch(sch *models.VMSchedule) {
28
+	writeXTDb.Model(&models.VMSchedule{}).Create(&sch)
29
+}
30
+
31
+func CreateVMSchMode(schMode *models.VMPatientScheduleTemplateMode) {
32
+	writeXTDb.Model(&models.VMPatientScheduleTemplateMode{}).Create(&schMode)
33
+}
34
+
35
+func CreateVMSchTemplateId(schTemplateId *models.VMPatientScheduleTemplateId) {
36
+	writeXTDb.Model(&models.VMPatientScheduleTemplateId{}).Create(&schTemplateId)
37
+}
38
+
39
+func CreateVMSchTemplate(schTemplate *models.VMPatientScheduleTemplateItem) {
40
+	writeXTDb.Model(&models.VMPatientScheduleTemplateItem{}).Create(&schTemplate)
41
+}
42
+
43
+func CreateVMPrescription(sys *models.SystemPrescription) {
44
+	writeXTDb.Model(&models.SystemPrescription{}).Create(&sys)
45
+}
46
+
47
+func CreatedDeviceMode(mode *models.VMDeviceMode) {
48
+	writeUserDb.Model(&models.VMDeviceMode{}).Create(&mode)
49
+}
50
+
51
+func GetFirstDeviceMode(orgid int64) (models.VMDeviceMode, error) {
52
+	mode := models.VMDeviceMode{}
53
+	err = readUserDb.Where("user_org_id = ? and status =1", orgid).First(&mode).Error
54
+	return mode, err
55
+}
56
+
57
+func GetFirstBedNumber(orgid int64) (models.VMDeviceNumber, error) {
58
+	number := models.VMDeviceNumber{}
59
+	err := readXTDb.Where("org_id = ? and status =1", orgid).First(&number).Error
60
+	return number, err
61
+}
62
+
63
+func CreateDeviceAddMacher(addmacher *models.VmDeviceAddmacher) {
64
+	writeUserDb.Model(&models.VmDeviceAddmacher{}).Create(&addmacher)
65
+}
66
+
67
+func GetLastMacher(orgid int64) (models.VmDeviceAddmacher, error) {
68
+	addmacher := models.VmDeviceAddmacher{}
69
+	err := readUserDb.Where("user_org_id = ? and status =1", orgid).First(&addmacher).Error
70
+	return addmacher, err
71
+}
72
+
73
+func CreatedTreateMode(treatmentmode *models.VmDeviceTreatmentmode) {
74
+	writeXTDb.Model(&models.VmDeviceTreatmentmode{}).Create(&treatmentmode)
75
+
76
+}
77
+
78
+func CreateOrgRole(role *models.Role) (err error) {
79
+	err = writeUserDb.Create(&role).Error
80
+	return
81
+}
82
+
83
+func GetRolePurview(roleID int64) (models.RolePurview, error) {
84
+	var rolePurviews models.RolePurview
85
+	var err error
86
+	err = readUserDb.Where("role_id = ?", roleID).First(&rolePurviews).Error
87
+	return rolePurviews, err
88
+}
89
+
90
+func GetFuncRolePurview(roleID int64) (models.SgjUserRoleFuncPurview, error) {
91
+	var rolePurviews models.SgjUserRoleFuncPurview
92
+	var err error
93
+	err = readUserDb.Where("role_id = ?", roleID).First(&rolePurviews).Error
94
+	return rolePurviews, err
95
+}
96
+
97
+func CreateRolePurview(purview *models.RolePurview) (err error) {
98
+	err = writeUserDb.Create(&purview).Error
99
+	return
100
+}
101
+
102
+func CreateFuncRolePurview(purview *models.SgjUserRoleFuncPurview) (err error) {
103
+	err = writeUserDb.Create(&purview).Error
104
+	return
105
+}

+ 8 - 3
static/js/create_org.js Datei anzeigen

1
 $(function() {
1
 $(function() {
2
     $("#open_3").attr("checked", "checked");
2
     $("#open_3").attr("checked", "checked");
3
-    
3
+
4
     $("#province_select").change(function() {
4
     $("#province_select").change(function() {
5
         $("#city_select option").remove();
5
         $("#city_select option").remove();
6
         $("#district_select option").remove();
6
         $("#district_select option").remove();
36
     });
36
     });
37
 
37
 
38
     $("#city_select").change(function() {
38
     $("#city_select").change(function() {
39
-        
39
+
40
         $("#district_select option").remove();
40
         $("#district_select option").remove();
41
         $("#district_select").append("<option value='0'>区/县</option>");
41
         $("#district_select").append("<option value='0'>区/县</option>");
42
         var city = $("#city_select option:selected").val();
42
         var city = $("#city_select option:selected").val();
141
         }
141
         }
142
 
142
 
143
         var postData = {
143
         var postData = {
144
+            user_name:$("#user_name").val(),
145
+
144
             name: $("#org_name").val(),
146
             name: $("#org_name").val(),
145
             // short_name: $("#org_short_name").val(),
147
             // short_name: $("#org_short_name").val(),
146
             contact_name: $("#contact_name").val(),
148
             contact_name: $("#contact_name").val(),
169
 });
171
 });
170
 
172
 
171
 function checkInfoFull() {
173
 function checkInfoFull() {
174
+    if ($("#user_name").val().length == 0) {
175
+        return "请填写用户名字";
176
+    }
172
     if ($("#org_name").val().length == 0) {
177
     if ($("#org_name").val().length == 0) {
173
         return "请填写机构名称";
178
         return "请填写机构名称";
174
     }
179
     }
203
 
208
 
204
 function doFail(res) {
209
 function doFail(res) {
205
     serverErrorMsg(res);
210
     serverErrorMsg(res);
206
-}
211
+}

+ 231 - 0
utils/tools.go Datei anzeigen

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([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$", 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
+}

+ 12 - 2
views/home/create_org.html Datei anzeigen

12
     <link href="/static/font-awesome/css/font-awesome.css?v=4.3.0" rel="stylesheet" />
12
     <link href="/static/font-awesome/css/font-awesome.css?v=4.3.0" rel="stylesheet" />
13
     <link href="/static/css/old_style.css?v=1.0.0" rel="stylesheet">
13
     <link href="/static/css/old_style.css?v=1.0.0" rel="stylesheet">
14
     <link href="/static/iconfont/iconfont.css?v=4.0.0" rel="stylesheet">
14
     <link href="/static/iconfont/iconfont.css?v=4.0.0" rel="stylesheet">
15
-    
15
+
16
 </head>
16
 </head>
17
 
17
 
18
 <body>
18
 <body>
36
                 </div>
36
                 </div>
37
             </div>
37
             </div>
38
         </div>
38
         </div>
39
+        <div class="stewardMsg">
40
+            <h2 class="stewardMsg_tit">用户信息</h2>
41
+            <div class="steward_content">
42
+                <div class="cell clearfix">
43
+                    <label class="cell_tit fl">用户名字</label>
44
+                    <input id="user_name" type="text" class="cell_input" maxlength="10" />
45
+                </div>
46
+            </div>
47
+        </div>
48
+
39
         <!-- 完善机构信息 -->
49
         <!-- 完善机构信息 -->
40
         <div class="stewardMsg">
50
         <div class="stewardMsg">
41
             <h2 class="stewardMsg_tit">机构信息</h2>
51
             <h2 class="stewardMsg_tit">机构信息</h2>
320
     <script src="/static/js/create_org.js?v=0.2.3"></script>
330
     <script src="/static/js/create_org.js?v=0.2.3"></script>
321
 </body>
331
 </body>
322
 
332
 
323
-</html>
333
+</html>

+ 11 - 5
views/new_main/create_org.html Datei anzeigen

12
     <link href="/static/font-awesome/css/font-awesome.css?v=4.3.0" rel="stylesheet" />
12
     <link href="/static/font-awesome/css/font-awesome.css?v=4.3.0" rel="stylesheet" />
13
     <link href="/static/css/old_style.css?v=1.0.0" rel="stylesheet">
13
     <link href="/static/css/old_style.css?v=1.0.0" rel="stylesheet">
14
     <link href="/static/iconfont/iconfont.css?v=4.0.0" rel="stylesheet">
14
     <link href="/static/iconfont/iconfont.css?v=4.0.0" rel="stylesheet">
15
-    
15
+
16
 </head>
16
 </head>
17
 
17
 
18
 <body>
18
 <body>
23
                     <img src="/static/images/logo.png" alt="" />
23
                     <img src="/static/images/logo.png" alt="" />
24
                 </a>
24
                 </a>
25
             </div>
25
             </div>
26
-            
26
+
27
             <div class="TheUser fr ">
27
             <div class="TheUser fr ">
28
                 <div class="userData fl">
28
                 <div class="userData fl">
29
                     <img src="{{.avatar}}" alt="头像" />
29
                     <img src="{{.avatar}}" alt="头像" />
36
             </div>
36
             </div>
37
         </div>
37
         </div>
38
         <!-- 完善机构信息 -->
38
         <!-- 完善机构信息 -->
39
+
40
+
39
         <div class="stewardMsg">
41
         <div class="stewardMsg">
40
             <h2 class="stewardMsg_tit">机构信息</h2>
42
             <h2 class="stewardMsg_tit">机构信息</h2>
41
             <div class="steward_content">
43
             <div class="steward_content">
42
                 <p class="tips">请正确填写以下信息,后续可在账号设置中修改</p>
44
                 <p class="tips">请正确填写以下信息,后续可在账号设置中修改</p>
45
+                <div class="cell clearfix">
46
+                    <label class="cell_tit fl">用户名称</label>
47
+                    <input id="user_name" type="text" class="cell_input" maxlength="10" />
48
+                </div>
43
                 <div class="cell clearfix">
49
                 <div class="cell clearfix">
44
                     <label class="cell_tit fl">机构名称</label>
50
                     <label class="cell_tit fl">机构名称</label>
45
                     <input id="org_name" type="text" class="cell_input" maxlength="50" />
51
                     <input id="org_name" type="text" class="cell_input" maxlength="50" />
99
                     <label class="cell_tit fl">机构电话</label>
105
                     <label class="cell_tit fl">机构电话</label>
100
                     <input id="org_phone" type="text" class="cell_input" maxlength="50" />
106
                     <input id="org_phone" type="text" class="cell_input" maxlength="50" />
101
                 </div>
107
                 </div>
102
-                <div class="cell clearfix">
108
+                <div class="cell clearfix" style="display: none">
103
                     <label class="cell_tit fl">选择启用的应用</label>
109
                     <label class="cell_tit fl">选择启用的应用</label>
104
                     <div class="Checkbox fl">
110
                     <div class="Checkbox fl">
105
                         <div class="opt">
111
                         <div class="opt">
141
     <script src="/static/js/layer.js"></script>
147
     <script src="/static/js/layer.js"></script>
142
     <script src="/static/js/md5.js"></script>
148
     <script src="/static/js/md5.js"></script>
143
     <script src="/static/js/common.js"></script>
149
     <script src="/static/js/common.js"></script>
144
-    <script src="/static/js/create_org.js?v=0.2.6"></script>
150
+    <script src="/static/js/create_org.js?v=0.2.8"></script>
145
 </body>
151
 </body>
146
 
152
 
147
-</html>
153
+</html>