Selaa lähdekoodia

负责人下拉权限选择

ith5 5 kuukautta sitten
vanhempi
commit
98ef19e5f0
1 muutettua tiedostoa jossa 18 lisäystä ja 6 poistoa
  1. 18 6
      app/v1/controller/CommonController.php

+ 18 - 6
app/v1/controller/CommonController.php

@@ -9,6 +9,7 @@ use app\v1\logic\center\GameGroupLogic;
 use app\v1\logic\center\GameLogic;
 use plugin\saiadmin\basic\BaseController;
 use app\v1\logic\center\GameMainLogic;
+use plugin\saiadmin\app\cache\UserInfoCache;
 use plugin\saiadmin\app\logic\system\SystemUserLogic;
 use plugin\saiadmin\app\model\system\SystemDept;
 use support\Request;
@@ -117,12 +118,23 @@ class CommonController extends BaseController
      */
     public function getAuthOptions(Request $request): Response
     {
-        // 获取用户列表
-        $data = $this->systemUserLogic->field('id as value, username as label,dept_id')->group('dept_id')->select()->toArray();
-        
-        // 获取用户部门
-        $deptList = SystemDept::where('1=1')->select()->toArray();
-
+                // 根据用户id获取用户权限
+        $token = getCurrentInfo();
+        // 用户权限缓存
+        $userAuthCache = new UserInfoCache($token['id']);
+        $user_info = $userAuthCache->getUserInfo();
+        $currentUserRoleList = $user_info['roleList'];
+        $currentUserRoleList = array_column($currentUserRoleList, 'id');
+        print_r($currentUserRoleList);
+
+        // 管理员角色ID:1, 则不限制权限
+        if(in_array(1,$currentUserRoleList)){
+            $data = $this->systemUserLogic->field('id as value, username as label,dept_id')->group('dept_id')->select()->toArray();
+            $deptList = SystemDept::where('1=1')->select()->toArray();
+        }else{
+            $data = $this->systemUserLogic->field('id as value, username as label,dept_id')->where('id',$user_info['id'])->group('dept_id')->select()->toArray();
+            $deptList = SystemDept::where('id',$user_info['dept_id'])->select()->toArray();
+        }
         $result = [];
         // 将部门列表转为以id为key的数组,便于查找
         $deptMap = [];