Ver código fonte

缓存拿数据

ith5 5 meses atrás
pai
commit
a1862ca4f4

+ 10 - 9
plugin/saiadmin/app/logic/system/SystemRoleLogic.php

@@ -173,15 +173,16 @@ class SystemRoleLogic extends BaseLogic
         }
         $query->order('sort', 'desc');
         $data = $this->getAll($query);
-        if (!empty($disabled)) {
-            foreach ($data as &$item) {
-                if (in_array($item['id'], $disabled)) {
-                    $item['disabled'] = true;
-                } else {
-                    $item['disabled'] = false;
-                }
-            }
-        }
+        // 
+        // if (!empty($disabled)) {
+        //     foreach ($data as &$item) {
+        //         if (in_array($item['id'], $disabled)) {
+        //             $item['disabled'] = true;
+        //         } else {
+        //             $item['disabled'] = false;
+        //         }
+        //     }
+        // }
         return Helper::makeTree($data);
     }
 

+ 16 - 3
plugin/saiadmin/basic/BaseLogic.php

@@ -6,6 +6,7 @@
 // +----------------------------------------------------------------------
 namespace plugin\saiadmin\basic;
 
+use plugin\saiadmin\app\cache\UserInfoCache;
 use plugin\saiadmin\exception\ApiException;
 use think\facade\Db;
 
@@ -203,13 +204,20 @@ class BaseLogic
 
         // 广告数据权限-自己以及下面组员
         if($authAdPermission==2){
-            // 如果没有传入负责人ID, 则取当前用户以及下面组员
-            $current_user_id = $this->adminInfo['id'];
+
+            // 根据用户id获取用户权限
+            $token = getCurrentInfo();
+            // 用户权限缓存
+            $userAuthCache = new UserInfoCache($token['id']);
+            $user_info = $userAuthCache->getUserInfo();
+            $current_user_id = $user_info['id'];
             $result = Db::connect('db_system')->table('sa_system_user')->field('dept_id')->where('id', $current_user_id)->select()->toArray();
             $dept_ids = array_column($result, 'dept_id');
             $under_user_ids = Db::connect('db_system')->table('sa_system_user')->field('id')->where('dept_id', 'in', $dept_ids)->select()->toArray();
             $under_user_ids = array_column($under_user_ids, 'id');
 
+           
+
             if(!empty($data['auth_id'])){
                // 如果传入了负责人ID,则取交集
                $data['auth_id'] = array_values(array_intersect( $data['auth_id'], array_values($under_user_ids)));
@@ -221,7 +229,12 @@ class BaseLogic
 
         // 广告数据权限-如果auth_id为空,则取当前用户
         if($authAdPermission==0){
-            $current_user_id = $this->adminInfo['id'];
+            // 根据用户id获取用户权限
+            $token = getCurrentInfo();
+            // 用户权限缓存
+            $userAuthCache = new UserInfoCache($token['id']);
+            $user_info = $userAuthCache->getUserInfo();
+            $current_user_id = $user_info['id'];
             if(!empty($data['auth_id'])){
                // 如果传入了负责人ID,则取交集
                $data['auth_id'] = array_values(array_intersect( $data['auth_id'], array_values($under_user_ids)));