logic = new GameLogic(); $this->validate = new GameValidate; $this->systemDeptLogic = new SystemDeptLogic(); parent::__construct(); } /** * 数据列表 * @param Request $request * @return Response */ public function index(Request $request): Response { $where = $request->more([ ['id', ''], ['main_id', ''], ['name', ''], ['os', ''], ['status', ''], ]); $list = $this->logic->getIndex($where); return $this->success($list); } /** * 添加游戏 */ public function addGame(Request $request): Response { $data = $request->post(); $cp_callback_type = $data['cp_callback_type']; if($cp_callback_type == 1){ // 读取主游戏的KEY if(!$data['main_game_id']){ return $this->fail('请选择主游戏'); } $main_game_info = $this->logic->read($data['main_game_id']); $data['appkey'] = $main_game_info['appkey']; $data['login_key'] = $main_game_info['login_key']; $data['pay_key'] = $main_game_info['pay_key']; }else{ // 生成新的KEY $data['appkey'] = md5('appkey'.uniqid()); $data['login_key'] = md5('login_key'.uniqid()); $data['pay_key'] = md5('pay_key'.uniqid()); } $this->logic->add($data); return $this->success(); } /** * 更新游戏 */ public function updateGame(Request $request, $id): Response { $data = $request->post(); // 如果主游戏ID改变,则获取主游戏KEY if($data['main_game_id']){ $game_info = $this->logic->read($data['main_game_id']); $data['appkey'] = $game_info['appkey']; $data['login_key'] = $game_info['login_key']; $data['pay_key'] = $game_info['pay_key']; }else{ // 如果主游戏ID为空,则生成新的KEY $data['appkey'] = md5('appkey'.uniqid()); $data['login_key'] = md5('login_key'.uniqid()); $data['pay_key'] = md5('pay_key'.uniqid()); } $this->logic->edit($id, $data); return $this->success(); } /** * 获取所有的游戏数据 */ public function getAllGameData(Request $request): Response { $list = $this->logic->getAllGameData(); return $this->success($list); } /** * 根据部门ID获取游戏列表 */ public function getGameListByDeptId(Request $request): Response { $dept_id = $request->get('dept_id'); $game_list = $this->logic->getGameListByDeptId($dept_id); return $this->success($game_list); } /** * 设置部门游戏权限 */ public function setGameListByDeptId(Request $request): Response { $game_list = $request->post('game_list'); $dept_id = $request->post('dept_id'); $this->logic->setGameListByDeptId($dept_id, $game_list); return $this->success(); } }