validate([ 'title' => ['nullable', 'string'], 'permission_name' => ['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() { // try { $params = request()->all(); $validator = [ 'keywords' => 'required|string|max:50', 'groups' => 'required|string|max:50', 'maxinum' => 'required|integer|min:1', 'mininum' => 'required|integer|min:0', 'odds' => 'required|numeric|min:0', ]; request()->validate($validator); $ret = GameplayRuleService::submit($params); if ($ret['code'] == GameplayRuleService::NOT) { return $this->error($ret['code'], $ret['msg']); } // } catch (ValidationException $e) { // return $this->error(HttpStatus::VALIDATION_FAILED, '', $e->errors()); // } catch (Exception $e) { // return $this->error(intval($e->getCode())); // } 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 = request()->post('id'); // 示例:通过 ID 删除菜单 $info = GameplayRuleService::findOne(['id' => $id]); if (!$info) { return $this->error(0, '角色不存在'); } $info->delete(); return $this->success([], '删除成功'); } }