|
@@ -597,3 +597,110 @@ 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 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
|
|
666
|
+ }
|
|
667
|
+
|
|
668
|
+ }
|
|
669
|
+ } else {
|
|
670
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRole)
|
|
671
|
+ return
|
|
672
|
+ }
|
|
673
|
+ 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,
|
|
683
|
+ })
|
|
684
|
+ } else {
|
|
685
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserIsExit)
|
|
686
|
+ return
|
|
687
|
+
|
|
688
|
+ }
|
|
689
|
+
|
|
690
|
+}
|
|
691
|
+func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
|
|
692
|
+ newArr = make([]string, 0)
|
|
693
|
+ for i := 0; i < len(arr); i++ {
|
|
694
|
+ repeat := false
|
|
695
|
+ for j := i + 1; j < len(arr); j++ {
|
|
696
|
+ if arr[i] == arr[j] {
|
|
697
|
+ repeat = true
|
|
698
|
+ break
|
|
699
|
+ }
|
|
700
|
+ }
|
|
701
|
+ if !repeat {
|
|
702
|
+ newArr = append(newArr, arr[i])
|
|
703
|
+ }
|
|
704
|
+ }
|
|
705
|
+ return
|
|
706
|
+}
|