model = new Game(); $this->gameMainLogic = new GameMainLogic(); $this->systemDeptLogic = new SystemDeptLogic(); } /** * 获取游戏列表 * @param array $where * @return array */ public function getIndex($where) { $auth_game_list = request()->header('auth_game_list'); $query = $this->search($where); if(!empty($auth_game_list)) { $authGameList = explode(',', $auth_game_list); $query->where('id', 'in', $authGameList); } $query->order('sort', 'desc'); $data = $this->getList($query); $mainGameMap = $this->gameMainLogic->getMainGameMap(); foreach ($data['data'] as $key => $value) { $data['data'][$key]['main_game_name'] = $mainGameMap[$value['main_id']] ?? ''; } return $data; } /** * 获取游戏options列表(有权限) * @return array */ public function getGameOptions($where) { $auth_game_list = request()->header('auth_game_list'); $query = $this->search($where); if(!empty($auth_game_list)) { $authGameList = explode(',', $auth_game_list); $query->where('id', 'in', $authGameList); } $list = $query->select()->toArray(); return $list; } /** * 获取游戏options列表(无权限) * @return array */ public function getGameOptionsNoAuth($where) { $query = $this->search($where); $list = $query->select()->toArray(); return $list; } /** * 获取所有的游戏数据 */ public function getAllGameData($where) { $auth_game_list = request()->header('auth_game_list'); $query = $this->search($where); if(!empty($auth_game_list)) { $authGameList = explode(',', $auth_game_list); $query->where('id', 'in', $authGameList); } $query->where('status', 1); $query->order('sort', 'desc'); $game_list = $this->getList($query); $mainGameMap = $this->gameMainLogic->getMainGameMap(); $groupedGames = []; foreach ($game_list as $game) { $mainId = $game['main_id']; $groupedGames[$mainId]['id'] = 'main_id_'.$mainId; $groupedGames[$mainId]['name'] = $mainGameMap[$mainId] ?? $mainId; $groupedGames[$mainId]['children'][] = [ 'id' => $game['id'], 'name' => '【'.$game['id'].'】'.$game['name'] ]; } return array_values($groupedGames); } /** * 根据权限获取游戏列表 */ public function getGameListByPermission($where) { $auth_game_list = request()->header('auth_game_list'); $query = $this->search($where); if(!empty($auth_game_list)) { $authGameList = explode(',', $auth_game_list); $query->where('id', 'in', $authGameList); } $query->where('status', 1); $query->order('sort', 'desc'); return $query->select()->toArray(); } /** * 根据部门ID获取游戏列表 * @param array $where * @return array */ public function 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(); } $mainGameMap = $this->gameMainLogic->getMainGameMap(); $groupedGames = []; foreach ($game_list as $game) { $mainId = $game['main_id']; $groupedGames[$mainId]['id'] = 'main_id_'.$mainId; $groupedGames[$mainId]['name'] = $mainGameMap[$mainId] ?? $mainId; $groupedGames[$mainId]['children'][] = [ 'id' => $game['id'], 'name' => '【'.$game['id'].'】'.$game['name'] ]; } return array_values($groupedGames); } /** * 设置部门游戏权限 * @param array $where * @param array $game_list * @return void */ public function setGameListByDeptId($dept_id, $game_list) { $this->systemDeptLogic->setGameListByDeptId($dept_id, $game_list); } }