1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?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_code' => '',
- '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_code' => '',
- 'menu_img' => '',
- 'pid' => 0,
- 'private' => '',
- 'weight' => '',
- 'is_show' => AdminMenuModel::$show
- ], '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);
- }
- }
|