validate([ 'group' => ['nullable', 'string'], 'keywords' => ['nullable', 'string'], ]); $search = request()->all(); $result = GameplayRuleService::paginate($search); } catch (ValidationException $e) { return $this->error(HttpStatus::VALIDATION_FAILED, '', $e->errors()); } catch (Exception $e) { return $this->error(intval($e->getCode())); } return $this->success($result); } /** * @api {post} /admin/role/submit 修改角色 * @apiGroup 玩法规则管理 * * @apiUse result * @apiUse header * @apiVersion 1.0.0 * * @apiParam {int} id 角色ID * @apiParam {string} display_name 角色名称(显示用) * @apiParam {string} description 角色描述 * @apiParam {array} [menus_ids] 角色菜单 */ public function store() { $params = request()->validate([ 'id' => 'nullable|integer|min:1', 'keywords' => 'required|string|max:50', 'groups' => 'required|string|max:50', 'maxinum' => 'required_without:id|integer|gte:mininum', 'mininum' => 'required_without:id|integer|min:0', 'odds' => ['required_without:id', 'regex:/^(?=.{1,10}$)\d{1,8}(\.\d{1,2})?$/'], ]); $ret = GameplayRuleService::submit($params); if ($ret['code'] == GameplayRuleService::NOT) { return $this->error($ret['code'], $ret['msg']); } return $this->success([], $ret['msg']); } /** * @api {post} /admin/role/delete 删除角色 * @apiGroup 玩法规则管理 * * @apiUse result * @apiUse header * @apiVersion 1.0.0 * * @apiParam {int} id 角色ID */ public function destroy() { ['id' => $id] = request()->validate(['id' => 'required|integer|min:1']); $keywords = DB::transaction(function () use ($id) { $templates = LotteryOdds::lockPc28Templates(); $info = GameplayRuleService::model()::whereKey($id)->lockForUpdate()->first(); if (!$info) { return null; } LotteryOdds::pc28CatalogChanged($templates, $info->id, deleted: true); $info->delete(); return $info->keywords; }, 3); if ($keywords === null) { return $this->error(0, '玩法不存在'); } GameplayRuleService::clearCache($keywords); return $this->success([], '删除成功'); } public function info() { $keywords = request()->get('keywords', '大'); $result = GameplayRuleService::getGameplayRules($keywords); return $this->success($result); } }