Ver código fonte

用户管理
1. 游戏数据权限
2. 游戏自然量权限
3. 广告数据权限

ith5 6 meses atrás
pai
commit
b20490d2cc

+ 23 - 18
app/v1/logic/center/GameLogic.php

@@ -62,14 +62,15 @@ class GameLogic extends BaseLogic
         }, $list);
         return $list;
     }
-
+    
     /**
-     * 处理游戏tree数据
-     * @return array
+     * 获取所有的游戏数据
      */
-    public function getGameTree($game_list)
+    public function getAllGameData()
     {
-         $mainGameMap = $this->gameMainLogic->getMainGameMap();
+        $game_list = $this->model->where('status', 1)->order('sort', 'desc')->select()->toArray();
+
+        $mainGameMap = $this->gameMainLogic->getMainGameMap();
         
          $groupedGames = [];
          foreach ($game_list as $game) {
@@ -81,17 +82,7 @@ class GameLogic extends BaseLogic
                 'name' => $game['name']
             ];
          }
-        $game_list = array_values($groupedGames);
-        return $game_list;
-    }
-
-    /**
-     * 获取所有的游戏数据
-     */
-    public function getAllGameData()
-    {
-        $game_list = $this->model->where('status', 1)->order('sort', 'desc')->select()->toArray();
-        return $this->getGameTree($game_list);
+        return array_values($groupedGames);
     }
 
     /**
@@ -100,14 +91,28 @@ class GameLogic extends BaseLogic
      * @return array
      */
     public function getGameListByDeptId($dept_id)
+    
     {
-        $game_ids = $this->systemDeptLogic->getGameListByDeptId($dept_id);
+        $game_ids = $this->systemDeptLogic->getGameIdsByDeptId($dept_id);
+        $game_list = [];
         if($game_ids==='*'){
             $game_list = $this->model->where('status', 1)->order('sort', 'desc')->select()->toArray();
         }else{
             $game_list = $this->model->where('id', 'in', $game_ids)->where('status', 1)->order('sort', 'desc')->select()->toArray();
         }
-        return $game_list;
+        $mainGameMap = $this->gameMainLogic->getMainGameMap();
+        
+         $groupedGames = [];
+         foreach ($game_list as $game) {
+            $mainId = $game['main_id'];
+            $groupedGames[$mainId]['id'] = $mainId;
+            $groupedGames[$mainId]['name'] = $mainGameMap[$mainId] ?? $mainId;
+            $groupedGames[$mainId]['children'][] = [
+                'id' => $game['id'],
+                'name' => $game['name']
+            ];
+         }
+        return array_values($groupedGames);
     }
 
     /**

+ 28 - 0
plugin/saiadmin/app/controller/system/SystemUserController.php

@@ -167,4 +167,32 @@ class SystemUserController extends BaseController
         $userAuthCache->clearUserCache();
         return $this->success('操作成功');
     }
+
+    /**
+     * 设置用户权限
+     * @param Request $request
+     * @return Response
+     */
+    public function setUserPermission(Request $request) : Response
+    {
+        $id = $request->post('id');
+        $game_list = $request->post('game_list');
+        $normal_game_list = $request->post('normal_game_list');
+        $ad_permission = $request->post('ad_permission');
+        if ($game_list) {
+            $data['game_list'] = $game_list;
+        }
+        if ($normal_game_list) {
+            $data['normal_game_list'] = $normal_game_list;
+        }
+        if ($ad_permission) {
+            $data['ad_permission'] = $ad_permission;
+        }
+        $this->logic->authEdit($id, $data);
+        $userInfoCache = new UserInfoCache($id);
+        $userInfoCache->clearUserInfo();
+        $userAuthCache = new UserAuthCache($id);
+        $userAuthCache->clearUserCache();
+        return $this->success('操作成功');
+    }
 }

+ 11 - 5
plugin/saiadmin/app/logic/system/SystemDeptLogic.php

@@ -19,12 +19,16 @@ use plugin\saiadmin\utils\Arr;
  */
 class SystemDeptLogic extends BaseLogic
 {
+
+    // protected $gameLogic;
+
     /**
      * 构造函数
      */
     public function __construct()
     {
         $this->model = new SystemDept();
+        // $this->gameLogic = new GameLogic();
     }
 
     /**
@@ -169,16 +173,16 @@ class SystemDeptLogic extends BaseLogic
         $model->leader()->detach($ids);
     }
 
+
     /**
-     * 根据部门ID获取游戏列表
+     * 根据部门ID获取游戏ID
      */
-    public function getGameListByDeptId($where)
+    public function getGameIdsByDeptId($dept_id)
     {
-        $dept_id = $where['dept_id'];
         $query = $this->model->field('game_list')->where('id', $dept_id);
         $data = $query->find();
-        
-        return $data->game_list;
+        $game_ids = $data->game_list;
+        return $game_ids;
     }
 
     /**
@@ -192,4 +196,6 @@ class SystemDeptLogic extends BaseLogic
         }
         return $result;
     }
+
+
 }

+ 1 - 0
plugin/saiadmin/config/route.php

@@ -35,6 +35,7 @@ Route::group('/core', function () {
     Route::post("/user/clearCache",[\plugin\saiadmin\app\controller\system\SystemUserController::class, 'clearCache']);
     Route::post("/user/initUserPassword",[\plugin\saiadmin\app\controller\system\SystemUserController::class, 'initUserPassword']);
     Route::post("/user/setHomePage",[\plugin\saiadmin\app\controller\system\SystemUserController::class, 'setHomePage']);
+    Route::post("/user/setUserPermission",[\plugin\saiadmin\app\controller\system\SystemUserController::class, 'setUserPermission']);
 
     // 角色管理
     fastRoute('role',\plugin\saiadmin\app\controller\system\SystemRoleController::class);