Kaynağa Gözat

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

XMLWAN 4 yıl önce
ebeveyn
işleme
b8527d9c91
27 değiştirilmiş dosya ile 934 ekleme ve 439 silme
  1. 1 1
      conf/app.conf
  2. 27 29
      controllers/base_api_controller.go
  3. 1 1
      controllers/dialysis_api_controller.go
  4. 125 123
      controllers/mobile_api_controllers/dialysis_api_controller.go
  5. 17 13
      controllers/mobile_api_controllers/dialysis_api_controller_extend.go
  6. 65 49
      controllers/mobile_api_controllers/mobile_api_base_controller.go
  7. 0 1
      controllers/mobile_api_controllers/mobile_api_router_register.go
  8. 183 162
      controllers/mobile_api_controllers/patient_api_controller.go
  9. 9 9
      controllers/new_mobile_api_controllers/forget_password_controller.go
  10. 51 1
      controllers/new_mobile_api_controllers/home_api_controller.go
  11. 80 2
      controllers/new_mobile_api_controllers/mobile_regist_controller.go
  12. 0 5
      controllers/new_mobile_api_controllers/new_login_api_controller.go
  13. 2 0
      controllers/new_mobile_api_controllers/new_mobile_api_router_register.go
  14. 113 28
      controllers/new_mobile_api_controllers/new_role_api_controller.go
  15. 2 2
      controllers/new_mobile_api_controllers/patient.json
  16. 87 0
      controllers/new_mobile_api_controllers/role.json
  17. 64 7
      controllers/verify_login_controller.go
  18. 2 0
      models/dialysis.go
  19. 2 0
      models/intergration_models.go
  20. 1 2
      models/purview_models.go
  21. 4 0
      models/role_models.go
  22. 21 0
      models/vm_models.go
  23. 2 2
      service/mobile_dialysis_service.go
  24. 2 0
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go
  25. 2 2
      service/role_service.go
  26. 5 0
      service/subscibe_service.go
  27. 66 0
      service/verify_login_token_service.go

+ 1 - 1
conf/app.conf Dosyayı Görüntüle

8
 sessiongcmaxlifetime = 64800
8
 sessiongcmaxlifetime = 64800
9
 
9
 
10
 tokencookiemaxlifetime = 7200
10
 tokencookiemaxlifetime = 7200
11
-mobile_token_expiration_second = 86400
11
+mobile_token_expiration_second = 300
12
 enablexsrf = false
12
 enablexsrf = false
13
 xsrfkey = 61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o
13
 xsrfkey = 61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o
14
 xsrfexpire = 3600
14
 xsrfexpire = 3600

+ 27 - 29
controllers/base_api_controller.go Dosyayı Görüntüle

2
 
2
 
3
 import (
3
 import (
4
 	"XT_New/enums"
4
 	"XT_New/enums"
5
-	"XT_New/models"
6
-	"XT_New/service"
7
 )
5
 )
8
 
6
 
9
 type BaseAPIController struct {
7
 type BaseAPIController struct {
178
 func (this *BaseServeAPIController) Prepare() {
176
 func (this *BaseServeAPIController) Prepare() {
179
 	this.BaseAPIController.Prepare()
177
 	this.BaseAPIController.Prepare()
180
 	if this.GetAdminUserInfo() == nil {
178
 	if this.GetAdminUserInfo() == nil {
181
-		var userAdmin models.AdminUser
182
-		userAdmin.Id = 380
183
-		userAdmin.Mobile = "13532250447"
184
-		userAdmin.IsSuperAdmin = true
185
-		userAdmin.Status = 1
186
-		userAdmin.CreateTime = 1530786071
187
-		userAdmin.ModifyTime = 1530786071
188
-		var subscibe models.ServeSubscibe
189
-		subscibe.ID = 1
190
-		subscibe.OrgId = 4
191
-		subscibe.PeriodStart = 1538035409
192
-		subscibe.PeriodEnd = 1569571409
193
-		subscibe.State = 1
194
-		subscibe.Status = 1
195
-		subscibe.CreatedTime = 1538035409
196
-		subscibe.UpdatedTime = 1538035409
197
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
198
-		subscibes[4] = &subscibe
199
-		var adminUserInfo service.AdminUserInfo
200
-		adminUserInfo.CurrentOrgId = 4
201
-		adminUserInfo.CurrentAppId = 5
202
-		adminUserInfo.AdminUser = &userAdmin
203
-		adminUserInfo.Subscibes = subscibes
204
-		this.SetSession("admin_user_info", &adminUserInfo)
205
-
206
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
207
-		//this.StopRun()
179
+		//var userAdmin models.AdminUser
180
+		//userAdmin.Id = 380
181
+		//userAdmin.Mobile = "13532250447"
182
+		//userAdmin.IsSuperAdmin = true
183
+		//userAdmin.Status = 1
184
+		//userAdmin.CreateTime = 1530786071
185
+		//userAdmin.ModifyTime = 1530786071
186
+		//var subscibe models.ServeSubscibe
187
+		//subscibe.ID = 1
188
+		//subscibe.OrgId = 4
189
+		//subscibe.PeriodStart = 1538035409
190
+		//subscibe.PeriodEnd = 1569571409
191
+		//subscibe.State = 1
192
+		//subscibe.Status = 1
193
+		//subscibe.CreatedTime = 1538035409
194
+		//subscibe.UpdatedTime = 1538035409
195
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
196
+		//subscibes[4] = &subscibe
197
+		//var adminUserInfo service.AdminUserInfo
198
+		//adminUserInfo.CurrentOrgId = 4
199
+		//adminUserInfo.CurrentAppId = 5
200
+		//adminUserInfo.AdminUser = &userAdmin
201
+		//adminUserInfo.Subscibes = subscibes
202
+		//this.SetSession("admin_user_info", &adminUserInfo)
203
+
204
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
205
+		this.StopRun()
208
 	}
206
 	}
209
 }
207
 }
210
 
208
 

+ 1 - 1
controllers/dialysis_api_controller.go Dosyayı Görüntüle

3902
 		}
3902
 		}
3903
 	}
3903
 	}
3904
 
3904
 
3905
-	err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID)
3905
+	err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID, adminInfo.AdminUser.Id)
3906
 	if err != nil {
3906
 	if err != nil {
3907
 		this.ErrorLog("删除透析监测记录失败:%v", err)
3907
 		this.ErrorLog("删除透析监测记录失败:%v", err)
3908
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
3908
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)

+ 125 - 123
controllers/mobile_api_controllers/dialysis_api_controller.go Dosyayı Görüntüle

494
 			"summary": summary,
494
 			"summary": summary,
495
 		})
495
 		})
496
 	} else { //修改
496
 	} else { //修改
497
-		if treatmentSummary.Creater != adminUserInfo.AdminUser.Id {
498
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
499
-			if getPermissionErr != nil {
500
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
501
-				return
502
-			} else if headNursePermission == nil {
503
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
504
-				return
505
-			}
506
-		}
497
+		//if treatmentSummary.Creater != adminUserInfo.AdminUser.Id {
498
+		//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
499
+		//	if getPermissionErr != nil {
500
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
501
+		//		return
502
+		//	} else if headNursePermission == nil {
503
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
504
+		//		return
505
+		//	}
506
+		//}
507
 
507
 
508
 		summary.Creater = treatmentSummary.Creater
508
 		summary.Creater = treatmentSummary.Creater
509
 		summary.CreatedTime = treatmentSummary.CreatedTime
509
 		summary.CreatedTime = treatmentSummary.CreatedTime
707
 		}
707
 		}
708
 
708
 
709
 	} else { //修改
709
 	} else { //修改
710
-		if receiveTreatment.Creater != adminUserInfo.AdminUser.Id {
711
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
712
-			if getPermissionErr != nil {
713
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
714
-				return
715
-			} else if headNursePermission == nil {
716
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
717
-				return
718
-			}
719
-		}
710
+		//if receiveTreatment.Creater != adminUserInfo.AdminUser.Id {
711
+		//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
712
+		//	if getPermissionErr != nil {
713
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
714
+		//		return
715
+		//	} else if headNursePermission == nil {
716
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
717
+		//		return
718
+		//	}
719
+		//}
720
 
720
 
721
 		receiveTreatmentAsses.Creater = receiveTreatment.Creater
721
 		receiveTreatmentAsses.Creater = receiveTreatment.Creater
722
 		receiveTreatmentAsses.CreatedTime = receiveTreatment.CreatedTime
722
 		receiveTreatmentAsses.CreatedTime = receiveTreatment.CreatedTime
872
 		IsEat:                        is_eat,
872
 		IsEat:                        is_eat,
873
 	}
873
 	}
874
 
874
 
875
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
875
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
876
 
876
 
877
 	_, assessmentAfter := service.FindAssessmentAfterDislysisByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
877
 	_, assessmentAfter := service.FindAssessmentAfterDislysisByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
878
 	if assessmentAfter.ID == 0 { //新增
878
 	if assessmentAfter.ID == 0 { //新增
879
-		if appRole.UserType == 2 || appRole.UserType == 1 {
880
-			assessmentAfterDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
881
-			assessmentAfterDislysis.AssessmentTime = time.Now().Unix()
879
+		//if appRole.UserType == 2 || appRole.UserType == 1 {
880
+		assessmentAfterDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
881
+		assessmentAfterDislysis.AssessmentTime = time.Now().Unix()
882
 
882
 
883
-		} else {
884
-			assessmentAfterDislysis.Creater = adminUserInfo.AdminUser.Id
883
+		//} else {
884
+		assessmentAfterDislysis.Creater = adminUserInfo.AdminUser.Id
885
 
885
 
886
-		}
886
+		//}
887
 
887
 
888
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
888
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
889
 		if err == nil {
889
 		if err == nil {
892
 			})
892
 			})
893
 		}
893
 		}
894
 	} else { //修改
894
 	} else { //修改
895
-		if appRole.UserType == 3 {
896
-			if assessmentAfter.Creater != adminUserInfo.AdminUser.Id && assessmentAfter.Creater != 0 {
897
-				headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
898
-				if getPermissionErr != nil {
899
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
900
-					return
901
-				} else if headNursePermission == nil {
902
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
903
-					return
904
-				}
905
-			}
906
-		}
895
+		//if appRole.UserType == 3 {
896
+		//	if assessmentAfter.Creater != adminUserInfo.AdminUser.Id && assessmentAfter.Creater != 0 {
897
+		//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
898
+		//		if getPermissionErr != nil {
899
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
900
+		//			return
901
+		//		} else if headNursePermission == nil {
902
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
903
+		//			return
904
+		//		}
905
+		//	}
906
+		//}
907
 
907
 
908
-		if appRole.UserType == 2 || appRole.UserType == 1 {
909
-			assessmentAfterDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
910
-			assessmentAfterDislysis.AssessmentTime = time.Now().Unix()
911
-		} else {
912
-			assessmentAfterDislysis.Modifier = adminUserInfo.AdminUser.Id
913
-			if assessmentAfterDislysis.Creater == 0 {
914
-				assessmentAfterDislysis.Creater = adminUserInfo.AdminUser.Id
915
-			}
908
+		//TODO 根据角色判断
909
+		//if appRole.UserType == 2 || appRole.UserType == 1 {
910
+		assessmentAfterDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
911
+		assessmentAfterDislysis.AssessmentTime = time.Now().Unix()
912
+		//} else {
913
+		assessmentAfterDislysis.Modifier = adminUserInfo.AdminUser.Id
914
+		if assessmentAfterDislysis.Creater == 0 {
915
+			assessmentAfterDislysis.Creater = adminUserInfo.AdminUser.Id
916
 		}
916
 		}
917
+		//}
917
 
918
 
918
 		assessmentAfterDislysis.CreatedTime = assessmentAfter.CreatedTime
919
 		assessmentAfterDislysis.CreatedTime = assessmentAfter.CreatedTime
919
 		assessmentAfterDislysis.ID = assessmentAfter.ID
920
 		assessmentAfterDislysis.ID = assessmentAfter.ID
1012
 	safe_package, _ := c.GetInt64("package", 0)
1013
 	safe_package, _ := c.GetInt64("package", 0)
1013
 	a_liquid, _ := c.GetInt64("a_liquid", 0)
1014
 	a_liquid, _ := c.GetInt64("a_liquid", 0)
1014
 
1015
 
1015
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1016
-	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
1017
-
1018
-	if template.TemplateId == 2 || template.TemplateId == 6 {
1019
-		if appRole.UserType == 3 {
1020
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1021
-			if getPermissionErr != nil {
1022
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1023
-				return
1024
-			} else if headNursePermission == nil {
1025
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePrescriptionPermissionDeniedModify)
1026
-				return
1027
-			}
1028
-		}
1029
-	}
1030
-
1031
-	if appRole.UserType == 2 || appRole.UserType == 1 {
1032
-		prescription_doctor = appRole.AdminUserId
1033
-	} else {
1034
-		prescription_doctor = 0
1035
-	}
1016
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1017
+	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
1018
+	//
1019
+	//if template.TemplateId == 2 || template.TemplateId == 6 {
1020
+	//	if appRole.UserType == 3 {
1021
+	//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1022
+	//		if getPermissionErr != nil {
1023
+	//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1024
+	//			return
1025
+	//		} else if headNursePermission == nil {
1026
+	//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePrescriptionPermissionDeniedModify)
1027
+	//			return
1028
+	//		}
1029
+	//	}
1030
+	//}
1031
+
1032
+	//TODO 需要根据角色去判断
1033
+	//if appRole.UserType == 2 || appRole.UserType == 1 {
1034
+	//	prescription_doctor = appRole.AdminUserId
1035
+	//} else {
1036
+	//	prescription_doctor = 0
1037
+	//}
1036
 
1038
 
1037
 	prescription := models.DialysisPrescription{
1039
 	prescription := models.DialysisPrescription{
1038
 
1040
 
1120
 		//if mode_id > 0 {
1122
 		//if mode_id > 0 {
1121
 		//	service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
1123
 		//	service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
1122
 		//}
1124
 		//}
1123
-		if template.TemplateId == 1 {
1124
-			if dialysisPrescription.Creater != adminUserInfo.AdminUser.Id && dialysisPrescription.Creater != 0 {
1125
-				headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1126
-				if getPermissionErr != nil {
1127
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1128
-					return
1129
-				} else if headNursePermission == nil {
1130
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePrescriptionPermissionDeniedModify)
1131
-					return
1132
-				}
1133
-			}
1134
-		}
1125
+		//if template.TemplateId == 1 {
1126
+		//	if dialysisPrescription.Creater != adminUserInfo.AdminUser.Id && dialysisPrescription.Creater != 0 {
1127
+		//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1128
+		//		if getPermissionErr != nil {
1129
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1130
+		//			return
1131
+		//		} else if headNursePermission == nil {
1132
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePrescriptionPermissionDeniedModify)
1133
+		//			return
1134
+		//		}
1135
+		//	}
1136
+		//}
1135
 
1137
 
1136
 		_, record := service.FindAutomaticReduceRecordByOrgId(adminUserInfo.Org.Id)
1138
 		_, record := service.FindAutomaticReduceRecordByOrgId(adminUserInfo.Org.Id)
1137
 		if record.IsOpen == 1 {
1139
 		if record.IsOpen == 1 {
4136
 		service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
4138
 		service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
4137
 	}
4139
 	}
4138
 
4140
 
4139
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
4140
-
4141
-	if appRole.UserType == 2 || appRole.UserType == 1 {
4142
-		prescription_doctor = appRole.AdminUserId
4143
-	} else {
4144
-		prescription_doctor = 0
4145
-	}
4146
-
4147
-	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
4148
-
4149
-	if template.TemplateId == 2 || template.TemplateId == 6 {
4150
-		if appRole.UserType == 3 {
4151
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
4152
-			if getPermissionErr != nil {
4153
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4154
-				return
4155
-			} else if headNursePermission == nil {
4156
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
4157
-				return
4158
-			}
4159
-		}
4160
-	}
4141
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
4142
+	//
4143
+	//if appRole.UserType == 2 || appRole.UserType == 1 {
4144
+	//	prescription_doctor = appRole.AdminUserId
4145
+	//} else {
4146
+	//	prescription_doctor = 0
4147
+	//}
4148
+
4149
+	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
4150
+	//
4151
+	//if template.TemplateId == 2 || template.TemplateId == 6 {
4152
+	//	if appRole.UserType == 3 {
4153
+	//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
4154
+	//		if getPermissionErr != nil {
4155
+	//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4156
+	//			return
4157
+	//		} else if headNursePermission == nil {
4158
+	//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
4159
+	//			return
4160
+	//		}
4161
+	//	}
4162
+	//}
4161
 
4163
 
4162
 	prescription := models.DialysisPrescription{
4164
 	prescription := models.DialysisPrescription{
4163
 
4165
 
5576
 	}
5578
 	}
5577
 
5579
 
5578
 	_, tempDialysisRecord := service.FindDialysisOrderById(record_id)
5580
 	_, tempDialysisRecord := service.FindDialysisOrderById(record_id)
5579
-
5580
-	if tempDialysisRecord.Creator != adminUserInfo.AdminUser.Id {
5581
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
5582
-		if getPermissionErr != nil {
5583
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5584
-			return
5585
-		} else if headNursePermission == nil {
5586
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
5587
-			return
5588
-		}
5589
-	}
5581
+	//
5582
+	//if tempDialysisRecord.Creator != adminUserInfo.AdminUser.Id {
5583
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
5584
+	//	if getPermissionErr != nil {
5585
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5586
+	//		return
5587
+	//	} else if headNursePermission == nil {
5588
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
5589
+	//		return
5590
+	//	}
5591
+	//}
5590
 
5592
 
5591
 	scheduleDateStart := startDate.Format("2006-01-02") + " 00:00:00"
5593
 	scheduleDateStart := startDate.Format("2006-01-02") + " 00:00:00"
5592
 	scheduleDateEnd := startDate.Format("2006-01-02") + " 23:59:59"
5594
 	scheduleDateEnd := startDate.Format("2006-01-02") + " 23:59:59"
5715
 	}
5717
 	}
5716
 	_, tempDialysisRecords := service.FindDialysisOrderById(record_id)
5718
 	_, tempDialysisRecords := service.FindDialysisOrderById(record_id)
5717
 
5719
 
5718
-	if tempDialysisRecords.FinishCreator != adminUserInfo.AdminUser.Id {
5719
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
5720
-		if getPermissionErr != nil {
5721
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5722
-			return
5723
-		} else if headNursePermission == nil {
5724
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
5725
-			return
5726
-		}
5727
-	}
5720
+	//if tempDialysisRecords.FinishCreator != adminUserInfo.AdminUser.Id {
5721
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
5722
+	//	if getPermissionErr != nil {
5723
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5724
+	//		return
5725
+	//	} else if headNursePermission == nil {
5726
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
5727
+	//		return
5728
+	//	}
5729
+	//}
5728
 
5730
 
5729
 	dialysisRecord := &models.DialysisOrder{
5731
 	dialysisRecord := &models.DialysisOrder{
5730
 		ID:             record_id,
5732
 		ID:             record_id,

+ 17 - 13
controllers/mobile_api_controllers/dialysis_api_controller_extend.go Dosyayı Görüntüle

134
 		Conductivity:              conductivity,
134
 		Conductivity:              conductivity,
135
 		DisplacementFlowQuantity:  displacement_flow_quantity,
135
 		DisplacementFlowQuantity:  displacement_flow_quantity,
136
 		BloodOxygenSaturation:     blood_oxygen_saturation,
136
 		BloodOxygenSaturation:     blood_oxygen_saturation,
137
+		Creator:                   adminInfo.AdminUser.Id,
138
+		Modify:                    0,
137
 	}
139
 	}
138
 
140
 
139
 	err := service.CreateMonitor(&record)
141
 	err := service.CreateMonitor(&record)
276
 	monitor.UpdatedTime = time.Now().Unix()
278
 	monitor.UpdatedTime = time.Now().Unix()
277
 	monitor.DisplacementFlowQuantity = displacement_flow_quantity
279
 	monitor.DisplacementFlowQuantity = displacement_flow_quantity
278
 	monitor.BloodOxygenSaturation = blood_oxygen_saturation
280
 	monitor.BloodOxygenSaturation = blood_oxygen_saturation
281
+	monitor.Modify = adminInfo.AdminUser.Id
282
+
279
 	err = service.UpdateMonitor(monitor)
283
 	err = service.UpdateMonitor(monitor)
280
 	if err != nil {
284
 	if err != nil {
281
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorUpdate)
285
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorUpdate)
313
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
317
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
314
 		return
318
 		return
315
 	}
319
 	}
316
-	if monitor != nil {
317
-		if monitor.MonitoringNurse != adminInfo.AdminUser.Id {
318
-			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminInfo.Org.Id, adminInfo.App.Id, adminInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
319
-			if getPermissionErr != nil {
320
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
321
-				return
322
-			} else if headNursePermission == nil {
323
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
324
-				return
325
-			}
326
-		}
327
-	}
320
+	//if monitor != nil {
321
+	//	if monitor.MonitoringNurse != adminInfo.AdminUser.Id {
322
+	//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminInfo.Org.Id, adminInfo.App.Id, adminInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
323
+	//		if getPermissionErr != nil {
324
+	//			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
325
+	//			return
326
+	//		} else if headNursePermission == nil {
327
+	//			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
328
+	//			return
329
+	//		}
330
+	//	}
331
+	//}
328
 
332
 
329
-	err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID)
333
+	err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID, adminInfo.AdminUser.Id)
330
 	if err != nil {
334
 	if err != nil {
331
 		this.ErrorLog("删除透析监测记录失败:%v", err)
335
 		this.ErrorLog("删除透析监测记录失败:%v", err)
332
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
336
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)

+ 65 - 49
controllers/mobile_api_controllers/mobile_api_base_controller.go Dosyayı Görüntüle

46
 }
46
 }
47
 
47
 
48
 func (this *MobileBaseAPIAuthController) Prepare() {
48
 func (this *MobileBaseAPIAuthController) Prepare() {
49
+	token := this.Ctx.GetCookie("token_cookie")
50
+	//if len(token) == 0{
51
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
52
+	//	this.StopRun()
53
+	//}
49
 	this.MobileBaseAPIController.Prepare()
54
 	this.MobileBaseAPIController.Prepare()
50
-
51
 	adminUserInfo := this.GetMobileAdminUserInfo()
55
 	adminUserInfo := this.GetMobileAdminUserInfo()
52
-	fmt.Println(adminUserInfo)
53
 
56
 
54
-	if adminUserInfo == nil {
57
+	if adminUserInfo == nil || len(token) == 0 {
55
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
58
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
56
 		this.StopRun()
59
 		this.StopRun()
57
 	}
60
 	}
63
 	//		this.StopRun()
66
 	//		this.StopRun()
64
 	//	}
67
 	//	}
65
 	//}
68
 	//}
66
-
67
-	if this.Ctx.Request.Header.Get("Permission") == "1" {
68
-		isPermission := false
69
-		adminUserInfo := this.GetMobileAdminUserInfo()
70
-		//该机构下该用户有多少个
71
-		role, _ := service.GetUserAllRole(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id)
72
-		var roles []string
73
-		if len(role.RoleIds) <= 0 { //该用户没有设置角色
74
-
75
-		} else {
76
-			roles = strings.Split(role.RoleIds, ",")
77
-		}
78
-
79
-		//获取该用户下所有角色的权限总集
80
-		var userRolePurviews string
81
-		var userRolePurviewsArr []string
82
-		for _, item := range roles {
83
-			role_id, _ := strconv.ParseInt(item, 10, 64)
84
-			purviews, _ := service.GetRoleFuncPurviewIds(role_id)
85
-			userRolePurviews = userRolePurviews + purviews
86
-		}
87
-		//该用户所拥有角色的权限的总集
88
-		userRolePurviewsArr = RemoveRepeatedPurviewElement(strings.Split(userRolePurviews, ","))
89
-		//系统所记录的权限列表
90
-		allPermission, _ := service.GetAllFunctionPurview()
91
-
92
-		//fmt.Println(this.Ctx.Request.RequestURI[1])
93
-
94
-		for _, item := range allPermission {
95
-			//判断当前路由是否在权限路由列表里面
96
-			if strings.Split(item.Urlfor, ",")[0] == strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode") {
97
-				//获取该角色的所有权限
98
-				for _, items := range userRolePurviewsArr {
99
-					id, _ := strconv.ParseInt(items, 10, 64)
100
-					if id == item.ID {
101
-						isPermission = true
102
-					}
69
+	if !adminUserInfo.AdminUser.IsSuperAdmin || adminUserInfo.AdminUser.Id != adminUserInfo.Org.Creator {
70
+
71
+		if this.Ctx.Request.Header.Get("Permission") == "1" {
72
+			isPermission := false
73
+			adminUserInfo := this.GetMobileAdminUserInfo()
74
+			//该机构下该用户有多少个
75
+			role, _ := service.GetUserAllRole(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id)
76
+			var roles []string
77
+			if len(role.RoleIds) <= 0 { //该用户没有设置角色
78
+
79
+			} else {
80
+				roles = strings.Split(role.RoleIds, ",")
81
+			}
82
+			fmt.Println(roles)
83
+
84
+			//获取该用户下所有角色的权限总集
85
+			var userRolePurviews string
86
+			var userRolePurviewsArr []string
87
+			for _, item := range roles {
88
+				role_id, _ := strconv.ParseInt(item, 10, 64)
89
+				purviews, _ := service.GetRoleFuncPurviewIds(role_id)
90
+				if len(userRolePurviews) == 0 {
91
+					userRolePurviews = purviews
92
+				} else {
93
+					userRolePurviews = userRolePurviews + "," + purviews
103
 				}
94
 				}
104
-				if !isPermission {
105
-					msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
106
-					json := make(map[string]interface{})
107
-					json["msg"] = msg
108
-					json["code"] = 0
109
-					json["state"] = 0
110
-					this.Data["json"] = json
111
-					this.ServeJSON()
112
-					this.StopRun()
95
+			}
96
+			//该用户所拥有角色的权限的总集
97
+			userRolePurviewsArr = RemoveRepeatedPurviewElement(strings.Split(userRolePurviews, ","))
98
+			fmt.Println(userRolePurviewsArr)
99
+			//系统所记录的权限列表
100
+			allPermission, _ := service.GetAllFunctionPurview()
101
+
102
+			for _, item := range allPermission {
103
+				fmt.Println(strings.Split(item.Urlfor, ",")[0])
104
+				fmt.Println(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
105
+
106
+				//判断当前路由是否在权限路由列表里面
107
+				if strings.Split(item.Urlfor, ",")[0] == strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode") {
108
+
109
+					//获取该角色的所有权限
110
+					for _, items := range userRolePurviewsArr {
111
+						id, _ := strconv.ParseInt(items, 10, 64)
112
+						fmt.Println(id)
113
+						fmt.Println(item.ID)
114
+
115
+						if id == item.ID {
116
+							isPermission = true
117
+						}
118
+					}
119
+					if !isPermission {
120
+						msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
121
+						json := make(map[string]interface{})
122
+						json["msg"] = msg
123
+						json["code"] = 0
124
+						json["state"] = 0
125
+						this.Data["json"] = json
126
+						this.ServeJSON()
127
+						this.StopRun()
128
+					}
113
 				}
129
 				}
114
 			}
130
 			}
115
 		}
131
 		}

+ 0 - 1
controllers/mobile_api_controllers/mobile_api_router_register.go Dosyayı Görüntüle

39
 	beego.Router("/m/api/advice/stop", &PatientApiController{}, "Post:StopDoctorAdvice")
39
 	beego.Router("/m/api/advice/stop", &PatientApiController{}, "Post:StopDoctorAdvice")
40
 	beego.Router("/m/api/advice/creategroup", &PatientApiController{}, "Post:CreateGroupAdvice")
40
 	beego.Router("/m/api/advice/creategroup", &PatientApiController{}, "Post:CreateGroupAdvice")
41
 	beego.Router("/m/api/advice/group/modify_starttime", &PatientApiController{}, "Post:ModifyAdviceGroupStartTime")
41
 	beego.Router("/m/api/advice/group/modify_starttime", &PatientApiController{}, "Post:ModifyAdviceGroupStartTime")
42
-
43
 	beego.Router("/m/api/advice/delete", &PatientApiController{}, "Delete:DeleteDoctorAdvice")
42
 	beego.Router("/m/api/advice/delete", &PatientApiController{}, "Delete:DeleteDoctorAdvice")
44
 	beego.Router("/m/api/advice/exec", &PatientApiController{}, "Post:ExecDoctorAdvice")
43
 	beego.Router("/m/api/advice/exec", &PatientApiController{}, "Post:ExecDoctorAdvice")
45
 	beego.Router("/m/api/advice/exec/modify", &PatientApiController{}, "Post:ModifyExecDoctorAdvice")
44
 	beego.Router("/m/api/advice/exec/modify", &PatientApiController{}, "Post:ModifyExecDoctorAdvice")

+ 183 - 162
controllers/mobile_api_controllers/patient_api_controller.go Dosyayı Görüntüle

183
 	//	return
183
 	//	return
184
 	//}
184
 	//}
185
 
185
 
186
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
187
-
188
-	if appRole.UserType == 3 {
189
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
190
-		if getPermissionErr != nil {
191
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
192
-			return
193
-		} else if headNursePermission == nil {
194
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
195
-			return
196
-		}
197
-	}
186
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
187
+	//
188
+	//if appRole.UserType == 3 {
189
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
190
+	//	if getPermissionErr != nil {
191
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
192
+	//		return
193
+	//	} else if headNursePermission == nil {
194
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
195
+	//		return
196
+	//	}
197
+	//}
198
 
198
 
199
 	var advice models.DoctorAdvice
199
 	var advice models.DoctorAdvice
200
 	code := adviceFormData(&advice, c.Ctx.Input.RequestBody, "create")
200
 	code := adviceFormData(&advice, c.Ctx.Input.RequestBody, "create")
259
 
259
 
260
 	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
260
 	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
261
 
261
 
262
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
263
-
264
-	if appRole.UserType == 3 {
265
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
266
-		if getPermissionErr != nil {
267
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
268
-			return
269
-		} else if headNursePermission == nil {
270
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
271
-			return
272
-		}
273
-	}
262
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
263
+	//
264
+	//if appRole.UserType == 3 {
265
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
266
+	//	if getPermissionErr != nil {
267
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
268
+	//		return
269
+	//	} else if headNursePermission == nil {
270
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
271
+	//		return
272
+	//	}
273
+	//}
274
 
274
 
275
 	advice, _ := service.FindDoctorAdvice(adminUserInfo.Org.Id, id)
275
 	advice, _ := service.FindDoctorAdvice(adminUserInfo.Org.Id, id)
276
 	if advice.ID == 0 {
276
 	if advice.ID == 0 {
278
 		return
278
 		return
279
 	}
279
 	}
280
 
280
 
281
-	if advice.AdviceDoctor != adminUserInfo.AdminUser.Id {
282
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCanotEditOtherAdvice)
283
-		return
284
-	}
285
-
286
 	code := adviceFormData(&advice, c.Ctx.Input.RequestBody, "update")
281
 	code := adviceFormData(&advice, c.Ctx.Input.RequestBody, "update")
287
 	if code > 0 {
282
 	if code > 0 {
288
 		c.ServeFailJSONWithSGJErrorCode(code)
283
 		c.ServeFailJSONWithSGJErrorCode(code)
381
 	//	return
376
 	//	return
382
 	//}
377
 	//}
383
 
378
 
384
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
385
-
386
-	if appRole.UserType == 3 {
387
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
388
-		if getPermissionErr != nil {
389
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
390
-			return
391
-		} else if headNursePermission == nil {
392
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
393
-			return
394
-		}
395
-	}
379
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
380
+	//
381
+	//if appRole.UserType == 3 {
382
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
383
+	//	if getPermissionErr != nil {
384
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
385
+	//		return
386
+	//	} else if headNursePermission == nil {
387
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
388
+	//		return
389
+	//	}
390
+	//}
396
 
391
 
397
 	if advice.StopState == 1 {
392
 	if advice.StopState == 1 {
398
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceStoped)
393
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceStoped)
480
 	//	return
475
 	//	return
481
 	//}
476
 	//}
482
 
477
 
483
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
484
-
485
-	if appRole.UserType == 3 {
486
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
487
-		if getPermissionErr != nil {
488
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
489
-			return
490
-		} else if headNursePermission == nil {
491
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
492
-			return
493
-		}
494
-	}
478
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
479
+	//
480
+	//if appRole.UserType == 3 {
481
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
482
+	//	if getPermissionErr != nil {
483
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
484
+	//		return
485
+	//	} else if headNursePermission == nil {
486
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
487
+	//		return
488
+	//	}
489
+	//}
495
 
490
 
496
 	advice.UpdatedTime = time.Now().Unix()
491
 	advice.UpdatedTime = time.Now().Unix()
497
 	advice.Status = 0
492
 	advice.Status = 0
540
 
535
 
541
 	adminUserInfo := c.GetMobileAdminUserInfo()
536
 	adminUserInfo := c.GetMobileAdminUserInfo()
542
 
537
 
543
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
544
-
545
-	if appRole.UserType == 2 || appRole.UserType == 1 {
546
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
547
-		if getPermissionErr != nil {
548
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
549
-			return
550
-		} else if headNursePermission == nil {
551
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
552
-			return
553
-		}
554
-	}
538
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
539
+	//
540
+	//if appRole.UserType == 2 || appRole.UserType == 1 {
541
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
542
+	//	if getPermissionErr != nil {
543
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
544
+	//		return
545
+	//	} else if headNursePermission == nil {
546
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
547
+	//		return
548
+	//	}
549
+	//}
555
 
550
 
556
 	var advice models.DoctorAdvice
551
 	var advice models.DoctorAdvice
557
 
552
 
673
 		}
668
 		}
674
 	}
669
 	}
675
 
670
 
676
-	if advice.ExecutionStaff != adminUserInfo.AdminUser.Id {
677
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
678
-		if getPermissionErr != nil {
679
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
680
-			return
681
-		} else if headNursePermission == nil {
682
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
683
-			return
684
-		}
685
-	}
671
+	//if advice.ExecutionStaff != adminUserInfo.AdminUser.Id {
672
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
673
+	//	if getPermissionErr != nil {
674
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
675
+	//		return
676
+	//	} else if headNursePermission == nil {
677
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
678
+	//		return
679
+	//	}
680
+	//}
686
 
681
 
687
 	if advice.StartTime > theTime.Unix() {
682
 	if advice.StartTime > theTime.Unix() {
688
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
683
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
732
 	}
727
 	}
733
 
728
 
734
 	adminUserInfo := c.GetMobileAdminUserInfo()
729
 	adminUserInfo := c.GetMobileAdminUserInfo()
735
-
736
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
737
-	if appRole.UserType != 3 {
738
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
739
-		if getPermissionErr != nil {
740
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
741
-			return
742
-		} else if headNursePermission == nil {
743
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
744
-			return
745
-		}
746
-	}
730
+	//
731
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
732
+	//if appRole.UserType != 3 {
733
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
734
+	//	if getPermissionErr != nil {
735
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
736
+	//		return
737
+	//	} else if headNursePermission == nil {
738
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
739
+	//		return
740
+	//	}
741
+	//}
747
 
742
 
748
 	var advice models.DoctorAdvice
743
 	var advice models.DoctorAdvice
749
 
744
 
848
 		return
843
 		return
849
 	}
844
 	}
850
 	//templateInfo,_ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
845
 	//templateInfo,_ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
851
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
846
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
852
 	var evaluation models.PredialysisEvaluation
847
 	var evaluation models.PredialysisEvaluation
853
 	if theEvaluation != nil {
848
 	if theEvaluation != nil {
854
-		if appRole.UserType == 2 || appRole.UserType == 1 {
855
-
856
-			evaluation = *theEvaluation
857
-
858
-		} else {
859
-			if theEvaluation.Creater != adminUserInfo.AdminUser.Id && theEvaluation.Creater != 0 {
860
-				headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
861
-				if getPermissionErr != nil {
862
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
863
-					return
864
-				} else if headNursePermission == nil {
865
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
866
-					return
867
-				}
868
-			} else {
869
-				evaluation = *theEvaluation
870
-			}
871
-		}
849
+		//if appRole.UserType == 2 || appRole.UserType == 1 {
850
+
851
+		evaluation = *theEvaluation
852
+
853
+		//} else {
854
+		//	if theEvaluation.Creater != adminUserInfo.AdminUser.Id && theEvaluation.Creater != 0 {
855
+		//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
856
+		//		if getPermissionErr != nil {
857
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
858
+		//			return
859
+		//		} else if headNursePermission == nil {
860
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
861
+		//			return
862
+		//		}
863
+		//	} else {
864
+		//		evaluation = *theEvaluation
865
+		//	}
866
+		//}
872
 	}
867
 	}
873
 
868
 
874
 	code := predialysisEvaluationFormData(&evaluation, c.Ctx.Input.RequestBody)
869
 	code := predialysisEvaluationFormData(&evaluation, c.Ctx.Input.RequestBody)
884
 		evaluation.AssessmentDate = theAssessmentDateTime
879
 		evaluation.AssessmentDate = theAssessmentDateTime
885
 		evaluation.PatientId = id
880
 		evaluation.PatientId = id
886
 		evaluation.UserOrgId = adminUserInfo.Org.Id
881
 		evaluation.UserOrgId = adminUserInfo.Org.Id
887
-		if appRole.UserType == 2 || appRole.UserType == 1 {
888
-			evaluation.AssessmentDoctor = adminUserInfo.AdminUser.Id
889
-			evaluation.AssessmentTime = time.Now().Unix()
890
-		} else {
891
-			evaluation.Creater = adminUserInfo.AdminUser.Id
892
-		}
882
+		//if appRole.UserType == 2 || appRole.UserType == 1 {
883
+		//	evaluation.AssessmentDoctor = adminUserInfo.AdminUser.Id
884
+		//	evaluation.AssessmentTime = time.Now().Unix()
885
+		//} else {
886
+		evaluation.Creater = adminUserInfo.AdminUser.Id
887
+		//}
893
 	} else {
888
 	} else {
894
 		evaluation.UpdatedTime = time.Now().Unix()
889
 		evaluation.UpdatedTime = time.Now().Unix()
895
 		evaluation.Evaluator = adminUserInfo.AdminUser.Id
890
 		evaluation.Evaluator = adminUserInfo.AdminUser.Id
896
-		if appRole.UserType == 2 || appRole.UserType == 1 {
897
-			evaluation.AssessmentDoctor = adminUserInfo.AdminUser.Id
898
-			evaluation.AssessmentTime = time.Now().Unix()
899
-		} else {
900
-			evaluation.Modifier = adminUserInfo.AdminUser.Id
901
-			if evaluation.Creater == 0 {
902
-				evaluation.Creater = adminUserInfo.AdminUser.Id
903
-			}
891
+		//if appRole.UserType == 2 || appRole.UserType == 1 {
892
+		//	evaluation.AssessmentDoctor = adminUserInfo.AdminUser.Id
893
+		//	evaluation.AssessmentTime = time.Now().Unix()
894
+		//} else {
895
+		evaluation.Modifier = adminUserInfo.AdminUser.Id
896
+		if evaluation.Creater == 0 {
897
+			evaluation.Creater = adminUserInfo.AdminUser.Id
904
 		}
898
 		}
899
+		//}
905
 	}
900
 	}
906
 
901
 
907
 	//新增逻辑
902
 	//新增逻辑
2439
 
2434
 
2440
 func (c *PatientApiController) DelDoctorAdvice() {
2435
 func (c *PatientApiController) DelDoctorAdvice() {
2441
 	groupno, _ := c.GetInt64("groupno", -1)
2436
 	groupno, _ := c.GetInt64("groupno", -1)
2437
+	is_sub, _ := c.GetInt64("is_sub", -1) //是否子药
2442
 
2438
 
2443
-	var ids []string
2444
-	if groupno == 0 {
2445
-		advice_id := c.GetString("advice_id")
2446
-		ids = strings.Split(advice_id, ",")
2447
-		if len(ids) <= 0 {
2448
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2449
-			return
2450
-		}
2451
-	}
2452
-	if groupno < 0 {
2453
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2454
-		return
2455
-	}
2456
-
2457
-	adminUserInfo := c.GetMobileAdminUserInfo()
2439
+	if is_sub == 1 { //是
2458
 
2440
 
2459
-	var advice models.DoctorAdvice
2460
-
2461
-	if groupno > 0 {
2462
-		advice, _ = service.FindDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
2441
+		advice_id, _ := c.GetInt64("advice_id")
2442
+		adminUserInfo := c.GetMobileAdminUserInfo()
2443
+		advice, _ := service.FindOldDoctorAdvice(adminUserInfo.Org.Id, advice_id)
2463
 		if advice.ID == 0 {
2444
 		if advice.ID == 0 {
2464
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
2445
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
2465
 			return
2446
 			return
2468
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2449
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2469
 			return
2450
 			return
2470
 		}
2451
 		}
2471
-	} else {
2472
-		advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
2473
-		for _, item := range advices {
2474
-			if item.ID == 0 {
2475
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
2452
+
2453
+		advice.Status = 0
2454
+		advice.UpdatedTime = time.Now().Unix()
2455
+		advice.Modifier = adminUserInfo.AdminUser.Id
2456
+
2457
+		err := service.DeleteDoctorAdvice(&advice)
2458
+		if err != nil {
2459
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
2460
+			return
2461
+		}
2462
+
2463
+		c.ServeSuccessJSON(map[string]interface{}{
2464
+			"msg": "ok",
2465
+		})
2466
+
2467
+		return
2468
+
2469
+	} else { //
2470
+
2471
+		var ids []string
2472
+		if groupno == 0 {
2473
+			advice_id := c.GetString("advice_id")
2474
+			ids = strings.Split(advice_id, ",")
2475
+			if len(ids) <= 0 {
2476
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2476
 				return
2477
 				return
2477
 			}
2478
 			}
2478
-			if !adminUserInfo.AdminUser.IsSuperAdmin && item.AdviceDoctor != adminUserInfo.AdminUser.Id {
2479
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
2479
+		}
2480
+		if groupno < 0 {
2481
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2482
+			return
2483
+		}
2484
+
2485
+		adminUserInfo := c.GetMobileAdminUserInfo()
2486
+		var advice models.DoctorAdvice
2487
+		if groupno > 0 {
2488
+			advice, _ = service.FindDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
2489
+			if advice.ID == 0 {
2490
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
2480
 				return
2491
 				return
2481
 			}
2492
 			}
2493
+		} else {
2494
+			advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
2495
+			for _, item := range advices {
2496
+				if item.ID == 0 {
2497
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
2498
+					return
2499
+				}
2500
+			}
2482
 		}
2501
 		}
2483
-	}
2484
 
2502
 
2485
-	advice.UpdatedTime = time.Now().Unix()
2486
-	advice.Status = 0
2487
-	advice.GroupNo = groupno
2503
+		advice.UpdatedTime = time.Now().Unix()
2504
+		advice.Status = 0
2505
+		advice.GroupNo = groupno
2488
 
2506
 
2489
-	var err error
2490
-	if groupno > 0 {
2491
-		err = service.DeleteDoctorAdviceByGroupNo(&advice)
2492
-	} else {
2493
-		err = service.BatchDeleteDoctorAdvice(ids)
2494
-	}
2507
+		var err error
2508
+		if groupno > 0 {
2509
+			err = service.DeleteDoctorAdviceByGroupNo(&advice)
2510
+		} else {
2511
+			err = service.BatchDeleteDoctorAdvice(ids)
2512
+		}
2495
 
2513
 
2496
-	if err != nil {
2497
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
2514
+		if err != nil {
2515
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
2516
+			return
2517
+		}
2518
+
2519
+		c.ServeSuccessJSON(map[string]interface{}{
2520
+			"msg": "ok",
2521
+		})
2498
 		return
2522
 		return
2523
+
2499
 	}
2524
 	}
2500
 
2525
 
2501
-	c.ServeSuccessJSON(map[string]interface{}{
2502
-		"msg": "ok",
2503
-	})
2504
-	return
2505
 }
2526
 }
2506
 
2527
 
2507
 // /m/api/advice/group/modify_starttime [post]
2528
 // /m/api/advice/group/modify_starttime [post]

+ 9 - 9
controllers/new_mobile_api_controllers/forget_password_controller.go Dosyayı Görüntüle

20
 
20
 
21
 func (this *ForgetPwdController) ModifyPassword() {
21
 func (this *ForgetPwdController) ModifyPassword() {
22
 	mobile := this.GetString("mobile")
22
 	mobile := this.GetString("mobile")
23
-	//code := this.GetString("code")
23
+	code := this.GetString("code")
24
 	password := this.GetString("password")
24
 	password := this.GetString("password")
25
-	//checkErr := this.checkParams(mobile, code, password)
26
-	//if checkErr != nil {
27
-	//	this.ServeFailJSONWithSGJErrorCode(checkErr.Code)
28
-	//	return
29
-	//}
25
+	checkErr := this.checkParams(mobile, code, password)
26
+	if checkErr != nil {
27
+		this.ServeFailJSONWithSGJErrorCode(checkErr.Code)
28
+		return
29
+	}
30
 
30
 
31
 	adminUser, _ := service.GetValidAdminUserByMobileReturnErr(mobile)
31
 	adminUser, _ := service.GetValidAdminUserByMobileReturnErr(mobile)
32
 
32
 
37
 		return
37
 		return
38
 	} else {
38
 	} else {
39
 		// 修改成功后验证码就要使其失效
39
 		// 修改成功后验证码就要使其失效
40
-		//redisClient := service.RedisClient()
41
-		//defer redisClient.Close()
42
-		//redisClient.Del("code_msg_" + mobile)
40
+		redisClient := service.RedisClient()
41
+		defer redisClient.Close()
42
+		redisClient.Del("code_msg_" + mobile)
43
 
43
 
44
 		ip := utils.GetIP(this.Ctx.Request)
44
 		ip := utils.GetIP(this.Ctx.Request)
45
 		ssoDomain := beego.AppConfig.String("sso_domain")
45
 		ssoDomain := beego.AppConfig.String("sso_domain")

+ 51 - 1
controllers/new_mobile_api_controllers/home_api_controller.go Dosyayı Görüntüle

350
 		//初始化医嘱模版
350
 		//初始化医嘱模版
351
 		InitAdviceTemplate(org)
351
 		InitAdviceTemplate(org)
352
 		//初始化角色和权限
352
 		//初始化角色和权限
353
-
353
+		InitRoleAndPurviews(org)
354
 		//初始化设备管理
354
 		//初始化设备管理
355
+		InitEquitMentInformation(org)
355
 
356
 
356
 		//初始化显示配置
357
 		//初始化显示配置
357
 
358
 
523
 	}
524
 	}
524
 
525
 
525
 }
526
 }
527
+
528
+func (this *HomeController) ModifyPsw() {
529
+	mobile := this.GetString("mobile")
530
+	code := this.GetString("code")
531
+	password := this.GetString("password")
532
+	checkErr := this.checkParam(mobile, code, password)
533
+	if checkErr != nil {
534
+		this.ServeFailJSONWithSGJErrorCode(checkErr.Code)
535
+		return
536
+	}
537
+	adminUser, _ := service.GetValidAdminUserByMobileReturnErr(mobile)
538
+	modifyErr := service.ModifyPassword(adminUser.Id, password)
539
+	if modifyErr != nil {
540
+		utils.ErrorLog("修改mobile=%v的用户的密码时失败: %v", mobile, modifyErr)
541
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
542
+		return
543
+	} else {
544
+		// 修改成功后验证码就要使其失效
545
+		redisClient := service.RedisClient()
546
+		defer redisClient.Close()
547
+		redisClient.Del("code_msg_" + mobile)
548
+		this.ServeSuccessJSON(map[string]interface{}{
549
+			"admin": adminUser,
550
+		})
551
+		return
552
+	}
553
+}
554
+
555
+func (this *HomeController) checkParam(mobile string, code string, password string) *enums.SGJError {
556
+	if utils.CellPhoneRegexp().MatchString(mobile) == false {
557
+		return &enums.SGJError{Code: enums.ErrorCodeMobileFormat}
558
+	}
559
+	if len(code) == 0 {
560
+		return &enums.SGJError{Code: enums.ErrorCodeVerificationCodeWrong}
561
+	}
562
+	if len(password) == 0 {
563
+		return &enums.SGJError{Code: enums.ErrorCodePasswordEmpty}
564
+	}
565
+	if service.IsMobileRegister(mobile) == false {
566
+		return &enums.SGJError{Code: enums.ErrorCodeMobileNotExit}
567
+	}
568
+	redisClient := service.RedisClient()
569
+	defer redisClient.Close()
570
+	cache_code, _ := redisClient.Get("code_msg_" + mobile).Result()
571
+	if cache_code != code {
572
+		return &enums.SGJError{Code: enums.ErrorCodeVerificationCodeWrong}
573
+	}
574
+	return nil
575
+}

+ 80 - 2
controllers/new_mobile_api_controllers/mobile_regist_controller.go Dosyayı Görüntüle

236
 		//初始化医嘱模版
236
 		//初始化医嘱模版
237
 		//InitAdviceTemplate(org)
237
 		//InitAdviceTemplate(org)
238
 		//初始化角色和权限
238
 		//初始化角色和权限
239
-
240
-		//初始化设备管理
239
+		InitRoleAndPurviews(org)
240
+		//初始化设备管理org
241
 		InitEquitMentInformation(org)
241
 		InitEquitMentInformation(org)
242
 		//初始化显示配置
242
 		//初始化显示配置
243
 
243
 
736
 
736
 
737
 }
737
 }
738
 
738
 
739
+func InitRoleAndPurviews(org *models.Org) {
740
+	roles := LoadRoleConfig("./role.json").Roles
741
+	app, _ := service.GetOrgApp(org.Id, 3)
742
+	for _, item := range roles {
743
+		role := &models.Role{
744
+			RoleName:     item.RoleName,
745
+			RoleIntro:    item.RoleIntroduction,
746
+			Creator:      0,
747
+			OrgId:        org.Id,
748
+			AppId:        app.Id,
749
+			IsSuperAdmin: false,
750
+			Status:       1,
751
+			CreateTime:   time.Now().Unix(),
752
+			ModifyTime:   time.Now().Unix(),
753
+			Number:       item.Number,
754
+			IsSystem:     item.IsSystem,
755
+		}
756
+		err := service.CreateOrgRole(role)
757
+		if err == nil {
758
+			purview := &models.RolePurview{
759
+				RoleId:     role.Id,
760
+				OrgId:      org.Id,
761
+				AppId:      role.AppId,
762
+				PurviewIds: item.PurviewIds,
763
+				Status:     1,
764
+				CreateTime: time.Now().Unix(),
765
+				ModifyTime: time.Now().Unix(),
766
+			}
767
+			func_purview := &models.SgjUserRoleFuncPurview{
768
+				RoleId:     role.Id,
769
+				OrgId:      org.Id,
770
+				AppId:      role.AppId,
771
+				PurviewIds: item.FuncIds,
772
+				Status:     1,
773
+				Ctime:      time.Now().Unix(),
774
+				Mtime:      time.Now().Unix(),
775
+			}
776
+
777
+			service.CreateRolePurview(purview)
778
+			service.CreateFuncRolePurview(func_purview)
779
+		}
780
+	}
781
+}
782
+
739
 func (this *MobileRegistController) ModifyName() {
783
 func (this *MobileRegistController) ModifyName() {
740
 	name := this.GetString("name")
784
 	name := this.GetString("name")
741
 	adminUserObj := this.GetSession("mobile_admin_user")
785
 	adminUserObj := this.GetSession("mobile_admin_user")
795
 
839
 
796
 }
840
 }
797
 
841
 
842
+type RoleConfig struct {
843
+	Roles []*models.VMUserRoleAndPurview "json:roles"
844
+}
845
+
798
 type PatientConfig struct {
846
 type PatientConfig struct {
799
 	Patients []*models.VMOrgPatients "json:patients"
847
 	Patients []*models.VMOrgPatients "json:patients"
800
 }
848
 }
807
 	Prescription []*models.SystemPrescription "json:prescription"
855
 	Prescription []*models.SystemPrescription "json:prescription"
808
 }
856
 }
809
 
857
 
858
+func LoadRoleConfig(dataFile string) *RoleConfig {
859
+	var config RoleConfig
860
+	_, filename, _, _ := runtime.Caller(1)
861
+	datapath := path.Join(path.Dir(filename), dataFile)
862
+	config_file, err := os.Open(datapath)
863
+	if err != nil {
864
+		emit("Failed to open config file '%s': %s\n", datapath, err)
865
+		return &config
866
+	}
867
+
868
+	fi, _ := config_file.Stat()
869
+
870
+	buffer := make([]byte, fi.Size())
871
+	_, err = config_file.Read(buffer)
872
+
873
+	buffer, err = StripComments(buffer) //去掉注释
874
+	if err != nil {
875
+		emit("Failed to strip comments from json: %s\n", err)
876
+		return &config
877
+	}
878
+
879
+	buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
880
+	err = json.Unmarshal(buffer, &config)         //解析json格式数据
881
+	if err != nil {
882
+		emit("Failed unmarshalling json: %s\n", err)
883
+		return &config
884
+	}
885
+	return &config
886
+}
887
+
810
 func LoadPatientConfig(dataFile string) *PatientConfig {
888
 func LoadPatientConfig(dataFile string) *PatientConfig {
811
 	var config PatientConfig
889
 	var config PatientConfig
812
 	_, filename, _, _ := runtime.Caller(1)
890
 	_, filename, _, _ := runtime.Caller(1)

+ 0 - 5
controllers/new_mobile_api_controllers/new_login_api_controller.go Dosyayı Görüntüle

513
 	mobile := this.GetString("phone")
513
 	mobile := this.GetString("phone")
514
 	aespass := this.GetString("aespass")
514
 	aespass := this.GetString("aespass")
515
 	types, _ := this.GetInt("type", 0)
515
 	types, _ := this.GetInt("type", 0)
516
-
517
 	utils.TraceLog("mobile:%v aespass:%v", mobile, aespass)
516
 	utils.TraceLog("mobile:%v aespass:%v", mobile, aespass)
518
 	if utils.CellPhoneRegexp().MatchString(mobile) == false {
517
 	if utils.CellPhoneRegexp().MatchString(mobile) == false {
519
 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeMobileFormat)
518
 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeMobileFormat)
529
 			return
528
 			return
530
 		}
529
 		}
531
 	}
530
 	}
532
-	//this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
533
-	//	"msg": "短信发送成功,有效期为10分钟",
534
-	//})
535
-	//this.ServeJSON()
536
 
531
 
537
 	if err := service.SendVerificationCodeSMS(mobile, aespass); err != nil {
532
 	if err := service.SendVerificationCodeSMS(mobile, aespass); err != nil {
538
 		this.Data["json"] = enums.MakeFailResponseJSON(err.Error(), 600)
533
 		this.Data["json"] = enums.MakeFailResponseJSON(err.Error(), 600)

+ 2 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go Dosyayı Görüntüle

33
 	beego.Router("/m/api/changeorg", &HomeController{}, "post:ChangeOrg")
33
 	beego.Router("/m/api/changeorg", &HomeController{}, "post:ChangeOrg")
34
 	beego.Router("/m/api/createOrg", &HomeController{}, "post:CreateOrg")
34
 	beego.Router("/m/api/createOrg", &HomeController{}, "post:CreateOrg")
35
 
35
 
36
+	beego.Router("/m/api/modifypsw", &HomeController{}, "post:ModifyPsw")
37
+
36
 	beego.Router("/m/api/staff", &NewRoleApiController{}, "get:GetAllOrgUser")
38
 	beego.Router("/m/api/staff", &NewRoleApiController{}, "get:GetAllOrgUser")
37
 
39
 
38
 	beego.Router("/m/api/staff/edit", &NewRoleApiController{}, "post:EditAdmin")
40
 	beego.Router("/m/api/staff/edit", &NewRoleApiController{}, "post:EditAdmin")

+ 113 - 28
controllers/new_mobile_api_controllers/new_role_api_controller.go Dosyayı Görüntüle

314
 	adminUserInfo := this.GetMobileAdminUserInfo()
314
 	adminUserInfo := this.GetMobileAdminUserInfo()
315
 	role_id, _ := this.GetInt64("id", 0)
315
 	role_id, _ := this.GetInt64("id", 0)
316
 	rolePurview, _ := service.GetRoleAndPurviewById(role_id, adminUserInfo.Org.Id, adminUserInfo.App.Id)
316
 	rolePurview, _ := service.GetRoleAndPurviewById(role_id, adminUserInfo.Org.Id, adminUserInfo.App.Id)
317
+	funRolePurview, _ := service.GetRoleFuncPurview(role_id)
318
+
317
 	role, _ := service.GetRoleByRoleID(role_id)
319
 	role, _ := service.GetRoleByRoleID(role_id)
318
 	this.ServeSuccessJSON(map[string]interface{}{
320
 	this.ServeSuccessJSON(map[string]interface{}{
319
 		"role_purview": rolePurview,
321
 		"role_purview": rolePurview,
320
 		"role":         role,
322
 		"role":         role,
323
+		"func_purview": funRolePurview,
321
 	})
324
 	})
322
 }
325
 }
323
 
326
 
458
 	role_id, _ := this.GetInt64("id", 0)
461
 	role_id, _ := this.GetInt64("id", 0)
459
 	purview_id := this.GetString("purview_id")
462
 	purview_id := this.GetString("purview_id")
460
 	is_open, _ := this.GetInt64("type", 0)
463
 	is_open, _ := this.GetInt64("type", 0)
464
+	is_all, _ := this.GetInt64("is_all", 0)
465
+	pid := this.GetString("pid")
461
 
466
 
462
-	permissions, err := service.GetRoleFuncPurviewIds(role_id)
467
+	func_permissions, err := service.GetRoleFuncPurviewIds(role_id)
468
+	permissions, _ := service.GetRolePurviewIds(role_id)
463
 
469
 
464
 	if err != nil {
470
 	if err != nil {
465
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
471
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
467
 	} else {
473
 	} else {
468
 
474
 
469
 		if is_open == 1 { //打开
475
 		if is_open == 1 { //打开
470
-			purview, _ := service.GetFuncRolePurview(role_id)
471
-			if purview.ID == 0 { // 新建
476
+			//处理功能权限涉及到的菜单权限
472
 
477
 
473
-				purview.PurviewIds = purview_id
474
-				purview.Ctime = time.Now().Unix()
475
-				purview.Mtime = time.Now().Unix()
478
+			purview, _ := service.GetRolePurview(role_id)
479
+			if purview.Id == 0 { // 新建
480
+				purview.PurviewIds = pid
481
+				purview.CreateTime = time.Now().Unix()
482
+				purview.ModifyTime = time.Now().Unix()
476
 				purview.Status = 1
483
 				purview.Status = 1
477
 				purview.RoleId = role_id
484
 				purview.RoleId = role_id
478
 				purview.OrgId = adminUser.Org.Id
485
 				purview.OrgId = adminUser.Org.Id
479
 				purview.AppId = adminUser.App.Id
486
 				purview.AppId = adminUser.App.Id
480
-				err := service.CreateFuncRolePurview(&purview)
487
+				service.CreateRolePurview(&purview)
488
+
489
+			} else { //修改
490
+				var permission_arr []string
491
+				purview, _ := service.GetRolePurview(role_id)
492
+				if len(permissions) > 0 {
493
+					permission_arr = strings.Split(permissions, ",")
494
+					if len(pid) > 0 {
495
+						permission_arr = append(permission_arr, strings.Split(pid, ",")...)
496
+					}
497
+				} else {
498
+					if len(pid) > 0 {
499
+						permission_arr = strings.Split(pid, ",")
500
+					}
501
+				}
502
+				permission_arr = RemoveRepeatedIDSElement(permission_arr)
503
+				permissions = strings.Join(permission_arr, ",")
504
+				purview.PurviewIds = permissions
505
+				service.SaveRolePurview(&purview)
506
+			}
507
+
508
+			func_purview, _ := service.GetFuncRolePurview(role_id)
509
+			if func_purview.ID == 0 { // 新建
510
+
511
+				func_purview.PurviewIds = purview_id
512
+				func_purview.Ctime = time.Now().Unix()
513
+				func_purview.Mtime = time.Now().Unix()
514
+				func_purview.Status = 1
515
+				func_purview.RoleId = role_id
516
+				func_purview.OrgId = adminUser.Org.Id
517
+				func_purview.AppId = adminUser.App.Id
518
+				err := service.CreateFuncRolePurview(&func_purview)
481
 				if err != nil {
519
 				if err != nil {
482
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
520
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
483
 					return
521
 					return
488
 				})
526
 				})
489
 			} else { //修改
527
 			} else { //修改
490
 				var permission_arr []string
528
 				var permission_arr []string
491
-				purview, _ := service.GetRoleFuncPurview(role_id)
492
-				if len(permissions) > 0 {
493
-					permission_arr = strings.Split(permissions, ",")
529
+				func_purview, _ := service.GetRoleFuncPurview(role_id)
530
+				if len(func_permissions) > 0 {
531
+					permission_arr = strings.Split(func_permissions, ",")
494
 					if len(purview_id) > 0 {
532
 					if len(purview_id) > 0 {
495
 						permission_arr = append(permission_arr, strings.Split(purview_id, ",")...)
533
 						permission_arr = append(permission_arr, strings.Split(purview_id, ",")...)
496
 					}
534
 					}
500
 					}
538
 					}
501
 				}
539
 				}
502
 				permission_arr = RemoveRepeatedIDSElement(permission_arr)
540
 				permission_arr = RemoveRepeatedIDSElement(permission_arr)
503
-				permissions = strings.Join(permission_arr, ",")
504
-				purview.PurviewIds = permissions
541
+				func_permissions = strings.Join(permission_arr, ",")
542
+				func_purview.PurviewIds = func_permissions
505
 
543
 
506
-				err := service.SaveRoleFuncPurview(&purview)
544
+				err := service.SaveRoleFuncPurview(&func_purview)
507
 				if err != nil {
545
 				if err != nil {
508
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
546
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
509
 					return
547
 					return
513
 				})
551
 				})
514
 			}
552
 			}
515
 		} else { //关闭
553
 		} else { //关闭
516
-			permission_arr := strings.Split(permissions, ",")
517
-			purview_arr := strings.Split(purview_id, ",")
518
 
554
 
519
-			for index, id := range permission_arr {
520
-				for _, pur_id := range purview_arr {
521
-					if id == pur_id {
522
-						permission_arr = append(permission_arr[:index], permission_arr[index+1:]...)
555
+			//处理功能权限涉及到的菜单权限,当关闭到只剩下一个的时候,在将菜单权限对应的权限id清除
556
+			func_permission_arr := strings.Split(func_permissions, ",")
557
+			if len(func_permission_arr) == 1 {
558
+				permission_arr := strings.Split(permissions, ",")
559
+				pid_arr := strings.Split(pid, ",")
560
+				for _, pur_id := range pid_arr {
561
+					for index, id := range permission_arr {
562
+						if id == pur_id {
563
+							permission_arr = append(permission_arr[:index], permission_arr[index+1:]...)
564
+						}
523
 					}
565
 					}
524
 				}
566
 				}
567
+				purview, _ := service.GetRolePurview(role_id)
568
+				purview.PurviewIds = strings.Join(permission_arr, ",")
569
+				service.SaveRolePurview(&purview)
525
 			}
570
 			}
526
-			purview, _ := service.GetRoleFuncPurview(role_id)
527
-			purview.PurviewIds = strings.Join(permission_arr, ",")
528
 
571
 
529
-			err := service.SaveRoleFuncPurview(&purview)
530
-			if err != nil {
531
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
532
-				return
572
+			if is_all == 1 {
573
+
574
+				permission_arr := strings.Split(permissions, ",")
575
+				pid_arr := strings.Split(pid, ",")
576
+				for _, pur_id := range pid_arr {
577
+					for index, id := range permission_arr {
578
+						if id == pur_id {
579
+							permission_arr = append(permission_arr[:index], permission_arr[index+1:]...)
580
+						}
581
+					}
582
+				}
583
+				purview, _ := service.GetRolePurview(role_id)
584
+				purview.PurviewIds = strings.Join(permission_arr, ",")
585
+				service.SaveRolePurview(&purview)
586
+
587
+				func_purview, _ := service.GetRoleFuncPurview(role_id)
588
+				func_purview.PurviewIds = ""
589
+				err := service.SaveRoleFuncPurview(&func_purview)
590
+				if err != nil {
591
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
592
+					return
593
+				}
594
+				this.ServeSuccessJSON(map[string]interface{}{
595
+					"is_open": 0,
596
+				})
597
+
598
+			} else {
599
+				permission_arr := strings.Split(func_permissions, ",")
600
+				purview_arr := strings.Split(purview_id, ",")
601
+				fmt.Println(permission_arr)
602
+				fmt.Println(purview_arr)
603
+				for index, id := range permission_arr {
604
+					for _, pur_id := range purview_arr {
605
+						if id == pur_id {
606
+							permission_arr = append(permission_arr[:index], permission_arr[index+1:]...)
607
+						}
608
+					}
609
+				}
610
+				func_purview, _ := service.GetRoleFuncPurview(role_id)
611
+				func_purview.PurviewIds = strings.Join(permission_arr, ",")
612
+
613
+				err := service.SaveRoleFuncPurview(&func_purview)
614
+				if err != nil {
615
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
616
+					return
617
+				}
618
+				this.ServeSuccessJSON(map[string]interface{}{
619
+					"is_open": 0,
620
+				})
533
 			}
621
 			}
534
-			this.ServeSuccessJSON(map[string]interface{}{
535
-				"is_open": 0,
536
-			})
537
 
622
 
538
 		}
623
 		}
539
 	}
624
 	}

+ 2 - 2
controllers/new_mobile_api_controllers/patient.json Dosyayı Görüntüle

6
       "dialysis_no": "001",
6
       "dialysis_no": "001",
7
       "admission_number": "",
7
       "admission_number": "",
8
       "source": 1,
8
       "source": 1,
9
-      "lapseto": 2,
9
+      "lapseto": 1,
10
       "partition_id": 0,
10
       "partition_id": 0,
11
       "bed_id": 0,
11
       "bed_id": 0,
12
       "name": "演示患者一",
12
       "name": "演示患者一",
85
       "dialysis_no": "002",
85
       "dialysis_no": "002",
86
       "admission_number": "",
86
       "admission_number": "",
87
       "source": 1,
87
       "source": 1,
88
-      "lapseto": 2,
88
+      "lapseto": 1,
89
       "partition_id": 0,
89
       "partition_id": 0,
90
       "bed_id": 0,
90
       "bed_id": 0,
91
       "name": "演示患者二",
91
       "name": "演示患者二",

+ 87 - 0
controllers/new_mobile_api_controllers/role.json Dosyayı Görüntüle

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": "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",
11
+        "func_ids": "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55"
12
+      },
13
+      {
14
+        "role_name": "医生",
15
+        "role_introduction": "医生角色能够进行建立患者档案,制定和调整患者透析治疗方案,定期评价病人的透析质量等",
16
+        "is_super_admin": false,
17
+        "status": 1,
18
+        "is_system": 1,
19
+        "number": 9998,
20
+        "purview_ids": "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": ""
22
+
23
+
24
+      },
25
+      {
26
+        "role_name": "护士",
27
+        "role_introduction": "护士角色能够进行病人透析管理,以及医院的感染控制与消毒记录等",
28
+        "is_super_admin": false,
29
+        "status": 1,
30
+        "is_system": 1,
31
+        "number": 9997,
32
+        "purview_ids": "74,75,73,48,52,110,93,121,122,124,125,120",
33
+        "func_ids": ""
34
+
35
+
36
+
37
+      },
38
+      {
39
+        "role_name": "库存",
40
+        "role_introduction": "库存角色负责透析耗材的日常管理,对耗材的入库、出库、退库的登记操作",
41
+        "is_super_admin": false,
42
+        "status": 1,
43
+        "is_system": 0,
44
+        "number": 9996,
45
+        "purview_ids": "94,111,112,113,114,115,116,117,118,119,129,84",
46
+        "func_ids": ""
47
+
48
+
49
+
50
+      },{
51
+        "role_name": "运营",
52
+        "role_introduction": "运营角色能够在SCRM中管理微网站、使用营销工具、做会员管理和分销商品经营的操作",
53
+        "is_super_admin": false,
54
+        "status": 1,
55
+        "is_system": 0,
56
+        "number": 9995,
57
+        "purview_ids": "161,160,162,163,165,170,169,171,172,173,174,177,175,178,180,179,181,186,185,187,188,189,192",
58
+        "func_ids": ""
59
+
60
+
61
+
62
+      },{
63
+        "role_name": "技师",
64
+        "role_introduction": "技师角色能够进行设备的管理,日常维护维修记录等",
65
+        "is_super_admin": false,
66
+        "status": 1,
67
+        "is_system": 0,
68
+        "number": 9994,
69
+        "purview_ids": "77,78,79,80,76",
70
+        "func_ids": ""
71
+
72
+
73
+      },
74
+      {
75
+        "role_name": "院长",
76
+        "role_introduction": "院长角色了解血透患者血液透析质量和相关的大数据,以及掌握透析中心整体运营情况",
77
+        "is_super_admin": false,
78
+        "status": 1,
79
+        "is_system": 0,
80
+        "number": 9993,
81
+        "purview_ids": "",
82
+        "func_ids": ""
83
+
84
+
85
+      }
86
+    ]
87
+}

+ 64 - 7
controllers/verify_login_controller.go Dosyayı Görüntüle

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/models"
5
-	"fmt"
6
-	"net/url"
7
-
8
 	"XT_New/enums"
4
 	"XT_New/enums"
5
+	"XT_New/models"
9
 	"XT_New/service"
6
 	"XT_New/service"
10
 	"XT_New/utils"
7
 	"XT_New/utils"
11
-
8
+	"fmt"
12
 	"github.com/astaxie/beego"
9
 	"github.com/astaxie/beego"
10
+	"net/url"
11
+	"strconv"
12
+	"strings"
13
 )
13
 )
14
 
14
 
15
 func VerifyUserLoginControllerRegistRouters() {
15
 func VerifyUserLoginControllerRegistRouters() {
166
 			//	return
166
 			//	return
167
 			//}
167
 			//}
168
 
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
169
 			curAppUrlfors := adminUserInfo.AppUrlfors[adminUserInfo.CurrentAppId]
193
 			curAppUrlfors := adminUserInfo.AppUrlfors[adminUserInfo.CurrentAppId]
170
 
194
 
195
+			if len(curAppUrlfors) == 0 {
196
+				if adminUser.Id == curOrg.Creator {
197
+
198
+					urlfors, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(3)
199
+					curAppUrlfors = urlfors
200
+
201
+				} else {
202
+					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
212
+						}
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)
221
+						}
222
+					}
223
+
224
+				}
225
+
226
+			}
227
+
171
 			//subscibe := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
228
 			//subscibe := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
172
 			//fmt.Println("subscibe", subscibe)
229
 			//fmt.Println("subscibe", subscibe)
173
 			//if err := service.GetOrgSubscibeState(subscibe); err != nil {
230
 			//if err := service.GetOrgSubscibeState(subscibe); err != nil {
191
 			//		didRegistedForMall = true
248
 			//		didRegistedForMall = true
192
 			//	}
249
 			//	}
193
 			//}
250
 			//}
194
-			//service.GetOrgSub
251
+			subscibe, _ := service.GetOrgSubscibe(adminUserInfo.CurrentOrgId)
195
 
252
 
196
 			this.SetSession("admin_user_info", adminUserInfo)
253
 			this.SetSession("admin_user_info", adminUserInfo)
197
 
254
 
201
 				"urlfors":        curAppUrlfors,
258
 				"urlfors":        curAppUrlfors,
202
 				"current_org_id": adminUserInfo.CurrentOrgId,
259
 				"current_org_id": adminUserInfo.CurrentOrgId,
203
 				"current_app_id": adminUserInfo.CurrentAppId,
260
 				"current_app_id": adminUserInfo.CurrentAppId,
204
-				//"subscibe":        subscibe,
261
+				"subscibe":       subscibe,
205
 				//"scrm_role_exist": didRegistedForSCRM,
262
 				//"scrm_role_exist": didRegistedForSCRM,
206
 				//"cdm_role_exist":  didRegistedForCDM,
263
 				//"cdm_role_exist":  didRegistedForCDM,
207
 				//"mall_role_exist": didRegistedForMall,
264
 				//"mall_role_exist": didRegistedForMall,

+ 2 - 0
models/dialysis.go Dosyayı Görüntüle

636
 	Conductivity              float64 `gorm:"column:conductivity" json:"conductivity"`
636
 	Conductivity              float64 `gorm:"column:conductivity" json:"conductivity"`
637
 	DisplacementFlowQuantity  float64 `gorm:"column:displacement_flow_quantity" json:"displacement_flow_quantity"`
637
 	DisplacementFlowQuantity  float64 `gorm:"column:displacement_flow_quantity" json:"displacement_flow_quantity"`
638
 	BloodOxygenSaturation     string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
638
 	BloodOxygenSaturation     string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
639
+	Creator                   int64   `gorm:"column:creator" json:"creator" form:"creator"`
640
+	Modify                    int64   `gorm:"column:modify" json:"modify" form:"modify"`
639
 }
641
 }
640
 
642
 
641
 func (MonitoringRecord) TableName() string {
643
 func (MonitoringRecord) TableName() string {

+ 2 - 0
models/intergration_models.go Dosyayı Görüntüle

265
 	Status           int64  `gorm:"column:status" json:"status" form:"status"`
265
 	Status           int64  `gorm:"column:status" json:"status" form:"status"`
266
 	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
266
 	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
267
 	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
267
 	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
268
+	Number           int64  `gorm:"column:number" json:"number" form:"number"`
269
+	IsSystem         int64  `gorm:"column:is_system" json:"is_system" form:"is_system"`
268
 }
270
 }
269
 
271
 
270
 func (VMUserRole) TableName() string {
272
 func (VMUserRole) TableName() string {

+ 1 - 2
models/purview_models.go Dosyayı Görüntüle

32
 	Status     int8   // 状态 0.无效 1.有效 2.禁用
32
 	Status     int8   // 状态 0.无效 1.有效 2.禁用
33
 	CreateTime int64  `gorm:"column:ctime"` // 创建时间
33
 	CreateTime int64  `gorm:"column:ctime"` // 创建时间
34
 	ModifyTime int64  `gorm:"column:mtime"` // 修改时间
34
 	ModifyTime int64  `gorm:"column:mtime"` // 修改时间
35
-
36
-	Role Role `gorm:"ForeignKey:RoleId;AssociationForeignKey:ID" json:"role_info"`
35
+	Role       Role   `gorm:"ForeignKey:RoleId;AssociationForeignKey:ID" json:"role_info"`
37
 }
36
 }
38
 
37
 
39
 func (RolePurview) TableName() string {
38
 func (RolePurview) TableName() string {

+ 4 - 0
models/role_models.go Dosyayı Görüntüle

12
 	CreateTime   int64  `gorm:"column:ctime" json:"-"` // 创建时间
12
 	CreateTime   int64  `gorm:"column:ctime" json:"-"` // 创建时间
13
 	ModifyTime   int64  `gorm:"column:mtime" json:"-"` // 修改时间
13
 	ModifyTime   int64  `gorm:"column:mtime" json:"-"` // 修改时间
14
 	StaffNumber  int64  `gorm:"-" json:"staff_number"`
14
 	StaffNumber  int64  `gorm:"-" json:"staff_number"`
15
+	Number       int64  `gorm:"number" json:"number"`
16
+	IsSystem     int64  `gorm:"column:is_system" json:"is_system" form:"is_system"`
15
 }
17
 }
16
 
18
 
17
 func (Role) TableName() string {
19
 func (Role) TableName() string {
111
 	CreateTime   int64  `gorm:"column:ctime" json:"-"` // 创建时间
113
 	CreateTime   int64  `gorm:"column:ctime" json:"-"` // 创建时间
112
 	ModifyTime   int64  `gorm:"column:mtime" json:"-"` // 修改时间
114
 	ModifyTime   int64  `gorm:"column:mtime" json:"-"` // 修改时间
113
 	StaffNumber  int64  `gorm:"-" json:"staff_number"`
115
 	StaffNumber  int64  `gorm:"-" json:"staff_number"`
116
+	Number       int64  `gorm:"column:number" json:"number" form:"number"`
117
+	IsSystem     int64  `gorm:"column:is_system" json:"is_system" form:"is_system"`
114
 }
118
 }
115
 
119
 
116
 func (Roles) TableName() string {
120
 func (Roles) TableName() string {

+ 21 - 0
models/vm_models.go Dosyayı Görüntüle

296
 func (VmDeviceTreatmentmode) TableName() string {
296
 func (VmDeviceTreatmentmode) TableName() string {
297
 	return "xt_device_treatmentmode"
297
 	return "xt_device_treatmentmode"
298
 }
298
 }
299
+
300
+type VMUserRoleAndPurview struct {
301
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
302
+	RoleName         string `gorm:"column:role_name" json:"role_name" form:"role_name"`
303
+	RoleIntroduction string `gorm:"column:role_introduction" json:"role_introduction" form:"role_introduction"`
304
+	Creator          int64  `gorm:"column:creator" json:"creator" form:"creator"`
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"`
307
+	IsSuperAdmin     int64  `gorm:"column:is_super_admin" json:"is_super_admin" form:"is_super_admin"`
308
+	Status           int64  `gorm:"column:status" json:"status" form:"status"`
309
+	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
310
+	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
311
+	Number           int64  `gorm:"column:number" json:"number" form:"number"`
312
+	PurviewIds       string `gorm:"column:-" json:"purview_ids" form:"purview_ids"`
313
+	FuncIds          string `gorm:"column:-" json:"func_ids" form:"func_ids"`
314
+	IsSystem         int64  `gorm:"column:is_system" json:"is_system" form:"is_system"`
315
+}
316
+
317
+func (VMUserRoleAndPurview) TableName() string {
318
+	return "sgj_user_role"
319
+}

+ 2 - 2
service/mobile_dialysis_service.go Dosyayı Görüntüle

613
 	return &patient, nil
613
 	return &patient, nil
614
 }
614
 }
615
 
615
 
616
-func DisableMonitor(orgID int64, patientID int64, recordID int64) error {
616
+func DisableMonitor(orgID int64, patientID int64, recordID int64, admin_user_id int64) error {
617
 	fmt.Println()
617
 	fmt.Println()
618
 	tx := writeDb.Begin()
618
 	tx := writeDb.Begin()
619
 	updateTime := time.Now().Unix()
619
 	updateTime := time.Now().Unix()
620
-	err := tx.Model(&models.MonitoringRecord{}).Where("user_org_id = ? AND patient_id = ? AND id = ? AND status = 1 ", orgID, patientID, recordID).Updates(map[string]interface{}{"status": 0, "updated_time": updateTime}).Error
620
+	err := tx.Model(&models.MonitoringRecord{}).Where("user_org_id = ? AND patient_id = ? AND id = ? AND status = 1 ", orgID, patientID, recordID).Updates(map[string]interface{}{"status": 0, "updated_time": updateTime, "modify": admin_user_id}).Error
621
 	if err != nil {
621
 	if err != nil {
622
 		tx.Rollback()
622
 		tx.Rollback()
623
 		return err
623
 		return err

+ 2 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go Dosyayı Görüntüle

481
 	Conductivity              float64 `gorm:"column:conductivity" json:"conductivity"`
481
 	Conductivity              float64 `gorm:"column:conductivity" json:"conductivity"`
482
 	DisplacementFlowQuantity  float64 `gorm:"column:displacement_flow_quantity" json:"displacement_flow_quantity"`
482
 	DisplacementFlowQuantity  float64 `gorm:"column:displacement_flow_quantity" json:"displacement_flow_quantity"`
483
 	BloodOxygenSaturation     string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
483
 	BloodOxygenSaturation     string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
484
+	Creator                   int64   `gorm:"column:creator" json:"creator" form:"creator"`
485
+	Modify                    int64   `gorm:"column:modify" json:"modify" form:"modify"`
484
 }
486
 }
485
 
487
 
486
 func (MonitoringRecordVM) TableName() string {
488
 func (MonitoringRecordVM) TableName() string {

+ 2 - 2
service/role_service.go Dosyayı Görüntüle

417
 	var roles []*models.Role
417
 	var roles []*models.Role
418
 	err := readUserDb.Model(models.Role{}).
418
 	err := readUserDb.Model(models.Role{}).
419
 		Where("org_id = ? AND status = 1", orgID).
419
 		Where("org_id = ? AND status = 1", orgID).
420
-		Order("number asc,ctime").
420
+		Order("number desc,ctime").
421
 		Find(&roles).
421
 		Find(&roles).
422
 		Error
422
 		Error
423
 	if err != nil {
423
 	if err != nil {
496
 	var viewModels []*NewAdminUserModel = make([]*NewAdminUserModel, 0)
496
 	var viewModels []*NewAdminUserModel = make([]*NewAdminUserModel, 0)
497
 	var rows *sql.Rows
497
 	var rows *sql.Rows
498
 	var err error
498
 	var err error
499
-	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 = ? AND user_type != 1  ORDER BY ctime DESC", orgID, appID).Rows()
499
+	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 = ? AND user_type <> 1 ORDER BY ctime DESC", orgID, appID).Rows()
500
 	defer rows.Close()
500
 	defer rows.Close()
501
 	if err != nil {
501
 	if err != nil {
502
 		if err == gorm.ErrRecordNotFound {
502
 		if err == gorm.ErrRecordNotFound {

+ 5 - 0
service/subscibe_service.go Dosyayı Görüntüle

27
 	return
27
 	return
28
 
28
 
29
 }
29
 }
30
+
31
+func GetOrgSubscibe(org_id int64) (subscibe models.ServeSubscibe, err error) {
32
+	err = readUserDb.Model(&models.ServeSubscibe{}).Where("org_id = ? AND status = 1", org_id).First(&subscibe).Error
33
+	return
34
+}

+ 66 - 0
service/verify_login_token_service.go Dosyayı Görüntüle

2
 
2
 
3
 import (
3
 import (
4
 	"encoding/json"
4
 	"encoding/json"
5
+	"github.com/jinzhu/gorm"
5
 	"io/ioutil"
6
 	"io/ioutil"
6
 	"net/http"
7
 	"net/http"
7
 	"net/url"
8
 	"net/url"
383
 	err := writeUserDb.Model(&models.AdminUser{}).Where("id = ? AND status = 1", adminID).Updates(map[string]interface{}{"password": password, "mtime": time.Now().Unix()}).Error
384
 	err := writeUserDb.Model(&models.AdminUser{}).Where("id = ? AND status = 1", adminID).Updates(map[string]interface{}{"password": password, "mtime": time.Now().Unix()}).Error
384
 	return err
385
 	return err
385
 }
386
 }
387
+
388
+func GetPurviewById(ids string) ([]*models.Purview, error) {
389
+	var originPurviews []*models.Purview
390
+	getPurviewErr := readUserDb.Model(&models.Purview{}).Where(fmt.Sprintf("id in (%v) and status = 1", ids)).Order("listorder asc").Order("id asc").Find(&originPurviews).Error
391
+	return originPurviews, getPurviewErr
392
+}
393
+
394
+func FindAdminUserIDA(id int64) (role models.App_Role, err error) {
395
+	err = readUserDb.Model(&models.App_Role{}).Where("id = ?", id).First(&role).Error
396
+	return
397
+}
398
+
399
+func GetSuperAdminUsersPurviewTreeAndUrlfors(appType int) ([]string, []*models.Purview, error) {
400
+	originPurviews, getPurviewErr := getAllOriginPurviews(appType)
401
+	if getPurviewErr != nil {
402
+		return nil, nil, getPurviewErr
403
+	}
404
+	urlfors, processedPurviews := getUrlforsAndProcessPurviews2Tree(originPurviews)
405
+	return urlfors, processedPurviews, nil
406
+}
407
+
408
+// 加工这些规则:树形化;以及从中取出不为空的 urlfor
409
+// 正确结果的前提是 originPurviews 以 parentid asc 排好序了的
410
+func getUrlforsAndProcessPurviews2Tree(originPurviews []*models.Purview) ([]string, []*models.Purview) {
411
+	processedPurviews := make([]*models.Purview, 0)
412
+	pid_childs := make(map[int][]*models.Purview)
413
+	urlfors := make([]string, 0, len(originPurviews))
414
+	for _, purview := range originPurviews {
415
+		if len(purview.Urlfor) != 0 {
416
+			urlfors = append(urlfors, purview.Urlfor)
417
+		}
418
+
419
+		// warning:下面这个算法只适用最多两层树形结构的菜单,对于两层以上的会丢失掉第三层及其以下的节点
420
+		// 因为取出 originPurviews 的时候已经排过序了,所以顶级节点肯定最先处理,不需要担心子节点比父节点先处理
421
+		if purview.Parentid == 0 {
422
+			processedPurviews = append(processedPurviews, purview)
423
+		} else {
424
+			childs := pid_childs[int(purview.Parentid)]
425
+			if pid_childs[int(purview.Parentid)] == nil {
426
+				childs = make([]*models.Purview, 0)
427
+			}
428
+			childs = append(childs, purview)
429
+			pid_childs[int(purview.Parentid)] = childs
430
+		}
431
+	}
432
+
433
+	for _, proPurview := range processedPurviews {
434
+		proPurview.Childs = pid_childs[int(proPurview.Id)]
435
+	}
436
+
437
+	return urlfors, processedPurviews
438
+}
439
+
440
+func getAllOriginPurviews(appType int) ([]*models.Purview, error) {
441
+	var purviews []*models.Purview
442
+	getPurviewErr := readUserDb.Model(models.Purview{}).Where("module = ? AND status = 1", appType).Order("listorder asc").Order("id asc").Find(&purviews).Error
443
+	if getPurviewErr != nil {
444
+		if getPurviewErr == gorm.ErrRecordNotFound {
445
+			return nil, nil
446
+		} else {
447
+			return nil, getPurviewErr
448
+		}
449
+	}
450
+	return purviews, nil
451
+}