123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use app\admin\logic\ActionLogic;
- use app\model\CommonModel;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Validate;
- //功能权限
- class Action extends BaseController
- {
- //获取权限列表
- public function List()
- {
- $menuid = $this->request->post('menuid', 0);
- return ActionLogic::List($menuid);
- }
- //添加权限
- public function Add()
- {
- $param = $this->request->only(['menuid', 'action_code', 'status' => CommonModel::$status_normal], 'post');
- $val = Validate::rule(Config::get('validate_rules.actionAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return ActionLogic::Add($param);
- }
- // //获取权限详情
- // public function Read()
- // {
- // $id = $this->request->post('id/d', 0);
- //
- // return ActionLogic::Read($id);
- // }
- //编辑权限
- public function Edit()
- {
- $param = $this->request->only(['id', 'action_code'], 'post');
- $val = Validate::rule([
- 'id' => 'require|number|gt:0',
- 'action_code|按钮编码' => 'require',
- ]);
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return ActionLogic::Edit($param);
- }
- //删除权限
- public function Delete()
- {
- $id = $this->request->post('id/d', 0);
- return ActionLogic::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 ActionLogic::Status($param);
- }
- }
|