Ver código fonte

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

csx 4 anos atrás
pai
commit
8e813f3012

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

+ 70 - 53
controllers/new_mobile_api_controllers/home_api_controller.go Ver arquivo

@@ -623,67 +623,84 @@ func (this *HomeController) GetFuncPermission() {
623 623
 	var is_has_check bool
624 624
 	var is_has_modify_exce bool
625 625
 
626
-	if app_role != nil {
627
-		if len(app_role.RoleIds) > 0 {
628
-			roles := strings.Split(app_role.RoleIds, ",")
629
-			var userRolePurviews string
630
-			for _, item := range roles {
631
-				role_id, _ := strconv.ParseInt(item, 10, 64)
632
-				purviews, _ := service.GetRoleFuncPurviewIds(role_id)
633
-				if len(userRolePurviews) == 0 {
634
-					userRolePurviews = purviews
635
-				} else {
636
-					userRolePurviews = userRolePurviews + "," + purviews
637
-				}
638
-			}
639
-			userRolePurviewsArr := RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
640
-			funcPurviews, _ := service.FindAllFuncPurview(userRolePurviewsArr)
641
-			for _, item := range funcPurviews {
642
-				//for _, url := range strings.Split(item.Urlfor,","){
643
-				if strings.Split(item.Urlfor, ",")[0] == create_url {
644
-					is_has_create = true
645
-				}
646
-				if strings.Split(item.Urlfor, ",")[0] == modify_url {
647
-					is_has_modify = true
648
-				}
649
-				if strings.Split(item.Urlfor, ",")[0] == modify_other_url {
650
-					is_has_modify_other = true
651
-				}
652
-				if strings.Split(item.Urlfor, ",")[0] == del_url {
653
-					is_has_del = true
654
-				}
655
-				if strings.Split(item.Urlfor, ",")[0] == del_other_url {
656
-					is_has_del_other = true
657
-				}
658
-				if strings.Split(item.Urlfor, ",")[0] == exce_url {
659
-					is_has_exce = true
660
-				}
661
-				if strings.Split(item.Urlfor, ",")[0] == check_url {
662
-					is_has_check = true
663
-				}
664
-				if strings.Split(item.Urlfor, ",")[0] == modify_exce_url {
665
-					is_has_modify_exce = true
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
+					}
666 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
+					}
667 669
 
670
+				}
671
+			} else {
672
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRole)
673
+				return
668 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
+			})
669 686
 		} else {
670
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRole)
687
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserIsExit)
671 688
 			return
689
+
672 690
 		}
691
+
692
+	} else {
673 693
 		this.ServeSuccessJSON(map[string]interface{}{
674
-			"is_has_create":       is_has_create,
675
-			"is_has_modify":       is_has_modify,
676
-			"is_has_modify_other": is_has_modify_other,
677
-			"is_has_del":          is_has_del,
678
-			"is_has_del_other":    is_has_del_other,
679
-			"is_has_exce":         is_has_exce,
680
-			"is_has_check":        is_has_check,
681
-			"is_has_modify_exce":  is_has_modify_exce,
682
-			"module":              module,
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,
683 703
 		})
684
-	} else {
685
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserIsExit)
686
-		return
687 704
 
688 705
 	}
689 706