model = new \app\api\model\Menu(); } /** * @OA\Get ( * path="menu/index",tags={"权限菜单"},summary="获取菜单列表",description="根据相关参数获取菜单列表", * @OA\Parameter(ref="#/components/parameters/token"), * @OA\Parameter(name="path",in="query",description="前端权限路由",@OA\Schema (type="string")), * @OA\Parameter(name="name",in="query",description="权限菜单名称",@OA\Schema (type="string")), * @OA\Parameter (name="page",in="query",description="当前页码",@OA\Schema (type="integer",format="int15")), * @OA\Parameter (name="limit",in="query",description="分页数量",@OA\Schema (type="integer",format="int15")), * @OA\Response( * response=200, * description="返回权限菜单菜单数据信息", * @OA\JsonContent(ref="#/components/schemas/MenuMsgExport"), * ), * ) */ public function index() { //接受参数 $_get = $this->request->param(); //指定搜索参数 $this->model->search_arr = ['path', 'name']; //验证参数 validate(\app\api\validate\Menu::class)->scene('lists')->check($_get); $_data = $this->model->index(); //数据处理 前台处理 // $_data['data'] = get_tree($_data['data'], 0, 'children'); //返回数据 return send_http_status($_data); } /** * @OA\Post (path="menu/add",tags={"权限菜单"},summary="添加权限菜单数据",description="添加后台权限菜单数据", * @OA\Parameter(ref="#/components/parameters/token"), * @OA\RequestBody( * @OA\MediaType(mediaType="application/json", * @OA\Schema(ref="#/components/schemas/MenuField"), * ), * ), * @OA\Response( * response=200, * description="添加成功", * @OA\JsonContent(type="object", * @OA\Property(property="code", type="integer",format="int32",description="状态码"), * @OA\Property(property="msg", type="string",description="提示信息"), * @OA\Property(property="count", type="integer",format="int32",description="记录总数"), * @OA\Property(property="data", type="integer",format="int32",description="添加成功的的数据ID"), * ), * ), * ) * @Log [sys_name] 在 [sys_time] 创建了权限菜单:[name] */ public function add() { //接收参数 $_post = $this->request->post(); //验证参数 validate(\app\api\validate\Menu::class)->check($_post); //处理并返回参数 $insertId = $this->model->parentAdd($_post); return send_http_status($insertId, $insertId ? 201 : 202); } /** * @OA\Get ( * path="menu/read/id/{id}",tags={"权限菜单"},summary="获取菜单详情",description="根据ID查询菜单信息", * @OA\Parameter(ref="#/components/parameters/token"), * @OA\Parameter(name="id",in="path",required=true,description="ID",@OA\Schema (type="integer",format="int32")), * @OA\Response( * response=200, * description="返回权限菜单菜单数据信息", * @OA\JsonContent(ref="#/components/schemas/MenuMsgExport"), * ), * ) */ public function read($id = '') { //验证参数 validate(\app\api\validate\Menu::class)->scene('read')->check(['id' => $id]); //返回数据 return send_http_status($this->model->parentRead($id)); } /** * @OA\Post (path="menu/edit/id/{id}",tags={"权限菜单"},summary="修改菜单数据",description="修改权限菜单数据", * @OA\Parameter(ref="#/components/parameters/token"), * @OA\RequestBody( * @OA\MediaType(mediaType="application/json", * @OA\Schema(ref="#/components/schemas/MenuField"), * ), * ), * @OA\Response( * response=200, * description="修改数据状态", * @OA\JsonContent(type="object", * @OA\Property(property="code", type="integer",format="int32",description="状态码"), * @OA\Property(property="msg", type="string",description="提示信息"), * @OA\Property(property="count", type="integer",format="int32",description="记录数"), * @OA\Property(property="data", type="string",description="不返回"), * ), * ), * ) * @Log [sys_name]在[sys_time] 修改了权限菜单[name]的数据 */ public function edit($id = 0) { //接收参数 $_post = $this->request->post(); $_post['id'] = $id; //安全赋值,以免客户端没传id,修改需要id字段 //验证参数 validate(\app\api\validate\Menu::class)->scene('update')->check($_post); //处理并返回数据 return send_http_status('', $this->model->parentEdit($_post, $id) ? 203 : 204); } /** * @OA\Post ( * path="menu/delete",tags={"权限菜单"},summary="删除菜单数据",description="根据ID删除菜单数据", * @OA\Parameter(ref="#/components/parameters/token"), * @OA\RequestBody( * @OA\MediaType(mediaType="application/json", * @OA\Schema ( * required={"id"}, * @OA\Property(property="id",type="string",description="数据ID或数据ID集合 id=1或 id=1,2,8"), * ), * ), * ), * @OA\Response( * response=200, * description="删除数据状态", * @OA\JsonContent(type="object", * @OA\Property(property="code", type="integer",format="int32",description="状态码"), * @OA\Property(property="msg", type="string",description="提示信息"), * @OA\Property(property="count", type="integer",format="int32",description="记录数"), * @OA\Property(property="data", type="string",description="不返回"), * ), * ), * ) * @Log [sys_name] 在 [sys_time] 删除了权限菜单:[name] */ public function delete() { //接收参数 $ids = $this->request->param('id'); //验证参数 validate(['ids|id' => 'require|length:1,100'])->check(['ids' => $ids]); //处理并返回数据 return send_http_status('', $this->model->parentDel($ids) ? 205 : 206); } /** * @OA\Post ( * path="menu/status",tags={"权限菜单"},summary="更新菜单状态",description="根据ID及status更新菜单状态", * @OA\Parameter(ref="#/components/parameters/token"), * @OA\RequestBody( * @OA\MediaType(mediaType="application/json", * @OA\Schema ( * required={"id","status"}, * @OA\Property(property="id",type="string",description="数据ID或数据ID集合 id=1或 id=1,2,8"), * @OA\Property(property="status",type="integer",format="int15",description="数据状态 0禁用 1启用"), * ), * ), * ), * @OA\Response( * response=200, * description="删除数据状态", * @OA\JsonContent(type="object", * @OA\Property(property="code", type="integer",format="int32",description="状态码"), * @OA\Property(property="msg", type="string",description="提示信息"), * @OA\Property(property="count", type="integer",format="int32",description="记录数"), * @OA\Property(property="data", type="string",description="不返回"), * ), * ), * ) * @Log [sys_name] 在 [sys_time] [dictionary_status]了权限菜单:[name] */ public function status() { //接收参数 $ids = $this->request->param('id'); $status = $this->request->param('status'); //验证参数 $_rules = [ 'ids|id' => 'require|length:1,100', 'status|状态值' => 'require|number|length:1', ]; validate($_rules)->check(['ids' => $ids, 'status' => $status]); //处理并返回数据 return send_http_status('', $this->model->parentStatus($ids, $status) !== false ? 207 : 208); } }