1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?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 menuList()
- {
- return MenuLogic::menuList();
- }
- //添加菜单
- public function menuAdd()
- {
- $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::menuAdd($param);
- }
- //编辑菜单
- public function menuEdit()
- {
- $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::menuEdit($param);
- }
- //删除菜单
- public function menuDel()
- {
- $id = $this->request->post('id/d', 0);
- return MenuLogic::menuDel($id);
- }
- //启禁用菜单
- public function menuStatus()
- {
- $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::menuStatus($param);
- }
- }
|