Action.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use app\admin\logic\ActionLogic;
  5. use app\model\CommonModel;
  6. use think\exception\ValidateException;
  7. use think\facade\Config;
  8. use think\facade\Validate;
  9. //功能权限
  10. class Action extends BaseController
  11. {
  12. //获取权限列表
  13. public function List()
  14. {
  15. $menuid = $this->request->post('menuid', 0);
  16. return ActionLogic::List($menuid);
  17. }
  18. //添加权限
  19. public function Add()
  20. {
  21. $param = $this->request->only(['menuid', 'action_code', 'status' => CommonModel::$status_normal], 'post');
  22. $val = Validate::rule(Config::get('validate_rules.actionAdd'));
  23. if (!$val->check($param)) throw new ValidateException($val->getError());
  24. return ActionLogic::Add($param);
  25. }
  26. // //获取权限详情
  27. // public function Read()
  28. // {
  29. // $id = $this->request->post('id/d', 0);
  30. //
  31. // return ActionLogic::Read($id);
  32. // }
  33. //编辑权限
  34. public function Edit()
  35. {
  36. $param = $this->request->only(['id', 'action_code'], 'post');
  37. $val = Validate::rule([
  38. 'id' => 'require|number|gt:0',
  39. 'action_code|按钮编码' => 'require',
  40. ]);
  41. if (!$val->check($param)) throw new ValidateException($val->getError());
  42. return ActionLogic::Edit($param);
  43. }
  44. //删除权限
  45. public function Delete()
  46. {
  47. $id = $this->request->post('id/d', 0);
  48. return ActionLogic::Delete($id);
  49. }
  50. //启禁用权限
  51. public function Status()
  52. {
  53. $param = $this->request->only(['id', 'status'], 'post');
  54. $val = Validate::rule(Config::get('validate_rules.status'));
  55. if (!$val->check($param)) throw new ValidateException($val->getError());
  56. return ActionLogic::Status($param);
  57. }
  58. }