Browse Source

Merge branch 'master' of http://git.shengws.com/csx/XT_New

csx 5 years ago
parent
commit
821eee1b89

+ 212 - 53
controllers/base_api_controller.go View File

2
 
2
 
3
 import (
3
 import (
4
 	"XT_New/enums"
4
 	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"fmt"
8
+	"strconv"
9
+	"strings"
5
 )
10
 )
6
 
11
 
7
 type BaseAPIController struct {
12
 type BaseAPIController struct {
60
 func (this *BaseAuthAPIController) Prepare() {
65
 func (this *BaseAuthAPIController) Prepare() {
61
 	this.BaseAPIController.Prepare()
66
 	this.BaseAPIController.Prepare()
62
 	if this.GetAdminUserInfo() == nil {
67
 	if this.GetAdminUserInfo() == nil {
63
-		//var userAdmin models.AdminUser
68
+		var userAdmin models.AdminUser
64
 		//userAdmin.Id = 400
69
 		//userAdmin.Id = 400
65
 		//userAdmin.Mobile = "13535547901"
70
 		//userAdmin.Mobile = "13535547901"
66
 		//
71
 		//
67
-		////userAdmin.Id = 597
68
-		////userAdmin.Mobile = "19874122664"
69
-		//userAdmin.IsSuperAdmin = false
70
-		//userAdmin.Status = 1
71
-		//userAdmin.CreateTime = 1530786071
72
-		//userAdmin.ModifyTime = 1530786071
73
-		//var subscibe models.ServeSubscibe
74
-		//subscibe.ID = 1
75
-		//subscibe.OrgId = 12
76
-		//subscibe.PeriodStart = 1538035409
77
-		//subscibe.PeriodEnd = 1569571409
78
-		//subscibe.State = 1
79
-		//subscibe.Status = 1
80
-		//subscibe.CreatedTime = 1538035409
81
-		//subscibe.UpdatedTime = 1538035409
82
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
83
-		//subscibes[4] = &subscibe
84
-		//var adminUserInfo service.AdminUserInfo
85
-		//adminUserInfo.CurrentOrgId = 12
86
-		//adminUserInfo.CurrentAppId = 18
87
-		//adminUserInfo.AdminUser = &userAdmin
88
-		//adminUserInfo.Subscibes = subscibes
89
-		//this.SetSession("admin_user_info", &adminUserInfo)
72
+		userAdmin.Id = 597
73
+		userAdmin.Mobile = "19874122664"
74
+		userAdmin.IsSuperAdmin = false
75
+		userAdmin.Status = 1
76
+		userAdmin.CreateTime = 1530786071
77
+		userAdmin.ModifyTime = 1530786071
78
+		var subscibe models.ServeSubscibe
79
+		subscibe.ID = 1
80
+		subscibe.OrgId = 12
81
+		subscibe.PeriodStart = 1538035409
82
+		subscibe.PeriodEnd = 1569571409
83
+		subscibe.State = 1
84
+		subscibe.Status = 1
85
+		subscibe.CreatedTime = 1538035409
86
+		subscibe.UpdatedTime = 1538035409
87
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
88
+		subscibes[4] = &subscibe
89
+		var adminUserInfo service.AdminUserInfo
90
+		adminUserInfo.CurrentOrgId = 12
91
+		adminUserInfo.CurrentAppId = 18
92
+		adminUserInfo.AdminUser = &userAdmin
93
+		adminUserInfo.Subscibes = subscibes
94
+		this.SetSession("admin_user_info", &adminUserInfo)
90
 
95
 
91
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
92
-		this.StopRun()
96
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
97
+		//this.StopRun()
98
+	}
99
+
100
+	adminUserInfo := this.GetAdminUserInfo()
101
+
102
+	if this.Ctx.Request.Header.Get("Permission") == "2" {
103
+		fmt.Println("1111111")
104
+		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
105
+		if adminUserInfo.AdminUser.Id != org.Creator { //超级管理员不受此限制
106
+
107
+			isPermission := false
108
+			adminUserInfo := this.GetAdminUserInfo()
109
+			//该机构下该用户有多少个
110
+			role, _ := service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
111
+			var roles []string
112
+			if len(role.RoleIds) <= 0 { //该用户没有设置角色
113
+
114
+			} else {
115
+				roles = strings.Split(role.RoleIds, ",")
116
+			}
117
+			fmt.Println(roles)
118
+
119
+			//获取该用户下所有角色的权限总集
120
+			var userRolePurviews string
121
+			var userRolePurviewsArr []string
122
+			for _, item := range roles {
123
+				role_id, _ := strconv.ParseInt(item, 10, 64)
124
+				purviews, _ := service.GetRoleFuncPurviewIds(role_id)
125
+				if len(userRolePurviews) == 0 {
126
+					userRolePurviews = purviews
127
+				} else {
128
+					userRolePurviews = userRolePurviews + "," + purviews
129
+				}
130
+			}
131
+			//该用户所拥有角色的权限的总集
132
+			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
133
+			fmt.Println(userRolePurviewsArr)
134
+			//系统所记录的权限列表
135
+			allPermission, _ := service.GetAllFunctionPurview()
136
+
137
+			for _, item := range allPermission {
138
+				fmt.Println(len(strings.Split(item.Urlfor, ",")))
139
+
140
+				fmt.Println(strings.Split(item.Urlfor, ","))
141
+				//fmt.Println(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
142
+
143
+				//判断当前路由是否在权限路由列表里面
144
+				if strings.Split(item.Urlfor, ",")[1] == strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode") {
145
+
146
+					//获取该角色的所有权限
147
+					for _, items := range userRolePurviewsArr {
148
+						id, _ := strconv.ParseInt(items, 10, 64)
149
+						fmt.Println(id)
150
+						fmt.Println(item.ID)
151
+
152
+						if id == item.ID {
153
+							isPermission = true
154
+						}
155
+					}
156
+					if !isPermission {
157
+						msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
158
+						json := make(map[string]interface{})
159
+						json["msg"] = msg
160
+						json["code"] = 0
161
+						json["state"] = 0
162
+						this.Data["json"] = json
163
+						this.ServeJSON()
164
+						this.StopRun()
165
+					}
166
+				}
167
+			}
168
+		}
169
+	}
170
+
171
+	if this.Ctx.Request.Header.Get("Permission") == "3" {
172
+		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
173
+		if adminUserInfo.AdminUser.Id != org.Creator { //超级管理员不受此限制
174
+
175
+			isPermission := false
176
+			adminUserInfo := this.GetAdminUserInfo()
177
+			//该机构下该用户有多少个
178
+			role, _ := service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
179
+			var roles []string
180
+			if len(role.RoleIds) <= 0 { //该用户没有设置角色
181
+
182
+			} else {
183
+				roles = strings.Split(role.RoleIds, ",")
184
+			}
185
+			fmt.Println(roles)
186
+
187
+			//获取该用户下所有角色的权限总集
188
+			var userRolePurviews string
189
+			var userRolePurviewsArr []string
190
+			for _, item := range roles {
191
+				role_id, _ := strconv.ParseInt(item, 10, 64)
192
+				purviews, _ := service.GetRoleFuncPurviewIds(role_id)
193
+				if len(userRolePurviews) == 0 {
194
+					userRolePurviews = purviews
195
+				} else {
196
+					userRolePurviews = userRolePurviews + "," + purviews
197
+				}
198
+			}
199
+			//该用户所拥有角色的权限的总集
200
+			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
201
+			fmt.Println(userRolePurviewsArr)
202
+			//系统所记录的权限列表
203
+			allPermission, _ := service.GetAllFunctionPurview()
204
+
205
+			for _, item := range allPermission {
206
+				fmt.Println(strings.Split(item.Urlfor, ",")[2])
207
+				fmt.Println(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
208
+
209
+				//判断当前路由是否在权限路由列表里面
210
+				if strings.Split(item.Urlfor, ",")[2] == strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode") {
211
+
212
+					//获取该角色的所有权限
213
+					for _, items := range userRolePurviewsArr {
214
+						id, _ := strconv.ParseInt(items, 10, 64)
215
+						fmt.Println(id)
216
+						fmt.Println(item.ID)
217
+
218
+						if id == item.ID {
219
+							isPermission = true
220
+						}
221
+					}
222
+					if !isPermission {
223
+						msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
224
+						json := make(map[string]interface{})
225
+						json["msg"] = msg
226
+						json["code"] = 0
227
+						json["state"] = 0
228
+						this.Data["json"] = json
229
+						this.ServeJSON()
230
+						this.StopRun()
231
+					}
232
+				}
233
+			}
234
+		}
93
 	}
235
 	}
94
 
236
 
95
 	//if this.Ctx.Request.Method != "GET" {
237
 	//if this.Ctx.Request.Method != "GET" {
175
 func (this *BaseServeAPIController) Prepare() {
317
 func (this *BaseServeAPIController) Prepare() {
176
 	this.BaseAPIController.Prepare()
318
 	this.BaseAPIController.Prepare()
177
 	if this.GetAdminUserInfo() == nil {
319
 	if this.GetAdminUserInfo() == nil {
178
-		//var userAdmin models.AdminUser
179
-		//userAdmin.Id = 400
180
-		//userAdmin.Mobile = "13535547901"
181
-		////userAdmin.Id = 597
182
-		////userAdmin.Mobile = "19874122664"
183
-		//userAdmin.IsSuperAdmin = false
184
-		//userAdmin.Status = 1
185
-		//userAdmin.CreateTime = 1530786071
186
-		//userAdmin.ModifyTime = 1530786071
187
-		//var subscibe models.ServeSubscibe
188
-		//subscibe.ID = 1
189
-		//subscibe.OrgId = 12
190
-		//subscibe.PeriodStart = 1538035409
191
-		//subscibe.PeriodEnd = 1569571409
192
-		//subscibe.State = 1
193
-		//subscibe.Status = 1
194
-		//subscibe.CreatedTime = 1538035409
195
-		//subscibe.UpdatedTime = 1538035409
196
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
197
-		//subscibes[4] = &subscibe
198
-		//var adminUserInfo service.AdminUserInfo
199
-		//adminUserInfo.CurrentOrgId = 12
200
-		//adminUserInfo.CurrentAppId = 18
201
-		//adminUserInfo.AdminUser = &userAdmin
202
-		//adminUserInfo.Subscibes = subscibes
203
-		//this.SetSession("admin_user_info", &adminUserInfo)
320
+		var userAdmin models.AdminUser
321
+		userAdmin.Id = 400
322
+		userAdmin.Mobile = "13535547901"
323
+		//userAdmin.Id = 597
324
+		//userAdmin.Mobile = "19874122664"
325
+		userAdmin.IsSuperAdmin = false
326
+		userAdmin.Status = 1
327
+		userAdmin.CreateTime = 1530786071
328
+		userAdmin.ModifyTime = 1530786071
329
+		var subscibe models.ServeSubscibe
330
+		subscibe.ID = 1
331
+		subscibe.OrgId = 12
332
+		subscibe.PeriodStart = 1538035409
333
+		subscibe.PeriodEnd = 1569571409
334
+		subscibe.State = 1
335
+		subscibe.Status = 1
336
+		subscibe.CreatedTime = 1538035409
337
+		subscibe.UpdatedTime = 1538035409
338
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
+		subscibes[4] = &subscibe
340
+		var adminUserInfo service.AdminUserInfo
341
+		adminUserInfo.CurrentOrgId = 12
342
+		adminUserInfo.CurrentAppId = 18
343
+		adminUserInfo.AdminUser = &userAdmin
344
+		adminUserInfo.Subscibes = subscibes
345
+		this.SetSession("admin_user_info", &adminUserInfo)
204
 
346
 
205
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
347
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
206
 		this.StopRun()
348
 		this.StopRun()
207
 	}
349
 	}
350
+
351
+	//if adminUserInfo.AppRole != nil {
352
+	//	if adminUserInfo.AppRole.Id > 0 {
353
+	//		app_role, _ := service.FindAppRoleById(adminUserInfo.AppRole.Id)
354
+	//		if app_role != nil {
355
+	//			if app_role.Status != 1 {
356
+	//				this.DelSession("mobile_admin_user_info")
357
+	//				this.Ctx.SetCookie("token_cookie", "")
358
+	//				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeForbidden)
359
+	//				this.StopRun()
360
+	//			}
361
+	//		}
362
+	//	}
363
+	//
364
+	//}
365
+	//fmt.Println("222222222")
366
+
208
 }
367
 }
209
 
368
 
210
-func RemoveRepeatedElement2(arr []string) (newArr []string) {
369
+func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
211
 	newArr = make([]string, 0)
370
 	newArr = make([]string, 0)
212
 	for i := 0; i < len(arr); i++ {
371
 	for i := 0; i < len(arr); i++ {
213
 		repeat := false
372
 		repeat := false

+ 23 - 22
controllers/data_api_controller.go View File

1022
 		return
1022
 		return
1023
 	}
1023
 	}
1024
 
1024
 
1025
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1026
-	if appRole.UserType == 3 {
1027
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1028
-		if getPermissionErr != nil {
1029
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1030
-			return
1031
-		} else if headNursePermission == nil {
1032
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1033
-			return
1034
-		}
1035
-	}
1025
+	//TODO 根据路由来做权限
1026
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1027
+	//if appRole.UserType == 3 {
1028
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1029
+	//	if getPermissionErr != nil {
1030
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1031
+	//		return
1032
+	//	} else if headNursePermission == nil {
1033
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1034
+	//		return
1035
+	//	}
1036
+	//}
1036
 
1037
 
1037
 	var templatedata models.DoctorAdviceTemplate
1038
 	var templatedata models.DoctorAdviceTemplate
1038
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &templatedata)
1039
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &templatedata)
1092
 		return
1093
 		return
1093
 	}
1094
 	}
1094
 
1095
 
1095
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1096
-	if appRole.UserType == 3 {
1097
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1098
-		if getPermissionErr != nil {
1099
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1100
-			return
1101
-		} else if headNursePermission == nil {
1102
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1103
-			return
1104
-		}
1105
-	}
1096
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1097
+	//if appRole.UserType == 3 {
1098
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1099
+	//	if getPermissionErr != nil {
1100
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1101
+	//		return
1102
+	//	} else if headNursePermission == nil {
1103
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1104
+	//		return
1105
+	//	}
1106
+	//}
1106
 
1107
 
1107
 	timeNow := time.Now().Unix()
1108
 	timeNow := time.Now().Unix()
1108
 	template.ID = id
1109
 	template.ID = id

+ 110 - 110
controllers/dialysis_api_controller.go View File

138
 
138
 
139
 	var prescription_doctor int64
139
 	var prescription_doctor int64
140
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
140
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
141
-	template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
142
-
143
-	if template.TemplateId == 2 || template.TemplateId == 6 {
144
-		if appRole.UserType == 3 {
145
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
146
-			if getPermissionErr != nil {
147
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
148
-				return
149
-			} else if headNursePermission == nil {
150
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
151
-				return
152
-			}
153
-		}
154
-	}
141
+	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
142
+
143
+	//if template.TemplateId == 2 || template.TemplateId == 6 {
144
+	//	if appRole.UserType == 3 {
145
+	//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
146
+	//		if getPermissionErr != nil {
147
+	//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
148
+	//			return
149
+	//		} else if headNursePermission == nil {
150
+	//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
151
+	//			return
152
+	//		}
153
+	//	}
154
+	//}
155
 
155
 
156
 	if appRole.UserType == 2 || appRole.UserType == 1 {
156
 	if appRole.UserType == 2 || appRole.UserType == 1 {
157
 		prescription_doctor = appRole.AdminUserId
157
 		prescription_doctor = appRole.AdminUserId
249
 			service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
249
 			service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
250
 		}
250
 		}
251
 
251
 
252
-		template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
253
-		if template.TemplateId == 1 {
254
-			if dialysisPrescription.Creater > 0 && dialysisPrescription.Creater != adminUserInfo.AdminUser.Id {
255
-				headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
256
-				if getPermissionErr != nil {
257
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
258
-					return
259
-				} else if headNursePermission == nil {
260
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
261
-					return
262
-				}
263
-			}
264
-		}
252
+		//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
253
+		//if template.TemplateId == 1 {
254
+		//	if dialysisPrescription.Creater > 0 && dialysisPrescription.Creater != adminUserInfo.AdminUser.Id {
255
+		//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
256
+		//		if getPermissionErr != nil {
257
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
258
+		//			return
259
+		//		} else if headNursePermission == nil {
260
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
261
+		//			return
262
+		//		}
263
+		//	}
264
+		//}
265
 
265
 
266
 		_, record := service.FindAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
266
 		_, record := service.FindAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
267
 		if record.IsOpen == 1 {
267
 		if record.IsOpen == 1 {
1483
 		service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1483
 		service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1484
 	}
1484
 	}
1485
 
1485
 
1486
-	template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
1487
-
1488
-	if template.TemplateId == 2 || template.TemplateId == 6 {
1489
-		if appRole.UserType == 3 {
1490
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1491
-			if getPermissionErr != nil {
1492
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1493
-				return
1494
-			} else if headNursePermission == nil {
1495
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1496
-				return
1497
-			}
1498
-		}
1499
-	}
1486
+	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
1487
+	//
1488
+	//if template.TemplateId == 2 || template.TemplateId == 6 {
1489
+	//	if appRole.UserType == 3 {
1490
+	//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1491
+	//		if getPermissionErr != nil {
1492
+	//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1493
+	//			return
1494
+	//		} else if headNursePermission == nil {
1495
+	//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1496
+	//			return
1497
+	//		}
1498
+	//	}
1499
+	//}
1500
 
1500
 
1501
 	prescription := models.DialysisPrescription{
1501
 	prescription := models.DialysisPrescription{
1502
 		UserOrgId:                 adminUserInfo.CurrentOrgId,
1502
 		UserOrgId:                 adminUserInfo.CurrentOrgId,
1565
 		prescription.Creater = adminUserInfo.AdminUser.Id
1565
 		prescription.Creater = adminUserInfo.AdminUser.Id
1566
 	} else { //修改
1566
 	} else { //修改
1567
 
1567
 
1568
-		template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
1569
-		if template.TemplateId == 1 {
1570
-			if dialysisPrescription.Creater != adminUserInfo.AdminUser.Id && dialysisPrescription.Creater != 0 {
1571
-				headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1572
-				if getPermissionErr != nil {
1573
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1574
-					return
1575
-				} else if headNursePermission == nil {
1576
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1577
-					return
1578
-				}
1579
-			}
1580
-		}
1568
+		//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
1569
+		//if template.TemplateId == 1 {
1570
+		//	if dialysisPrescription.Creater != adminUserInfo.AdminUser.Id && dialysisPrescription.Creater != 0 {
1571
+		//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1572
+		//		if getPermissionErr != nil {
1573
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1574
+		//			return
1575
+		//		} else if headNursePermission == nil {
1576
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1577
+		//			return
1578
+		//		}
1579
+		//	}
1580
+		//}
1581
 
1581
 
1582
 		_, record := service.FindAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
1582
 		_, record := service.FindAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
1583
 		if record.IsOpen == 1 {
1583
 		if record.IsOpen == 1 {
2941
 		}
2941
 		}
2942
 
2942
 
2943
 	} else { //修改
2943
 	} else { //修改
2944
-		if receiveTreatment.Creater != adminUserInfo.AdminUser.Id {
2945
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
2946
-			if getPermissionErr != nil {
2947
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2948
-				return
2949
-			} else if headNursePermission == nil {
2950
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2951
-				return
2952
-			}
2953
-		}
2944
+		//if receiveTreatment.Creater != adminUserInfo.AdminUser.Id {
2945
+		//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
2946
+		//	if getPermissionErr != nil {
2947
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2948
+		//		return
2949
+		//	} else if headNursePermission == nil {
2950
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2951
+		//		return
2952
+		//	}
2953
+		//}
2954
 
2954
 
2955
 		receiveTreatmentAsses.Creater = receiveTreatment.Creater
2955
 		receiveTreatmentAsses.Creater = receiveTreatment.Creater
2956
 		receiveTreatmentAsses.CreatedTime = receiveTreatment.CreatedTime
2956
 		receiveTreatmentAsses.CreatedTime = receiveTreatment.CreatedTime
3068
 	}
3068
 	}
3069
 
3069
 
3070
 	if assessment.ID > 0 {
3070
 	if assessment.ID > 0 {
3071
-		if appRole.UserType == 3 {
3072
-			if assessment.Creater != adminUserInfo.AdminUser.Id && assessment.Creater != 0 {
3073
-				headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
3074
-				if getPermissionErr != nil {
3075
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3076
-					return
3077
-				} else if headNursePermission == nil {
3078
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
3079
-					return
3080
-				}
3081
-			}
3082
-		}
3071
+		//if appRole.UserType == 3 {
3072
+		//	if assessment.Creater != adminUserInfo.AdminUser.Id && assessment.Creater != 0 {
3073
+		//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
3074
+		//		if getPermissionErr != nil {
3075
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3076
+		//			return
3077
+		//		} else if headNursePermission == nil {
3078
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
3079
+		//			return
3080
+		//		}
3081
+		//	}
3082
+		//}
3083
 		if appRole.UserType == 2 || appRole.UserType == 1 {
3083
 		if appRole.UserType == 2 || appRole.UserType == 1 {
3084
 			assessment.AssessmentDoctor = adminUserInfo.AdminUser.Id
3084
 			assessment.AssessmentDoctor = adminUserInfo.AdminUser.Id
3085
 			assessment.AssessmentTime = time.Now().Unix()
3085
 			assessment.AssessmentTime = time.Now().Unix()
3261
 
3261
 
3262
 		}
3262
 		}
3263
 	} else { //修改
3263
 	} else { //修改
3264
-		if appRole.UserType == 3 {
3265
-			if evaluation.Creater != adminUserInfo.AdminUser.Id && evaluation.Creater != 0 {
3266
-				headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
3267
-				if getPermissionErr != nil {
3268
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3269
-					return
3270
-				} else if headNursePermission == nil {
3271
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
3272
-					return
3273
-				}
3274
-			}
3275
-		}
3264
+		//if appRole.UserType == 3 {
3265
+		//	if evaluation.Creater != adminUserInfo.AdminUser.Id && evaluation.Creater != 0 {
3266
+		//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
3267
+		//		if getPermissionErr != nil {
3268
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3269
+		//			return
3270
+		//		} else if headNursePermission == nil {
3271
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
3272
+		//			return
3273
+		//		}
3274
+		//	}
3275
+		//}
3276
 
3276
 
3277
 		if appRole.UserType == 2 || appRole.UserType == 1 {
3277
 		if appRole.UserType == 2 || appRole.UserType == 1 {
3278
 			assessmentBeforeDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
3278
 			assessmentBeforeDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
3529
 		}
3529
 		}
3530
 
3530
 
3531
 	} else { //修改
3531
 	} else { //修改
3532
-		if tempTreatmentSummary.Creater != adminUserInfo.AdminUser.Id {
3533
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
3534
-			if getPermissionErr != nil {
3535
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3536
-				return
3537
-			} else if headNursePermission == nil {
3538
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
3539
-				return
3540
-			}
3541
-		}
3532
+		//if tempTreatmentSummary.Creater != adminUserInfo.AdminUser.Id {
3533
+		//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
3534
+		//	if getPermissionErr != nil {
3535
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3536
+		//		return
3537
+		//	} else if headNursePermission == nil {
3538
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
3539
+		//		return
3540
+		//	}
3541
+		//}
3542
 
3542
 
3543
 		treatmentSummary.Creater = tempTreatmentSummary.Creater
3543
 		treatmentSummary.Creater = tempTreatmentSummary.Creater
3544
 		treatmentSummary.CreatedTime = tempTreatmentSummary.CreatedTime
3544
 		treatmentSummary.CreatedTime = tempTreatmentSummary.CreatedTime
3889
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3889
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3890
 		return
3890
 		return
3891
 	}
3891
 	}
3892
-	if monitor != nil {
3893
-		if monitor.MonitoringNurse != adminInfo.AdminUser.Id {
3894
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminInfo.CurrentOrgId, adminInfo.CurrentAppId, adminInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
3895
-			if getPermissionErr != nil {
3896
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3897
-				return
3898
-			} else if headNursePermission == nil {
3899
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
3900
-				return
3901
-			}
3902
-		}
3903
-	}
3892
+	//if monitor != nil {
3893
+	//	if monitor.MonitoringNurse != adminInfo.AdminUser.Id {
3894
+	//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminInfo.CurrentOrgId, adminInfo.CurrentAppId, adminInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
3895
+	//		if getPermissionErr != nil {
3896
+	//			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3897
+	//			return
3898
+	//		} else if headNursePermission == nil {
3899
+	//			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
3900
+	//			return
3901
+	//		}
3902
+	//	}
3903
+	//}
3904
 
3904
 
3905
 	err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID, adminInfo.AdminUser.Id)
3905
 	err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID, adminInfo.AdminUser.Id)
3906
 	if err != nil {
3906
 	if err != nil {

+ 30 - 30
controllers/dialysis_record_api_controller.go View File

515
 			return
515
 			return
516
 		}
516
 		}
517
 
517
 
518
-		if monitor.MonitoringNurse != adminUserInfo.AdminUser.Id {
519
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
520
-			if getPermissionErr != nil {
521
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
522
-				return
523
-			} else if headNursePermission == nil {
524
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
525
-				return
526
-			}
527
-		}
518
+		//if monitor.MonitoringNurse != adminUserInfo.AdminUser.Id {
519
+		//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
520
+		//	if getPermissionErr != nil {
521
+		//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
522
+		//		return
523
+		//	} else if headNursePermission == nil {
524
+		//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
525
+		//		return
526
+		//	}
527
+		//}
528
 
528
 
529
 		monitor.OperateTime = monitorParam.OperateTime
529
 		monitor.OperateTime = monitorParam.OperateTime
530
 		monitor.PulseFrequency = monitorParam.PulseFrequency
530
 		monitor.PulseFrequency = monitorParam.PulseFrequency
2366
 
2366
 
2367
 	_, tempDialysisRecord := service.FindDialysisOrderById(record_id)
2367
 	_, tempDialysisRecord := service.FindDialysisOrderById(record_id)
2368
 
2368
 
2369
-	if tempDialysisRecord.Creator != adminUserInfo.AdminUser.Id {
2370
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
2371
-		if getPermissionErr != nil {
2372
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2373
-			return
2374
-		} else if headNursePermission == nil {
2375
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2376
-			return
2377
-		}
2378
-	}
2369
+	//if tempDialysisRecord.Creator != adminUserInfo.AdminUser.Id {
2370
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
2371
+	//	if getPermissionErr != nil {
2372
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2373
+	//		return
2374
+	//	} else if headNursePermission == nil {
2375
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2376
+	//		return
2377
+	//	}
2378
+	//}
2379
 
2379
 
2380
 	scheduleDateStart := startDate.Format("2006-01-02") + " 00:00:00"
2380
 	scheduleDateStart := startDate.Format("2006-01-02") + " 00:00:00"
2381
 	scheduleDateEnd := startDate.Format("2006-01-02") + " 23:59:59"
2381
 	scheduleDateEnd := startDate.Format("2006-01-02") + " 23:59:59"
2511
 	}
2511
 	}
2512
 	_, tempDialysisRecords := service.FindDialysisOrderById(record_id)
2512
 	_, tempDialysisRecords := service.FindDialysisOrderById(record_id)
2513
 
2513
 
2514
-	if tempDialysisRecords.FinishCreator != adminUserInfo.AdminUser.Id {
2515
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
2516
-		if getPermissionErr != nil {
2517
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2518
-			return
2519
-		} else if headNursePermission == nil {
2520
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2521
-			return
2522
-		}
2523
-	}
2514
+	//if tempDialysisRecords.FinishCreator != adminUserInfo.AdminUser.Id {
2515
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
2516
+	//	if getPermissionErr != nil {
2517
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2518
+	//		return
2519
+	//	} else if headNursePermission == nil {
2520
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2521
+	//		return
2522
+	//	}
2523
+	//}
2524
 
2524
 
2525
 	dialysisRecord := &models.DialysisOrder{
2525
 	dialysisRecord := &models.DialysisOrder{
2526
 		ID:             record_id,
2526
 		ID:             record_id,

+ 17 - 0
controllers/gobal_config_api_controller.go View File

1079
 			"template_id": tempInfo.TemplateId,
1079
 			"template_id": tempInfo.TemplateId,
1080
 		}
1080
 		}
1081
 
1081
 
1082
+		if tempOrg != nil && appRole != nil {
1083
+			// 插入一条登录记录
1084
+			ip := this.GetString("ip")
1085
+			loginLog := &models.AdminUserLoginLog{
1086
+				AdminUserId: adminUser.Id,
1087
+				OrgId:       tempOrg.Id,
1088
+				AppId:       appRole.AppId,
1089
+				IP:          ip,
1090
+				OperateType: 3,
1091
+				AppType:     3,
1092
+				CreateTime:  time.Now().Unix(),
1093
+			}
1094
+			if insertErr := service.InsertLoginLog(loginLog); insertErr != nil {
1095
+				utils.ErrorLog("为手机号为%v的用户插入一条登录记录失败:%v", mobile, insertErr)
1096
+			}
1097
+		}
1098
+
1082
 		this.SetSession("admin_user_info", adminUserInfo)
1099
 		this.SetSession("admin_user_info", adminUserInfo)
1083
 
1100
 
1084
 		this.ServeSuccessJSON(map[string]interface{}{
1101
 		this.ServeSuccessJSON(map[string]interface{}{

+ 1 - 1
controllers/mobile_api_controllers/mobile_api_base_controller.go View File

83
 	}
83
 	}
84
 
84
 
85
 	if this.Ctx.Request.Header.Get("Permission") == "1" {
85
 	if this.Ctx.Request.Header.Get("Permission") == "1" {
86
-		if !adminUserInfo.AdminUser.IsSuperAdmin || adminUserInfo.AdminUser.Id != adminUserInfo.Org.Creator {
86
+		if adminUserInfo.AdminUser.Id != adminUserInfo.Org.Creator { //超级管理员不受此限制
87
 
87
 
88
 			isPermission := false
88
 			isPermission := false
89
 			adminUserInfo := this.GetMobileAdminUserInfo()
89
 			adminUserInfo := this.GetMobileAdminUserInfo()

+ 37 - 34
controllers/mobile_api_controllers/patient_api_controller.go View File

62
 		return
62
 		return
63
 	}
63
 	}
64
 
64
 
65
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
66
-	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
67
-
68
-	if template.TemplateId == 2 || template.TemplateId == 6 {
69
-		if appRole.UserType == 3 {
70
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
71
-			if getPermissionErr != nil {
72
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
73
-				return
74
-			} else if headNursePermission == nil {
75
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
76
-				return
77
-			}
78
-		}
79
-	}
65
+	//根据路由来做权限
66
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
67
+	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
68
+
69
+	//if template.TemplateId == 2 || template.TemplateId == 6 {
70
+	//	if appRole.UserType == 3 {
71
+	//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
72
+	//		if getPermissionErr != nil {
73
+	//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
74
+	//			return
75
+	//		} else if headNursePermission == nil {
76
+	//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
77
+	//			return
78
+	//		}
79
+	//	}
80
+	//}
80
 
81
 
81
 	var solution models.DialysisSolution
82
 	var solution models.DialysisSolution
82
 
83
 
2208
 	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdvicePermissionDeniedModify)
2209
 	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdvicePermissionDeniedModify)
2209
 	//	return
2210
 	//	return
2210
 	//}
2211
 	//}
2211
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
2212
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
2212
 
2213
 
2213
-	if appRole.UserType == 3 {
2214
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
2215
-		if getPermissionErr != nil {
2216
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2217
-			return
2218
-		} else if headNursePermission == nil {
2219
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2220
-			return
2221
-		}
2222
-	}
2214
+	//if appRole.UserType == 3 {
2215
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
2216
+	//	if getPermissionErr != nil {
2217
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2218
+	//		return
2219
+	//	} else if headNursePermission == nil {
2220
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2221
+	//		return
2222
+	//	}
2223
+	//}
2224
+	//TODO根据路由做权限
2223
 
2225
 
2224
 	group_no, _ := c.GetInt64("group_no")
2226
 	group_no, _ := c.GetInt64("group_no")
2225
 	if group_no <= 0 {
2227
 	if group_no <= 0 {
2445
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
2447
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
2446
 			return
2448
 			return
2447
 		}
2449
 		}
2448
-		if !adminUserInfo.AdminUser.IsSuperAdmin && advice.AdviceDoctor != adminUserInfo.AdminUser.Id {
2449
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2450
-			return
2451
-		}
2450
+		//TODO 根据路由来做权限
2451
+		//if !adminUserInfo.AdminUser.IsSuperAdmin && advice.AdviceDoctor != adminUserInfo.AdminUser.Id {
2452
+		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2453
+		//	return
2454
+		//}
2452
 
2455
 
2453
 		advice.Status = 0
2456
 		advice.Status = 0
2454
 		advice.UpdatedTime = time.Now().Unix()
2457
 		advice.UpdatedTime = time.Now().Unix()
2562
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
2565
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
2563
 		return
2566
 		return
2564
 	}
2567
 	}
2565
-	if !adminUserInfo.AdminUser.IsSuperAdmin && advice.AdviceDoctor != adminUserInfo.AdminUser.Id {
2566
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2567
-		return
2568
-	}
2568
+	//if !adminUserInfo.AdminUser.IsSuperAdmin && advice.AdviceDoctor != adminUserInfo.AdminUser.Id {
2569
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2570
+	//	return
2571
+	//}
2569
 
2572
 
2570
 	advice.Status = 0
2573
 	advice.Status = 0
2571
 	advice.UpdatedTime = time.Now().Unix()
2574
 	advice.UpdatedTime = time.Now().Unix()

+ 3 - 1
controllers/orginfo_api_controller.go View File

57
 func (c *OrgInfoApiController) EditOrgInfo() {
57
 func (c *OrgInfoApiController) EditOrgInfo() {
58
 	adminUserInfo := c.GetAdminUserInfo()
58
 	adminUserInfo := c.GetAdminUserInfo()
59
 
59
 
60
-	if !adminUserInfo.AdminUser.IsSuperAdmin {
60
+	tempOrg, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
61
+
62
+	if tempOrg != nil && adminUserInfo.AdminUser.Id != tempOrg.Creator {
61
 		c.ServeFailJsonSend(enums.ErrorCodePermissionDenied, "权限不足")
63
 		c.ServeFailJsonSend(enums.ErrorCodePermissionDenied, "权限不足")
62
 		return
64
 		return
63
 	}
65
 	}

+ 90 - 90
controllers/patient_api_controller.go View File

242
 	//获取老表的最后一条数据
242
 	//获取老表的最后一条数据
243
 	patients, err := service.GetLastPatientData(adminUserInfo.CurrentOrgId)
243
 	patients, err := service.GetLastPatientData(adminUserInfo.CurrentOrgId)
244
 	patientsNew := models.XtPatientsNew{
244
 	patientsNew := models.XtPatientsNew{
245
-		UserOrgId:                    adminUserInfo.CurrentOrgId,
246
-		UserId:                       0,
247
-		Avatar:                       patients.Avatar,
248
-		PatientType:                  patients.PatientType,
249
-		DialysisNo:                   patients.DialysisNo,
250
-		AdmissionNumber:              patients.AdmissionNumber,
251
-		Source:                       patients.Source,
252
-		Lapseto:                      patients.Lapseto,
253
-		PartitionId:                  patients.PartitionId,
254
-		BedId:                        patients.BedId,
255
-		Name:                         patients.Name,
256
-		Alias:                        patients.Alias,
257
-		Gender:                       patients.Gender,
258
-		MaritalStatus:                patients.MaritalStatus,
259
-		IdCardNo:                     patients.IdCardNo,
260
-		Birthday:                     patients.Birthday,
261
-		ReimbursementWayId:           patients.ReimbursementWayId,
262
-		HealthCareType:               patients.HealthCareType,
263
-		HealthCareNo:                 patients.HealthCareNo,
264
-		HealthCareDueDate:            patients.HealthCareDueDate,
265
-		Height:                       patients.Height,
266
-		BloodType:                    patients.BloodType,
267
-		Rh:                           patients.Rh,
245
+		UserOrgId:          adminUserInfo.CurrentOrgId,
246
+		UserId:             0,
247
+		Avatar:             patients.Avatar,
248
+		PatientType:        patients.PatientType,
249
+		DialysisNo:         patients.DialysisNo,
250
+		AdmissionNumber:    patients.AdmissionNumber,
251
+		Source:             patients.Source,
252
+		Lapseto:            patients.Lapseto,
253
+		PartitionId:        patients.PartitionId,
254
+		BedId:              patients.BedId,
255
+		Name:               patients.Name,
256
+		Alias:              patients.Alias,
257
+		Gender:             patients.Gender,
258
+		MaritalStatus:      patients.MaritalStatus,
259
+		IdCardNo:           patients.IdCardNo,
260
+		Birthday:           patients.Birthday,
261
+		ReimbursementWayId: patients.ReimbursementWayId,
262
+		HealthCareType:     patients.HealthCareType,
263
+		HealthCareNo:       patients.HealthCareNo,
264
+		HealthCareDueDate:  patients.HealthCareDueDate,
265
+		Height:             patients.Height,
266
+		BloodType:          patients.BloodType,
267
+		Rh:                 patients.Rh,
268
 		HealthCareDueAlertDate:       patients.HealthCareDueAlertDate,
268
 		HealthCareDueAlertDate:       patients.HealthCareDueAlertDate,
269
 		EducationLevel:               patients.EducationLevel,
269
 		EducationLevel:               patients.EducationLevel,
270
 		Profession:                   patients.Profession,
270
 		Profession:                   patients.Profession,
310
 		Nation:                       patients.Nation,
310
 		Nation:                       patients.Nation,
311
 		NativePlace:                  patients.NativePlace,
311
 		NativePlace:                  patients.NativePlace,
312
 		Age:                          patients.Age,
312
 		Age:                          patients.Age,
313
-		InfectiousNextRecordTime:     patients.InfectiousNextRecordTime,
314
-		IsInfectious:                 patients.IsInfectious,
315
-		RemindCycle:                  patients.RemindCycle,
316
-		ResponseResult:               patients.ResponseResult,
317
-		IsOpenRemind:                 patients.IsOpenRemind,
318
-		FirstTreatmentDate:           patients.FirstTreatmentDate,
319
-		DialysisAge:                  patients.DialysisAge,
320
-		ExpenseKind:                  patients.ExpenseKind,
321
-		TellPhone:                    patients.TellPhone,
322
-		ContactName:                  patients.ContactName,
323
-		BloodPatients:                1,
324
-		SlowPatients:                 0,
325
-		MemberPatients:               0,
326
-		EcommerPatients:              "",
327
-		BloodId:                      patients.ID,
328
-		SlowId:                       0,
329
-		MemberId:                     0,
330
-		MemberFistdate:               0,
331
-		MemberPatienttype:            0,
332
-		MemberTreatement:             0,
333
-		EquitmentId:                  "",
313
+		InfectiousNextRecordTime: patients.InfectiousNextRecordTime,
314
+		IsInfectious:             patients.IsInfectious,
315
+		RemindCycle:              patients.RemindCycle,
316
+		ResponseResult:           patients.ResponseResult,
317
+		IsOpenRemind:             patients.IsOpenRemind,
318
+		FirstTreatmentDate:       patients.FirstTreatmentDate,
319
+		DialysisAge:              patients.DialysisAge,
320
+		ExpenseKind:              patients.ExpenseKind,
321
+		TellPhone:                patients.TellPhone,
322
+		ContactName:              patients.ContactName,
323
+		BloodPatients:            1,
324
+		SlowPatients:             0,
325
+		MemberPatients:           0,
326
+		EcommerPatients:          "",
327
+		BloodId:                  patients.ID,
328
+		SlowId:                   0,
329
+		MemberId:                 0,
330
+		MemberFistdate:           0,
331
+		MemberPatienttype:        0,
332
+		MemberTreatement:         0,
333
+		EquitmentId:              "",
334
 	}
334
 	}
335
 
335
 
336
 	err = service.CreatePatientsNew(&patientsNew)
336
 	err = service.CreatePatientsNew(&patientsNew)
1616
 		return
1616
 		return
1617
 	}
1617
 	}
1618
 
1618
 
1619
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1619
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1620
 
1620
 
1621
-	if appRole.UserType == 3 {
1622
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1623
-		if getPermissionErr != nil {
1624
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1625
-			return
1626
-		} else if headNursePermission == nil {
1627
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1628
-			return
1629
-		}
1630
-	}
1621
+	//if appRole.UserType == 3 {
1622
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1623
+	//	if getPermissionErr != nil {
1624
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1625
+	//		return
1626
+	//	} else if headNursePermission == nil {
1627
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1628
+	//		return
1629
+	//	}
1630
+	//}
1631
 
1631
 
1632
 	//if advice.AdviceDoctor != adminUserInfo.AdminUser.Id {
1632
 	//if advice.AdviceDoctor != adminUserInfo.AdminUser.Id {
1633
 	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCanotEditOtherAdvice)
1633
 	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCanotEditOtherAdvice)
1735
 
1735
 
1736
 	adminUserInfo := c.GetAdminUserInfo()
1736
 	adminUserInfo := c.GetAdminUserInfo()
1737
 
1737
 
1738
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1739
-
1740
-	if appRole.UserType == 3 {
1741
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1742
-		if getPermissionErr != nil {
1743
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1744
-			return
1745
-		} else if headNursePermission == nil {
1746
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1747
-			return
1748
-		}
1749
-	}
1738
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1739
+	//
1740
+	//if appRole.UserType == 3 {
1741
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1742
+	//	if getPermissionErr != nil {
1743
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1744
+	//		return
1745
+	//	} else if headNursePermission == nil {
1746
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1747
+	//		return
1748
+	//	}
1749
+	//}
1750
 
1750
 
1751
 	advice, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
1751
 	advice, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
1752
 	if advice.ID == 0 {
1752
 	if advice.ID == 0 {
1829
 	//	return
1829
 	//	return
1830
 	//}
1830
 	//}
1831
 
1831
 
1832
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1833
-
1834
-	if appRole.UserType == 3 {
1835
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1836
-		if getPermissionErr != nil {
1837
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1838
-			return
1839
-		} else if headNursePermission == nil {
1840
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1841
-			return
1842
-		}
1843
-	}
1832
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1833
+	//
1834
+	//if appRole.UserType == 3 {
1835
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1836
+	//	if getPermissionErr != nil {
1837
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1838
+	//		return
1839
+	//	} else if headNursePermission == nil {
1840
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1841
+	//		return
1842
+	//	}
1843
+	//}
1844
 
1844
 
1845
 	advice.UpdatedTime = time.Now().Unix()
1845
 	advice.UpdatedTime = time.Now().Unix()
1846
 	advice.Status = 0
1846
 	advice.Status = 0
1873
 		return
1873
 		return
1874
 	}
1874
 	}
1875
 
1875
 
1876
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1877
-	if appRole.UserType == 3 {
1878
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1879
-		if getPermissionErr != nil {
1880
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1881
-			return
1882
-		} else if headNursePermission == nil {
1883
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1884
-			return
1885
-		}
1886
-	}
1876
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1877
+	//if appRole.UserType == 3 {
1878
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1879
+	//	if getPermissionErr != nil {
1880
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1881
+	//		return
1882
+	//	} else if headNursePermission == nil {
1883
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
1884
+	//		return
1885
+	//	}
1886
+	//}
1887
 
1887
 
1888
 	err := service.DeleteGroupAdvice(adminUserInfo.CurrentOrgId, groupNo, adminUserInfo.AdminUser.Id)
1888
 	err := service.DeleteGroupAdvice(adminUserInfo.CurrentOrgId, groupNo, adminUserInfo.AdminUser.Id)
1889
 	if err != nil {
1889
 	if err != nil {

+ 407 - 1
controllers/public_api_controller.go View File

2
 
2
 
3
 import (
3
 import (
4
 	"XT_New/enums"
4
 	"XT_New/enums"
5
+	"XT_New/models"
5
 	"XT_New/service"
6
 	"XT_New/service"
6
 	"encoding/json"
7
 	"encoding/json"
7
 	"fmt"
8
 	"fmt"
9
+	"os"
10
+	"path"
11
+	"runtime"
8
 	"strings"
12
 	"strings"
9
 	"time"
13
 	"time"
10
 
14
 
21
 	beego.Router("/api/app/release", &PublicApiController{}, "Get:AppRelease")
25
 	beego.Router("/api/app/release", &PublicApiController{}, "Get:AppRelease")
22
 	beego.Router("/api/get", &PublicApiController{}, "Get:GetJson")
26
 	beego.Router("/api/get", &PublicApiController{}, "Get:GetJson")
23
 
27
 
28
+	beego.Router("/api/public/handledata", &PublicApiController{}, "Post:HandleData")
29
+
24
 }
30
 }
25
 
31
 
26
 func (c *PublicApiController) GetDoctorAdviceConfig() {
32
 func (c *PublicApiController) GetDoctorAdviceConfig() {
43
 		"time":      timeNowStr,
49
 		"time":      timeNowStr,
44
 		"timestamp": timeNowStamp,
50
 		"timestamp": timeNowStamp,
45
 	})
51
 	})
46
-
47
 }
52
 }
48
 
53
 
49
 func (c *PublicApiController) AppRelease() {
54
 func (c *PublicApiController) AppRelease() {
156
 	//fmt.Println(string(jsonBytes))
161
 	//fmt.Println(string(jsonBytes))
157
 
162
 
158
 }
163
 }
164
+
165
+func (c *PublicApiController) HandleData() {
166
+	//org_app, _ := service.GetAllAppOrg()
167
+	org_role, _ := service.GetAllRole()
168
+
169
+	var org_ids []int64
170
+
171
+	//for _, apps := range org_app {
172
+	//	xt_org_app, _ := service.GetAppByType(int64(apps.OrgId), 3)
173
+	//	scrm_org_app, _ := service.GetAppByType(int64(apps.OrgId), 1)
174
+	//	cdm_org_app, _ := service.GetAppByType(int64(apps.OrgId), 4)
175
+	//	mall_org_app, _ := service.GetAppByType(int64(apps.OrgId), 5)
176
+	//	org_app_6, _ := service.GetAppByType(int64(apps.OrgId), 6)
177
+	//	org_app_7, _ := service.GetAppByType(int64(apps.OrgId), 7)
178
+	//	org_app_8, _ := service.GetAppByType(int64(apps.OrgId), 8)
179
+	//	org_app_9, _ := service.GetAppByType(int64(apps.OrgId), 9)
180
+	//	org_app_10, _ := service.GetAppByType(int64(apps.OrgId), 10)
181
+	//	org_app_11, _ := service.GetAppByType(int64(apps.OrgId), 11)
182
+	//	org_app_12, _ := service.GetAppByType(int64(apps.OrgId), 12)
183
+	//	org_app_13, _ := service.GetAppByType(int64(apps.OrgId), 13)
184
+	//	org_app_14, _ := service.GetAppByType(int64(apps.OrgId), 14)
185
+	//	org_app_15, _ := service.GetAppByType(int64(apps.OrgId), 15)
186
+	//
187
+	//	var xt_temp_org_app *models.OrgApp
188
+	//	var mall_temp_org_app *models.OrgApp
189
+	//
190
+	//
191
+	//	if xt_org_app == nil || xt_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
192
+	//
193
+	//		app, _ := service.GetOrgApp(0,3)
194
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
195
+	//
196
+	//		app.Id = 0
197
+	//		app.OrgId = apps.OrgId
198
+	//		app.Creator = int(org.Creator)
199
+	//		app.Number  = 0
200
+	//		app.Status = 1
201
+	//		app.ModifyTime = time.Now().Unix()
202
+	//		app.CreateTime = time.Now().Unix()
203
+	//		service.CreateOrgApp(app)
204
+	//		xt_temp_org_app = app
205
+	//	}else{
206
+	//
207
+	//		xt_temp_org_app = xt_org_app
208
+	//
209
+	//	}
210
+	//
211
+	//	if scrm_org_app == nil || scrm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
212
+	//
213
+	//		app, _ := service.GetOrgApp(0,1)
214
+	//		//org, _ := service.GetOrgById(int64(12))
215
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
216
+	//
217
+	//		app.OrgId = apps.OrgId
218
+	//		app.Id = 0
219
+	//
220
+	//		app.Creator = int(org.Creator)
221
+	//		app.Number  = 0
222
+	//		app.Status = 1
223
+	//		app.ModifyTime = time.Now().Unix()
224
+	//		app.CreateTime = time.Now().Unix()
225
+	//		service.CreateOrgApp(app)
226
+	//
227
+	//	}
228
+	//
229
+	//	if cdm_org_app == nil || cdm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
230
+	//		app, _ := service.GetOrgApp(0,4)
231
+	//		//org, _ := service.GetOrgById(int64(12))
232
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
233
+	//
234
+	//		app.OrgId = apps.OrgId
235
+	//		app.Creator = int(org.Creator)
236
+	//		app.Number  = 0
237
+	//		app.Id = 0
238
+	//
239
+	//		app.Status = 1
240
+	//		app.ModifyTime = time.Now().Unix()
241
+	//		app.CreateTime = time.Now().Unix()
242
+	//		service.CreateOrgApp(app)
243
+	//	}
244
+	//
245
+	//	if mall_org_app == nil || mall_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
246
+	//		app, _ := service.GetOrgApp(0,5)
247
+	//		//org, _ := service.GetOrgById(int64(12))
248
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
249
+	//
250
+	//		app.OrgId = apps.OrgId
251
+	//		app.Creator = int(org.Creator)
252
+	//		app.Number  = 0
253
+	//		app.Id = 0
254
+	//
255
+	//		app.Status = 1
256
+	//		app.ModifyTime = time.Now().Unix()
257
+	//		app.CreateTime = time.Now().Unix()
258
+	//		service.CreateOrgApp(app)
259
+	//		mall_temp_org_app = app
260
+	//	}else{
261
+	//		mall_temp_org_app = mall_org_app
262
+	//	}
263
+	//
264
+	//
265
+	//
266
+	//	if org_app_6 == nil || org_app_6.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
267
+	//		app, _ := service.GetOrgApp(0,6)
268
+	//		//org, _ := service.GetOrgById(int64(12))
269
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
270
+	//
271
+	//		app.OrgId = apps.OrgId
272
+	//		app.Creator = int(org.Creator)
273
+	//		app.Number  = 0
274
+	//		app.Id = 0
275
+	//
276
+	//		app.Status = 1
277
+	//		app.ModifyTime = time.Now().Unix()
278
+	//		app.CreateTime = time.Now().Unix()
279
+	//		app.Pid  = xt_temp_org_app.Id
280
+	//		service.CreateOrgApp(app)
281
+	//
282
+	//
283
+	//	}
284
+	//	if org_app_7 == nil || org_app_7.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
285
+	//		app, _ := service.GetOrgApp(0,7)
286
+	//		//org, _ := service.GetOrgById(int64(12))
287
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
288
+	//
289
+	//		app.OrgId = apps.OrgId
290
+	//		app.Creator = int(org.Creator)
291
+	//		app.Number  = 0
292
+	//		app.Status = 1
293
+	//		app.Id = 0
294
+	//
295
+	//		app.ModifyTime = time.Now().Unix()
296
+	//		app.CreateTime = time.Now().Unix()
297
+	//		app.Pid  = xt_temp_org_app.Id
298
+	//
299
+	//		service.CreateOrgApp(app)
300
+	//	}
301
+	//	if org_app_8 == nil || org_app_8.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
302
+	//		app, _ := service.GetOrgApp(0,8)
303
+	//		//org, _ := service.GetOrgById(int64(12))
304
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
305
+	//
306
+	//		app.OrgId = apps.OrgId
307
+	//		app.Creator = int(org.Creator)
308
+	//		app.Number  = 0
309
+	//		app.Id = 0
310
+	//
311
+	//		app.Pid  = mall_temp_org_app.Id
312
+	//
313
+	//		app.Status = 1
314
+	//		app.ModifyTime = time.Now().Unix()
315
+	//		app.CreateTime = time.Now().Unix()
316
+	//		service.CreateOrgApp(app)
317
+	//	}
318
+	//	if org_app_9 == nil || org_app_9.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
319
+	//		app, _ := service.GetOrgApp(0,9)
320
+	//		//org, _ := service.GetOrgById(int64(12))
321
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
322
+	//
323
+	//		app.OrgId = apps.OrgId
324
+	//		app.Pid  = xt_temp_org_app.Id
325
+	//
326
+	//		app.Creator = int(org.Creator)
327
+	//		app.Number  = 0
328
+	//		app.Id = 0
329
+	//
330
+	//		app.Status = 1
331
+	//		app.ModifyTime = time.Now().Unix()
332
+	//		app.CreateTime = time.Now().Unix()
333
+	//		service.CreateOrgApp(app)
334
+	//
335
+	//	}
336
+	//	if org_app_10 == nil || org_app_10.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
337
+	//		app, _ := service.GetOrgApp(0,10)
338
+	//		//org, _ := service.GetOrgById(int64(12))
339
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
340
+	//
341
+	//		app.OrgId = apps.OrgId
342
+	//		app.Creator = int(org.Creator)
343
+	//		app.Pid  = xt_temp_org_app.Id
344
+	//
345
+	//		app.Number  = 0
346
+	//		app.Id = 0
347
+	//
348
+	//		app.Status = 1
349
+	//		app.ModifyTime = time.Now().Unix()
350
+	//		app.CreateTime = time.Now().Unix()
351
+	//		service.CreateOrgApp(app)
352
+	//	}
353
+	//	if org_app_11 == nil || org_app_11.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
354
+	//		app, _ := service.GetOrgApp(0,11)
355
+	//		//org, _ := service.GetOrgById(int64(12))
356
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
357
+	//
358
+	//		app.OrgId = app.OrgId
359
+	//		app.Creator = int(org.Creator)
360
+	//		app.Pid  = xt_temp_org_app.Id
361
+	//		app.Id = 0
362
+	//
363
+	//		app.Number  = 0
364
+	//		app.Status = 1
365
+	//		app.ModifyTime = time.Now().Unix()
366
+	//		app.CreateTime = time.Now().Unix()
367
+	//		service.CreateOrgApp(app)
368
+	//	}
369
+	//	if org_app_12 == nil || org_app_12.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
370
+	//		app, _ := service.GetOrgApp(0,12)
371
+	//		//org, _ := service.GetOrgById(int64(12))
372
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
373
+	//
374
+	//		app.OrgId = apps.OrgId
375
+	//		app.Creator = int(org.Creator)
376
+	//		app.Pid  = xt_temp_org_app.Id
377
+	//		app.Number  = 0
378
+	//		app.Status = 1
379
+	//		app.Id = 0
380
+	//
381
+	//		app.ModifyTime = time.Now().Unix()
382
+	//		app.CreateTime = time.Now().Unix()
383
+	//		service.CreateOrgApp(app)
384
+	//	}
385
+	//	if org_app_13 == nil || org_app_13.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
386
+	//		app, _ := service.GetOrgApp(0,13)
387
+	//		//org, _ := service.GetOrgById(int64(12))
388
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
389
+	//
390
+	//		app.OrgId = apps.OrgId
391
+	//		app.Creator = int(org.Creator)
392
+	//		app.Pid  = xt_temp_org_app.Id
393
+	//		app.Number  = 0
394
+	//		app.Id = 0
395
+	//
396
+	//		app.Status = 1
397
+	//		app.ModifyTime = time.Now().Unix()
398
+	//		app.CreateTime = time.Now().Unix()
399
+	//		service.CreateOrgApp(app)
400
+	//	}
401
+	//	if org_app_14 == nil || org_app_14.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
402
+	//		app, _ := service.GetOrgApp(0,14)
403
+	//		//org, _ := service.GetOrgById(int64(12))
404
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
405
+	//
406
+	//		app.OrgId = apps.OrgId
407
+	//		app.Creator = int(org.Creator)
408
+	//		app.Pid  = xt_temp_org_app.Id
409
+	//		app.Id = 0
410
+	//		app.Number  = 0
411
+	//		app.Status = 1
412
+	//		app.ModifyTime = time.Now().Unix()
413
+	//		app.CreateTime = time.Now().Unix()
414
+	//		service.CreateOrgApp(app)
415
+	//	}
416
+	//
417
+	//	if org_app_15 == nil || org_app_15.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
418
+	//		app, _ := service.GetOrgApp(0,15)
419
+	//		//org, _ := service.GetOrgById(int64(12))
420
+	//		org, _ := service.GetOrgById(int64(apps.OrgId))
421
+	//
422
+	//		app.OrgId = apps.OrgId
423
+	//		app.Creator = int(org.Creator)
424
+	//		app.Pid  = xt_temp_org_app.Id
425
+	//		app.Number  = 0
426
+	//		app.Status = 1
427
+	//		app.Id = 0
428
+	//		app.ModifyTime = time.Now().Unix()
429
+	//		app.CreateTime = time.Now().Unix()
430
+	//		service.CreateOrgApp(app)
431
+	//	}
432
+	//}
433
+	//
434
+	for _, role := range org_role {
435
+		org_ids = append(org_ids, role.OrgId)
436
+	}
437
+	//
438
+	//
439
+	////创建内置角色
440
+	//InitRoleAndPurviews(org_ids)
441
+
442
+	//var org_id int = 0
443
+	////管理员
444
+	//app_roles  := service.GetAllUserRoleByUserTypeOne(org_id)
445
+	//for _, item := range app_roles{
446
+	//	var ids string
447
+	//	if len(item.RoleIds) == 0{
448
+	//		ids = strconv.FormatInt( item.RoleId,10)
449
+	//	}else{
450
+	//
451
+	//		ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
452
+	//	}
453
+	//
454
+	//	service.UpdateRoleIds(item.Id, ids)
455
+	//}
456
+	////护士医生
457
+	//app_roles2  := service.GetAllUserRoleByUserTypeOther(org_id)
458
+	//for _, item := range app_roles2{
459
+	//	var ids string
460
+	//	if len(item.RoleIds) == 0{
461
+	//		ids = strconv.FormatInt( item.RoleId,10)
462
+	//	}else{
463
+	//		ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
464
+	//	}
465
+	//	if item.UserType == 2{
466
+	//		role := service.FindRoleByUserTypeOne(item.OrgId)
467
+	//		ids = ids +"," + strconv.FormatInt(role.Id,10)
468
+	//
469
+	//	} else if item.UserType == 3{
470
+	//		role := service.FindRoleByUserTypeTwo(item.OrgId)
471
+	//		ids = ids +"," + strconv.FormatInt(role.Id,10)
472
+	//	}
473
+	//	service.UpdateRoleIds(item.Id, ids)
474
+	//}
475
+	c.ServeSuccessJSON(map[string]interface{}{
476
+		"msg": "ok",
477
+	})
478
+
479
+}
480
+
481
+func InitRoleAndPurviews(org_ids []int64) {
482
+	roles := LoadRoleConfig("./role.json").Roles
483
+	for _, org_id := range org_ids {
484
+		app, _ := service.GetOrgApp(org_id, 3)
485
+		if app == nil || app.Id == 0 {
486
+			continue
487
+		}
488
+		for _, item := range roles {
489
+			role := &models.Role{
490
+				RoleName:     item.RoleName,
491
+				RoleIntro:    item.RoleIntroduction,
492
+				Creator:      0,
493
+				OrgId:        org_id,
494
+				AppId:        app.Id,
495
+				IsSuperAdmin: false,
496
+				Status:       1,
497
+				CreateTime:   time.Now().Unix(),
498
+				ModifyTime:   time.Now().Unix(),
499
+				Number:       item.Number,
500
+				IsSystem:     item.IsSystem,
501
+			}
502
+			err := service.CreateOrgRole(role)
503
+			if err == nil {
504
+				purview := &models.RolePurview{
505
+					RoleId:     role.Id,
506
+					OrgId:      org_id,
507
+					AppId:      role.AppId,
508
+					PurviewIds: item.PurviewIds,
509
+					Status:     1,
510
+					CreateTime: time.Now().Unix(),
511
+					ModifyTime: time.Now().Unix(),
512
+				}
513
+				func_purview := &models.SgjUserRoleFuncPurview{
514
+					RoleId:     role.Id,
515
+					OrgId:      org_id,
516
+					AppId:      role.AppId,
517
+					PurviewIds: item.FuncIds,
518
+					Status:     1,
519
+					Ctime:      time.Now().Unix(),
520
+					Mtime:      time.Now().Unix(),
521
+				}
522
+
523
+				service.CreateRolePurview(purview)
524
+				service.CreateFuncRolePurview(func_purview)
525
+			}
526
+		}
527
+
528
+	}
529
+
530
+}
531
+
532
+type RoleConfig struct {
533
+	Roles []*models.VMUserRoleAndPurview "json:roles"
534
+}
535
+
536
+func LoadRoleConfig(dataFile string) *RoleConfig {
537
+	var config RoleConfig
538
+	_, filename, _, _ := runtime.Caller(1)
539
+	datapath := path.Join(path.Dir(filename), dataFile)
540
+	config_file, err := os.Open(datapath)
541
+	if err != nil {
542
+		emit("Failed to open config file '%s': %s\n", datapath, err)
543
+		return &config
544
+	}
545
+
546
+	fi, _ := config_file.Stat()
547
+
548
+	buffer := make([]byte, fi.Size())
549
+	_, err = config_file.Read(buffer)
550
+
551
+	buffer, err = StripComments(buffer) //去掉注释
552
+	if err != nil {
553
+		emit("Failed to strip comments from json: %s\n", err)
554
+		return &config
555
+	}
556
+
557
+	buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
558
+	err = json.Unmarshal(buffer, &config)         //解析json格式数据
559
+	if err != nil {
560
+		emit("Failed unmarshalling json: %s\n", err)
561
+		return &config
562
+	}
563
+	return &config
564
+}

+ 37 - 0
controllers/role.json View File

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

+ 102 - 53
controllers/role_controller.go View File

39
 
39
 
40
 	beego.Router("/api/role/staff", &RoleAPIController{}, "get:GetRoleStaff")
40
 	beego.Router("/api/role/staff", &RoleAPIController{}, "get:GetRoleStaff")
41
 
41
 
42
+	beego.Router("/api/role", &RoleAPIController{}, "get:GetRoleInfo")
43
+
42
 }
44
 }
43
 
45
 
44
 type RoleAPIController struct {
46
 type RoleAPIController struct {
346
 // /api/adminmain [get]
348
 // /api/adminmain [get]
347
 func (this *RoleAPIController) AdminMainView() {
349
 func (this *RoleAPIController) AdminMainView() {
348
 	adminUserInfo := this.GetAdminUserInfo()
350
 	adminUserInfo := this.GetAdminUserInfo()
349
-
350
-	//org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
351
-
352
 	var isSubSuperAdmin bool = false
351
 	var isSubSuperAdmin bool = false
353
 	adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
352
 	adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
354
-
355
-	//app_role, _ := service.GetAppRoleById(adminUserInfo.)
356
-	role_ids := strings.Split(adminUserRole.RoleIds, ",")
357
-
358
-	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
359
-
360
-	if adminUserInfo.AdminUser.Id != org.Creator {
361
-		for _, item := range role_ids {
362
-			id, _ := strconv.ParseInt(item, 10, 64)
363
-			role, _ := service.GetRoleByRoleID(id)
364
-			if role.IsSystem == 1 && role.RoleName == "子管理员" {
365
-				isSubSuperAdmin = true
353
+	if len(adminUserRole.RoleIds) > 0 {
354
+		role_ids := strings.Split(adminUserRole.RoleIds, ",")
355
+		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
356
+		if adminUserInfo.AdminUser.Id != org.Creator {
357
+			for _, item := range role_ids {
358
+				id, _ := strconv.ParseInt(item, 10, 64)
359
+				role, _ := service.GetRoleByRoleID(id)
360
+				if role.IsSystem == 1 && role.RoleName == "子管理员" {
361
+					isSubSuperAdmin = true
362
+				}
366
 			}
363
 			}
367
 		}
364
 		}
368
 	}
365
 	}
366
+	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
369
 
367
 
370
 	viewModels, _, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
368
 	viewModels, _, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
371
 	if getAdminsErr != nil {
369
 	if getAdminsErr != nil {
414
 	var isSubSuperAdmin bool = false
412
 	var isSubSuperAdmin bool = false
415
 	adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
413
 	adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
416
 
414
 
417
-	//app_role, _ := service.GetAppRoleById(adminUserInfo.)
418
-	role_ids := strings.Split(adminUserRole.RoleIds, ",")
415
+	if len(adminUserRole.RoleIds) > 0 {
416
+		//app_role, _ := service.GetAppRoleById(adminUserInfo.)
417
+		role_ids := strings.Split(adminUserRole.RoleIds, ",")
419
 
418
 
420
-	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
419
+		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
421
 
420
 
422
-	if adminUserInfo.AdminUser.Id != org.Creator {
423
-		for _, item := range role_ids {
424
-			id, _ := strconv.ParseInt(item, 10, 64)
425
-			role, _ := service.GetRoleByRoleID(id)
426
-			if role.IsSystem == 1 && role.RoleName == "子管理员" {
427
-				isSubSuperAdmin = true
421
+		if adminUserInfo.AdminUser.Id != org.Creator {
422
+			for _, item := range role_ids {
423
+				id, _ := strconv.ParseInt(item, 10, 64)
424
+				role, _ := service.GetRoleByRoleID(id)
425
+				if role.IsSystem == 1 && role.RoleName == "子管理员" {
426
+					isSubSuperAdmin = true
427
+				}
428
 			}
428
 			}
429
 		}
429
 		}
430
 	}
430
 	}
431
+	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
431
 
432
 
432
 	roles, getRoleErr := service.GetAllValidRoles(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
433
 	roles, getRoleErr := service.GetAllValidRoles(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
433
 	if getRoleErr != nil {
434
 	if getRoleErr != nil {
563
 
564
 
564
 	var isSubSuperAdmin bool = false
565
 	var isSubSuperAdmin bool = false
565
 	adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
566
 	adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
566
-
567
-	//app_role, _ := service.GetAppRoleById(adminUserInfo.)
568
-	role_ids := strings.Split(adminUserRole.RoleIds, ",")
569
-
570
-	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
571
-
572
-	if adminUserInfo.AdminUser.Id != org.Creator {
573
-		for _, item := range role_ids {
574
-			id, _ := strconv.ParseInt(item, 10, 64)
575
-			role, _ := service.GetRoleByRoleID(id)
576
-			if role.IsSystem == 1 && role.RoleName == "子管理员" {
577
-				isSubSuperAdmin = true
567
+	if len(adminUserRole.RoleIds) > 0 {
568
+		role_ids := strings.Split(adminUserRole.RoleIds, ",")
569
+		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
570
+		if adminUserInfo.AdminUser.Id != org.Creator {
571
+			for _, item := range role_ids {
572
+				id, _ := strconv.ParseInt(item, 10, 64)
573
+				role, _ := service.GetRoleByRoleID(id)
574
+				if role.IsSystem == 1 && role.RoleName == "子管理员" {
575
+					isSubSuperAdmin = true
576
+				}
578
 			}
577
 			}
579
 		}
578
 		}
580
 	}
579
 	}
580
+	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
581
 
581
 
582
 	redisClient := service.RedisClient()
582
 	redisClient := service.RedisClient()
583
 	defer redisClient.Close()
583
 	defer redisClient.Close()
829
 	var isSubSuperAdmin bool = false
829
 	var isSubSuperAdmin bool = false
830
 	adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
830
 	adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
831
 
831
 
832
-	//app_role, _ := service.GetAppRoleById(adminUserInfo.)
833
-	role_ids := strings.Split(adminUserRole.RoleIds, ",")
834
-
835
-	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
836
-
837
-	if adminUserInfo.AdminUser.Id != org.Creator {
838
-		for _, item := range role_ids {
839
-			id, _ := strconv.ParseInt(item, 10, 64)
840
-			role, _ := service.GetRoleByRoleID(id)
841
-			if role.IsSystem == 1 && role.RoleName == "子管理员" {
842
-				isSubSuperAdmin = true
832
+	if len(adminUserRole.RoleIds) > 0 {
833
+		//app_role, _ := service.GetAppRoleById(adminUserInfo.)
834
+		role_ids := strings.Split(adminUserRole.RoleIds, ",")
835
+		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
836
+		if adminUserInfo.AdminUser.Id != org.Creator {
837
+			for _, item := range role_ids {
838
+				id, _ := strconv.ParseInt(item, 10, 64)
839
+				role, _ := service.GetRoleByRoleID(id)
840
+				if role.IsSystem == 1 && role.RoleName == "子管理员" {
841
+					isSubSuperAdmin = true
842
+				}
843
 			}
843
 			}
844
 		}
844
 		}
845
 	}
845
 	}
846
+	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
846
 
847
 
847
 	roles, err := service.GetAllOrgValidRoles(adminUserInfo.CurrentOrgId, isSubSuperAdmin)
848
 	roles, err := service.GetAllOrgValidRoles(adminUserInfo.CurrentOrgId, isSubSuperAdmin)
848
 	if err != nil {
849
 	if err != nil {
850
 		return
851
 		return
851
 	} else {
852
 	} else {
852
 		this.ServeSuccessJSON(map[string]interface{}{
853
 		this.ServeSuccessJSON(map[string]interface{}{
853
-			"roles": roles,
854
+			"roles":           roles,
855
+			"isSubSuperAdmin": isSubSuperAdmin,
856
+			"org":             org,
854
 		})
857
 		})
855
 	}
858
 	}
856
 
859
 
859
 func (this *RoleAPIController) GetAllOrgUser() {
862
 func (this *RoleAPIController) GetAllOrgUser() {
860
 	adminUserInfo := this.GetAdminUserInfo()
863
 	adminUserInfo := this.GetAdminUserInfo()
861
 	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
864
 	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
865
+	var isSubSuperAdmin bool = false
866
+	adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
867
+	if len(adminUserRole.RoleIds) > 0 {
868
+		//app_role, _ := service.GetAppRoleById(adminUserInfo.)
869
+		role_ids := strings.Split(adminUserRole.RoleIds, ",")
870
+		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
871
+		if adminUserInfo.AdminUser.Id != org.Creator {
872
+			for _, item := range role_ids {
873
+				id, _ := strconv.ParseInt(item, 10, 64)
874
+				role, _ := service.GetRoleByRoleID(id)
875
+				if role.IsSystem == 1 && role.RoleName == "子管理员" {
876
+					isSubSuperAdmin = true
877
+				}
878
+			}
879
+		}
880
+	}
862
 	viewModels, _, _ := service.GetAllAdminUsersAndRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
881
 	viewModels, _, _ := service.GetAllAdminUsersAndRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
863
 	this.ServeSuccessJSON(map[string]interface{}{
882
 	this.ServeSuccessJSON(map[string]interface{}{
864
-		"admins": viewModels,
865
-		"org":    org,
883
+		"admins":          viewModels,
884
+		"org":             org,
885
+		"isSubSuperAdmin": isSubSuperAdmin,
866
 	})
886
 	})
867
 }
887
 }
868
 
888
 
886
 func (this *RoleAPIController) GetRoleStaff() {
906
 func (this *RoleAPIController) GetRoleStaff() {
887
 	adminUserInfo := this.GetAdminUserInfo()
907
 	adminUserInfo := this.GetAdminUserInfo()
888
 
908
 
909
+	var isSubSuperAdmin bool = false
910
+	adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
911
+	if len(adminUserRole.RoleIds) > 0 {
912
+		role_ids := strings.Split(adminUserRole.RoleIds, ",")
913
+		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
914
+		if adminUserInfo.AdminUser.Id != org.Creator {
915
+			for _, item := range role_ids {
916
+				id, _ := strconv.ParseInt(item, 10, 64)
917
+				role, _ := service.GetRoleByRoleID(id)
918
+				if role.IsSystem == 1 && role.RoleName == "子管理员" {
919
+					isSubSuperAdmin = true
920
+				}
921
+			}
922
+		}
923
+	}
924
+	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
889
 	viewModels, _, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
925
 	viewModels, _, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
890
 	if getAdminsErr != nil {
926
 	if getAdminsErr != nil {
891
 		//beego.Error("获取管理员列表失败:", getAdminsErr)
927
 		//beego.Error("获取管理员列表失败:", getAdminsErr)
892
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
928
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
893
 		return
929
 		return
894
 	}
930
 	}
895
-	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
896
 
931
 
897
 	this.ServeSuccessJSON(map[string]interface{}{
932
 	this.ServeSuccessJSON(map[string]interface{}{
898
-		"admins": viewModels,
899
-		"org":    org,
933
+		"admins":          viewModels,
934
+		"org":             org,
935
+		"isSubSuperAdmin": isSubSuperAdmin,
936
+	})
937
+
938
+}
939
+
940
+func (this *RoleAPIController) GetRoleInfo() {
941
+	roleId, _ := this.GetInt64("role_id")
942
+	if roleId <= 0 {
943
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
944
+		return
945
+	}
946
+	role, _ := service.GetRoleByRoleID(roleId)
947
+	this.ServeSuccessJSON(map[string]interface{}{
948
+		"role": role,
900
 	})
949
 	})
901
 
950
 
902
 }
951
 }

+ 19 - 75
controllers/verify_login_controller.go View File

160
 					utils.ErrorLog("字段批量插入失败:%v", err)
160
 					utils.ErrorLog("字段批量插入失败:%v", err)
161
 				}
161
 				}
162
 			}
162
 			}
163
-			//curApp := adminUserInfo.OrgApps[adminUserInfo.CurrentOrgId][adminUserInfo.CurrentAppId]
164
-			//if curApp.OpenStatus != 1 {
165
-			//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNeverCreateTypeApp)
166
-			//	return
167
-			//}
168
-
169
-			//fmt.Println(appRole.RoleIds)
170
-			//
171
-
172
-			//role_arr := strings.Split(appRole.RoleIds, ",")
173
-			//var ids string
174
-			//for _, role_id := range role_arr{
175
-			//	id, _ := strconv.ParseInt(role_id, 10, 64)
176
-			//	purview_ids,_  := service.GetRolePurviewIds(id)
177
-			//	if len(ids) == 0{
178
-			//		ids = purview_ids
179
-			//	}else{
180
-			//		ids = ids +","+purview_ids
181
-			//	}
182
-			//}
183
-			//
184
-			//pruviews ,_ := service.GetPurviewById(ids)
185
-			//
186
-			//var curAppUrlfors []string
187
-			//for _, item :=range pruviews{
188
-			//	curAppUrlfors = append(curAppUrlfors, item.Urlfor)
189
-			//
190
-			//}
191
-
192
-			//var urls []string
193
-			curAppUrlfors := adminUserInfo.AppUrlfors[adminUserInfo.CurrentAppId]
194
 
163
 
164
+			var curAppUrlfors []string
195
 			if len(curAppUrlfors) == 0 {
165
 			if len(curAppUrlfors) == 0 {
196
-				if adminUser.Id == curOrg.Creator {
197
-
166
+				if adminUser.Id == curOrg.Creator { //超级管理员
198
 					urlfors, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(3)
167
 					urlfors, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(3)
199
 					curAppUrlfors = urlfors
168
 					curAppUrlfors = urlfors
200
 
169
 
201
 				} else {
170
 				} else {
202
 					appRole, _ := service.FindAdminUserIDA(appRole.Id)
171
 					appRole, _ := service.FindAdminUserIDA(appRole.Id)
203
-					role_arr := strings.Split(appRole.RoleIds, ",")
204
-					var ids string
205
-					for _, role_id := range role_arr {
206
-						id, _ := strconv.ParseInt(role_id, 10, 64)
207
-						purview_ids, _ := service.GetRolePurviewIds(id)
208
-						if len(ids) == 0 {
209
-							ids = purview_ids
210
-						} else {
211
-							ids = ids + "," + purview_ids
172
+					if appRole.Id > 0 && len(appRole.RoleIds) > 0 {
173
+						role_arr := strings.Split(appRole.RoleIds, ",")
174
+						var ids string
175
+						for _, role_id := range role_arr {
176
+							id, _ := strconv.ParseInt(role_id, 10, 64)
177
+							purview_ids, _ := service.GetRolePurviewIds(id)
178
+							if len(ids) == 0 {
179
+								ids = purview_ids
180
+							} else {
181
+								ids = ids + "," + purview_ids
182
+							}
212
 						}
183
 						}
213
-					}
214
-
215
-					pruviews, _ := service.GetPurviewById(ids)
216
-
217
-					for _, item := range pruviews {
218
-						if item.Module == 3 && item.Parentid > 0 {
219
-							fmt.Println(item.Urlfor)
220
-							curAppUrlfors = append(curAppUrlfors, item.Urlfor)
184
+						pruviews, _ := service.GetPurviewById(ids)
185
+						for _, item := range pruviews {
186
+							if item.Module == 3 && item.Parentid > 0 {
187
+								fmt.Println(item.Urlfor)
188
+								curAppUrlfors = append(curAppUrlfors, item.Urlfor)
189
+							}
221
 						}
190
 						}
222
 					}
191
 					}
223
-
224
 				}
192
 				}
225
-
226
 			}
193
 			}
227
 
194
 
228
-			//subscibe := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
229
-			//fmt.Println("subscibe", subscibe)
230
-			//if err := service.GetOrgSubscibeState(subscibe); err != nil {
231
-			//	this.ErrorLog("没有机构订阅信息,数据有误")
232
-			//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
233
-			//	return
234
-			//}
235
-
236
-			//orgApps := adminUserInfo.OrgApps[curOrg.Id]
237
-			//didRegistedForSCRM := false
238
-			//didRegistedForMall := false
239
-			//didRegistedForCDM := false
240
-			//for _, app := range orgApps {
241
-			//	if app.AppType == 1 && app.OpenStatus == 1 {
242
-			//		didRegistedForSCRM = true
243
-			//	}
244
-			//	if app.AppType == 4 && app.OpenStatus == 1 {
245
-			//		didRegistedForCDM = true
246
-			//	}
247
-			//	if app.AppType == 5 && app.OpenStatus == 1 {
248
-			//		didRegistedForMall = true
249
-			//	}
250
-			//}
251
 			subscibe, _ := service.GetOrgSubscibe(adminUserInfo.CurrentOrgId)
195
 			subscibe, _ := service.GetOrgSubscibe(adminUserInfo.CurrentOrgId)
252
 
196
 
253
 			this.SetSession("admin_user_info", adminUserInfo)
197
 			this.SetSession("admin_user_info", adminUserInfo)

+ 1 - 1
models/vm_models.go View File

304
 	Creator          int64  `gorm:"column:creator" json:"creator" form:"creator"`
304
 	Creator          int64  `gorm:"column:creator" json:"creator" form:"creator"`
305
 	OrgId            int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
305
 	OrgId            int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
306
 	AppId            int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
306
 	AppId            int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
307
-	IsSuperAdmin     int64  `gorm:"column:is_super_admin" json:"is_super_admin" form:"is_super_admin"`
307
+	IsSuperAdmin     bool   `gorm:"column:is_super_admin" json:"is_super_admin" form:"is_super_admin"`
308
 	Status           int64  `gorm:"column:status" json:"status" form:"status"`
308
 	Status           int64  `gorm:"column:status" json:"status" form:"status"`
309
 	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
309
 	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
310
 	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
310
 	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`

+ 1 - 1
routers/router.go View File

12
 func init() {
12
 func init() {
13
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
13
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
14
 		// AllowAllOrigins:  true,
14
 		// AllowAllOrigins:  true,
15
-		AllowOrigins: []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://localhost:9531", "http://xt.test.shengws.com", "http://new_mobile.test.sgjyun.com", "https://xt.test.shengws.com", "http://xt.test.sgjyun.com:9528", "https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://mobile.sgjyun.com", "http://mobile.kuyicloud.com"},
15
+		AllowOrigins: []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://localhost:9531", "http://xt.test.shengws.com", "http://new_mobile.test.sgjyun.com", "https://xt.test.shengws.com", "http://xt.test.sgjyun.com", "https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://mobile.sgjyun.com", "http://mobile.kuyicloud.com"},
16
 		//AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com","http://mobile.sgjyun.com","http://mobile.kuyicloud.com"},
16
 		//AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com","http://mobile.sgjyun.com","http://mobile.kuyicloud.com"},
17
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
17
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
18
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "X-XSRF-TOKEN", "Permission"},
18
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "X-XSRF-TOKEN", "Permission"},

+ 121 - 0
service/app_version.go View File

2
 
2
 
3
 import (
3
 import (
4
 	"XT_New/models"
4
 	"XT_New/models"
5
+	"fmt"
5
 	"github.com/jinzhu/gorm"
6
 	"github.com/jinzhu/gorm"
7
+	"time"
6
 )
8
 )
7
 
9
 
8
 func GetAppVersionByAppType(apptype int64) (*models.AppVersion, error) {
10
 func GetAppVersionByAppType(apptype int64) (*models.AppVersion, error) {
17
 	}
19
 	}
18
 	return &version, nil
20
 	return &version, nil
19
 }
21
 }
22
+
23
+func GetAllAppOrg() ([]*models.OrgApp, error) {
24
+	var app []*models.OrgApp
25
+	err := readUserDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id > 0").Group("org_id").Find(&app).Error
26
+	if err == gorm.ErrRecordNotFound {
27
+		return nil, nil
28
+	}
29
+
30
+	if err != nil {
31
+		return nil, err
32
+	}
33
+	return app, nil
34
+}
35
+
36
+func GetSystemApp() ([]*models.OrgApp, error) {
37
+	var app []*models.OrgApp
38
+	err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0 ").Find(&app).Error
39
+	if err == gorm.ErrRecordNotFound {
40
+		return nil, nil
41
+	}
42
+
43
+	if err != nil {
44
+		return nil, err
45
+	}
46
+	return app, nil
47
+}
48
+
49
+func GetApp() ([]*models.OrgApp, error) {
50
+	var app []*models.OrgApp
51
+	err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0").Find(&app).Error
52
+	if err == gorm.ErrRecordNotFound {
53
+		return nil, nil
54
+	}
55
+
56
+	if err != nil {
57
+		return nil, err
58
+	}
59
+	return app, nil
60
+}
61
+
62
+func GetAppByType(orgID int64, app_type int) (*models.OrgApp, error) {
63
+	var apps models.OrgApp
64
+	err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
65
+	if err != nil {
66
+		return nil, err
67
+	}
68
+	return &apps, nil
69
+}
70
+
71
+func CreateOrgApp(app *models.OrgApp) {
72
+	writeUserDb.Create(&app)
73
+
74
+}
75
+
76
+func GetAllUserRole(org_id int64) (appRole []*models.App_Role) {
77
+	if org_id == 0 {
78
+		readUserDb.Model(&models.App_Role{}).Where("status = 1").Find(&appRole)
79
+
80
+	} else {
81
+		readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? ", org_id).Find(&appRole)
82
+
83
+	}
84
+	return
85
+}
86
+
87
+func GetAllUserRoleByUserTypeOne(org_id int) (appRole []*models.App_Role) {
88
+	fmt.Println("11111")
89
+	app, _ := GetOrgApp(int64(org_id), 3)
90
+	fmt.Println(app)
91
+
92
+	if org_id == 0 {
93
+		readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type = 1  ").Find(&appRole)
94
+
95
+	} else {
96
+		readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ?  AND user_type = 1 AND app_id = ?  ", org_id, app.Id).Find(&appRole)
97
+
98
+	}
99
+	return
100
+}
101
+
102
+func GetAllUserRoleByUserTypeOther(org_id int) (appRole []*models.App_Role) {
103
+	app, _ := GetOrgApp(int64(org_id), 3)
104
+
105
+	if org_id == 0 {
106
+		readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type > 1").Find(&appRole)
107
+
108
+	} else {
109
+		readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ?  AND user_type > 1 AND app_id = ? ", org_id, app.Id).Find(&appRole)
110
+
111
+	}
112
+	return
113
+}
114
+
115
+func FindRoleByUserTypeOne(org_id int64) (role models.Role) {
116
+	readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 2 AND role_name = '医生'", org_id).First(&role)
117
+	return
118
+}
119
+
120
+func FindRoleByUserTypeTwo(org_id int64) (role models.Role) {
121
+	readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 3 AND role_name = '护士'", org_id).First(&role)
122
+	return
123
+}
124
+
125
+func GetAllRole() ([]*models.Role, error) {
126
+	var app []*models.Role
127
+	err := readUserDb.Model(&models.Role{}).Where("status = 1").Group("org_id").Find(&app).Error
128
+	if err == gorm.ErrRecordNotFound {
129
+		return nil, nil
130
+	}
131
+	if err != nil {
132
+		return nil, err
133
+	}
134
+	return app, nil
135
+}
136
+
137
+func UpdateRoleIds(id int64, ids string) {
138
+	writeUserDb.Model(&models.App_Role{}).Where("status = 1 AND id = ?", id).Updates(map[string]interface{}{"role_ids": ids, "mtime": time.Now().Unix()})
139
+
140
+}

+ 2 - 2
service/role_service.go View File

204
 	var roles []*models.Role
204
 	var roles []*models.Role
205
 	err := readUserDb.Model(models.Role{}).
205
 	err := readUserDb.Model(models.Role{}).
206
 		Where("org_id = ? AND app_id = ? AND status = 1", orgID, appID).
206
 		Where("org_id = ? AND app_id = ? AND status = 1", orgID, appID).
207
-		Order("ctime asc").
207
+		Order("number desc,ctime").
208
 		Find(&roles).
208
 		Find(&roles).
209
 		Error
209
 		Error
210
 	if err != nil {
210
 	if err != nil {
592
 	var viewModels []*NewAdminUserModel = make([]*NewAdminUserModel, 0)
592
 	var viewModels []*NewAdminUserModel = make([]*NewAdminUserModel, 0)
593
 	var rows *sql.Rows
593
 	var rows *sql.Rows
594
 	var err error
594
 	var err error
595
-	rows, err = readUserDb.Raw("SELECT u_a_r.id, u_a_r.admin_user_id, u_a_r.user_name,  u_a_r.user_title, u_a_r.status,u_a_r.avatar,u_a_r.role_ids FROM sgj_user_admin_role AS u_a_r  WHERE org_id = ? AND app_id = ? ORDER BY ctime DESC", orgID, appID).Rows()
595
+	rows, err = readUserDb.Raw("SELECT u_a_r.id, u_a_r.admin_user_id, u_a_r.user_name,  u_a_r.user_title, u_a_r.status,u_a_r.avatar,u_a_r.role_ids FROM sgj_user_admin_role AS u_a_r  WHERE org_id = ? AND app_id = ? ORDER BY ctime asc", orgID, appID).Rows()
596
 	defer rows.Close()
596
 	defer rows.Close()
597
 	if err != nil {
597
 	if err != nil {
598
 		if err == gorm.ErrRecordNotFound {
598
 		if err == gorm.ErrRecordNotFound {