Ver código fonte

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

XMLWAN 4 anos atrás
pai
commit
35c15a5092

+ 2 - 0
controllers/dialysis_record_api_controller.go Ver arquivo

@@ -493,6 +493,7 @@ func (this *DialysisRecordAPIController) EditMonitor() {
493 493
 			CreatedTime:           time.Now().Unix(),
494 494
 			UpdatedTime:           time.Now().Unix(),
495 495
 			BloodOxygenSaturation: monitorParam.BloodOxygenSaturation,
496
+			Creator:               adminUserInfo.AdminUser.Id,
496 497
 		}
497 498
 		createErr := service.CreateMonitor(&monitor)
498 499
 		if createErr != nil {
@@ -550,6 +551,7 @@ func (this *DialysisRecordAPIController) EditMonitor() {
550 551
 		monitor.Result = monitorParam.Result
551 552
 		monitor.MonitoringNurse = adminUserInfo.AdminUser.Id
552 553
 		monitor.UpdatedTime = time.Now().Unix()
554
+		monitor.Modify = adminUserInfo.AdminUser.Id
553 555
 		monitor.BloodOxygenSaturation = monitorParam.BloodOxygenSaturation
554 556
 		updateErr := service.UpdateMonitor(monitor)
555 557
 		if updateErr != nil {

+ 8 - 1
controllers/mobile_api_controllers/mobile_api_base_controller.go Ver arquivo

@@ -54,11 +54,18 @@ func (this *MobileBaseAPIAuthController) Prepare() {
54 54
 	this.MobileBaseAPIController.Prepare()
55 55
 	adminUserInfo := this.GetMobileAdminUserInfo()
56 56
 
57
-	if adminUserInfo == nil || len(token) == 0 {
57
+	if adminUserInfo == nil {
58
+		this.DelSession("mobile_admin_user_info")
58 59
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
59 60
 		this.StopRun()
60 61
 	}
61 62
 
63
+	if len(token) == 0 {
64
+		this.DelSession("mobile_admin_user_info")
65
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeLoginTimeout)
66
+		this.StopRun()
67
+	}
68
+
62 69
 	//if this.Ctx.Request.Method != "GET" {
63 70
 	//	err := service.GetOrgSubscibeState(adminUserInfo.Subscibe)
64 71
 	//	if err != nil || adminUserInfo.Subscibe.State == 3 {

+ 0 - 1
controllers/mobile_api_controllers/patient_api_controller.go Ver arquivo

@@ -288,7 +288,6 @@ func (c *PatientApiController) EditDoctorAdvice() {
288 288
 	advice.Status = 1
289 289
 	advice.UpdatedTime = time.Now().Unix()
290 290
 	advice.UserOrgId = adminUserInfo.Org.Id
291
-	advice.AdviceDoctor = adminUserInfo.AdminUser.Id
292 291
 	advice.Modifier = adminUserInfo.AdminUser.Id
293 292
 
294 293
 	//处理修改医嘱开始时间逻辑(不包括子医嘱)

+ 124 - 0
controllers/new_mobile_api_controllers/home_api_controller.go Ver arquivo

@@ -597,3 +597,127 @@ func (this *HomeController) checkParam(mobile string, code string, password stri
597 597
 	}
598 598
 	return nil
599 599
 }
600
+
601
+func (this *HomeController) GetFuncPermission() {
602
+	adminUserInfo := this.GetMobileAdminUserInfo()
603
+	user_id := adminUserInfo.AdminUser.Id
604
+	app_id := adminUserInfo.App.Id
605
+	org_id := adminUserInfo.Org.Id
606
+	create_url := this.GetString("create_url")
607
+	modify_url := this.GetString("modify_url")
608
+	modify_other_url := this.GetString("modify_other_url")
609
+	del_url := this.GetString("del_url")
610
+	del_other_url := this.GetString("del_other_url")
611
+	exce_url := this.GetString("exce_url")
612
+	check_url := this.GetString("check_url")
613
+	modify_exce_url := this.GetString("modify_exce_url")
614
+	module, _ := this.GetInt64("module", 0)
615
+
616
+	app_role, _ := service.GetAppRole(org_id, app_id, user_id)
617
+	var is_has_create bool
618
+	var is_has_modify bool
619
+	var is_has_modify_other bool
620
+	var is_has_del bool
621
+	var is_has_del_other bool
622
+	var is_has_exce bool
623
+	var is_has_check bool
624
+	var is_has_modify_exce bool
625
+
626
+	if adminUserInfo.AdminUser.Id != adminUserInfo.Org.Creator {
627
+
628
+		if app_role != nil {
629
+			if len(app_role.RoleIds) > 0 {
630
+				roles := strings.Split(app_role.RoleIds, ",")
631
+				var userRolePurviews string
632
+				for _, item := range roles {
633
+					role_id, _ := strconv.ParseInt(item, 10, 64)
634
+					purviews, _ := service.GetRoleFuncPurviewIds(role_id)
635
+					if len(userRolePurviews) == 0 {
636
+						userRolePurviews = purviews
637
+					} else {
638
+						userRolePurviews = userRolePurviews + "," + purviews
639
+					}
640
+				}
641
+				userRolePurviewsArr := RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
642
+				funcPurviews, _ := service.FindAllFuncPurview(userRolePurviewsArr)
643
+				for _, item := range funcPurviews {
644
+					//for _, url := range strings.Split(item.Urlfor,","){
645
+					if strings.Split(item.Urlfor, ",")[0] == create_url {
646
+						is_has_create = true
647
+					}
648
+					if strings.Split(item.Urlfor, ",")[0] == modify_url {
649
+						is_has_modify = true
650
+					}
651
+					if strings.Split(item.Urlfor, ",")[0] == modify_other_url {
652
+						is_has_modify_other = true
653
+					}
654
+					if strings.Split(item.Urlfor, ",")[0] == del_url {
655
+						is_has_del = true
656
+					}
657
+					if strings.Split(item.Urlfor, ",")[0] == del_other_url {
658
+						is_has_del_other = true
659
+					}
660
+					if strings.Split(item.Urlfor, ",")[0] == exce_url {
661
+						is_has_exce = true
662
+					}
663
+					if strings.Split(item.Urlfor, ",")[0] == check_url {
664
+						is_has_check = true
665
+					}
666
+					if strings.Split(item.Urlfor, ",")[0] == modify_exce_url {
667
+						is_has_modify_exce = true
668
+					}
669
+
670
+				}
671
+			} else {
672
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRole)
673
+				return
674
+			}
675
+			this.ServeSuccessJSON(map[string]interface{}{
676
+				"is_has_create":       is_has_create,
677
+				"is_has_modify":       is_has_modify,
678
+				"is_has_modify_other": is_has_modify_other,
679
+				"is_has_del":          is_has_del,
680
+				"is_has_del_other":    is_has_del_other,
681
+				"is_has_exce":         is_has_exce,
682
+				"is_has_check":        is_has_check,
683
+				"is_has_modify_exce":  is_has_modify_exce,
684
+				"module":              module,
685
+			})
686
+		} else {
687
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserIsExit)
688
+			return
689
+
690
+		}
691
+
692
+	} else {
693
+		this.ServeSuccessJSON(map[string]interface{}{
694
+			"is_has_create":       true,
695
+			"is_has_modify":       true,
696
+			"is_has_modify_other": true,
697
+			"is_has_del":          true,
698
+			"is_has_del_other":    true,
699
+			"is_has_exce":         true,
700
+			"is_has_check":        true,
701
+			"is_has_modify_exce":  true,
702
+			"module":              true,
703
+		})
704
+
705
+	}
706
+
707
+}
708
+func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
709
+	newArr = make([]string, 0)
710
+	for i := 0; i < len(arr); i++ {
711
+		repeat := false
712
+		for j := i + 1; j < len(arr); j++ {
713
+			if arr[i] == arr[j] {
714
+				repeat = true
715
+				break
716
+			}
717
+		}
718
+		if !repeat {
719
+			newArr = append(newArr, arr[i])
720
+		}
721
+	}
722
+	return
723
+}

+ 2 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go Ver arquivo

@@ -60,6 +60,8 @@ func NewMobileAPIControllersRegisterRouters() {
60 60
 
61 61
 	beego.Router("/m/api/func_role/get", &NewRoleApiController{}, "get:GetFuncRolePurviews")
62 62
 
63
+	beego.Router("/m/api/permission/get", &HomeController{}, "get:GetFuncPermission")
64
+
63 65
 	beego.Router("/m/api/patient/getbloodpatientinfo", &NewDialysisApiController{}, "Get:GetBloodPatientInfo")
64 66
 	beego.Router("/m/api/patient/getslowpatientinfo", &NewDialysisApiController{}, "Get:GetSlowPatientInfo")
65 67
 	beego.Router("/m/api/patient/getmemberpatientinfo", &NewDialysisApiController{}, "Get:GetMemberpatientInfo")

+ 0 - 3
controllers/patient_api_controller.go Ver arquivo

@@ -798,8 +798,6 @@ func (c *PatientApiController) UpdateDialysisSolution() {
798 798
 	}
799 799
 
800 800
 	solution.UpdatedTime = time.Now().Unix()
801
-	solution.Doctor = adminUserInfo.AdminUser.Id
802
-	solution.RegistrarsId = adminUserInfo.AdminUser.Id
803 801
 
804 802
 	err := service.UpdatePatientDialysisSolution(&solution)
805 803
 	if err != nil {
@@ -1724,7 +1722,6 @@ func (c *PatientApiController) UpdateDoctorAdvice() {
1724 1722
 	}
1725 1723
 
1726 1724
 	advice.UpdatedTime = time.Now().Unix()
1727
-	advice.AdviceDoctor = adminUserInfo.AdminUser.Id
1728 1725
 	advice.Modifier = adminUserInfo.AdminUser.Id
1729 1726
 
1730 1727
 	err := service.UpdateDoctorAdvice(&advice)

+ 8 - 0
enums/error_code.go Ver arquivo

@@ -188,6 +188,10 @@ const ( // ErrorCode
188 188
 
189 189
 	ErrorCodeForbidden       = 20035
190 190
 	ErrorCodeRoleNameIsExist = 20036
191
+
192
+	ErrorCodeRole = 20037
193
+
194
+	ErrorCodeAdminUserIsExit = 20038
191 195
 )
192 196
 
193 197
 var ErrCodeMsgs = map[int]string{
@@ -375,6 +379,10 @@ var ErrCodeMsgs = map[int]string{
375 379
 	ErrorCodeForbidden: "你已经被管理员禁用,无法使用该系统",
376 380
 
377 381
 	ErrorCodeRoleNameIsExist: "该角色已经不存在",
382
+
383
+	ErrorCodeRole: "尚未配置角色,无访问权限",
384
+
385
+	ErrorCodeAdminUserIsExit: "用户不存在",
378 386
 }
379 387
 
380 388
 type SGJError struct {

+ 6 - 0
service/role_service.go Ver arquivo

@@ -748,3 +748,9 @@ func FindRoleRecordByRoleName(name string, org_id int64) (total int64) {
748 748
 	readUserDb.Model(&models.Role{}).Where("status = 1 AND role_name = ? AND org_id = ?", name, org_id).Count(&total)
749 749
 	return
750 750
 }
751
+
752
+func FindAllFuncPurview(ids []string) (purview []*models.SgjUserOperatePurview, err error) {
753
+	err = readUserDb.Model(&models.SgjUserOperatePurview{}).Where("status = 1 AND id in (?)", ids).Find(&purview).Error
754
+	return
755
+
756
+}