12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace app\admin\controller;
- use app\admin\logic\MenuLogic;
- use app\BaseController;
- use app\model\AdminMenuModel;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Validate;
- //【菜单】
- class Menu extends BaseController
- {
- //获取用户菜单列表
- public function list()
- {
- return MenuLogic::list();
- }
- //获取全部菜单
- public function all()
- {
- return MenuLogic::all();
- }
- //添加菜单
- public function add()
- {
- $param = $this->request->only([
- 'menu_name',
- 'menu_url' => '',
- 'menu_route' => '',
- 'menu_type' => AdminMenuModel::$type_1,
- 'menu_img' => '',
- 'pid' => 0,
- 'private' => '',
- 'weight' => '',
- ], 'post');
- $val = Validate::rule(Config::get('validate_rules.menuAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return MenuLogic::add($param);
- }
- //编辑菜单
- public function edit()
- {
- $param = $this->request->only([
- 'id',
- 'menu_name',
- 'menu_url' => '',
- 'menu_route' => '',
- 'menu_type' => '',
- 'menu_img' => '',
- 'pid' => 0,
- 'private' => '',
- 'weight' => '',
- ], 'post');
- $val = Validate::rule(Config::get('validate_rules.menuEdit'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return MenuLogic::edit($param);
- }
- //删除菜单
- public function delete()
- {
- $id = $this->request->post('id/d', 0);
- return MenuLogic::delete($id);
- }
- //启禁用菜单
- public function status()
- {
- $param = $this->request->only(['id', 'status'], 'post');
- $val = Validate::rule(Config::get('validate_rules.status'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return MenuLogic::status($param);
- }
- }
|