Action.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. return ActionLogic::Read($id);
  31. }
  32. //编辑权限
  33. public function Edit()
  34. {
  35. $param = $this->request->only([''], 'post');
  36. $val = Validate::rule(Config::get('validate_rules.'));
  37. if (!$val->check($param)) throw new ValidateException($val->getError());
  38. return ActionLogic::Edit($param);
  39. }
  40. //删除权限
  41. public function Delete()
  42. {
  43. $param = $this->request->only([''], 'post');
  44. $val = Validate::rule(Config::get('validate_rules.'));
  45. if (!$val->check($param)) throw new ValidateException($val->getError());
  46. return ActionLogic::Delete($param);
  47. }
  48. //启禁用权限
  49. public function Status()
  50. {
  51. $param = $this->request->only(['id','status'], 'post');
  52. $val = Validate::rule(Config::get('validate_rules.status'));
  53. if (!$val->check($param)) throw new ValidateException($val->getError());
  54. return ActionLogic::Status($param);
  55. }
  56. }