AuthController.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace platform\controllers;
  3. use biz\auth\services\AuthService;
  4. use common\components\util;
  5. use Yii;
  6. class AuthController extends BaseController
  7. {
  8. public $enableCsrfValidation = false;
  9. //获取权限树 shish 2019.11.24
  10. public function actionTree()
  11. {
  12. $get = Yii::$app->request->get();
  13. $endId = isset($get['endId']) ? $get['endId'] : 1;
  14. $tree = AuthService::getTree($endId);
  15. util::success($tree);
  16. }
  17. //添加权限 shish 2019.11.24
  18. public function actionAdd()
  19. {
  20. $post = Yii::$app->request->post();
  21. $endId = isset($post['endId']) ? $post['endId'] : 1;
  22. $authName = isset($post['authName']) ? $post['authName'] : '';
  23. $list = AuthService::getNameList($endId);
  24. if (in_array($authName, $list)) {
  25. util::fail('名称已经存在');
  26. }
  27. AuthService::add($_POST);
  28. util::ok();
  29. }
  30. public function actionModify()
  31. {
  32. $post = Yii::$app->request->post();
  33. $endId = isset($post['endId']) ? $post['endId'] : 1;
  34. $authName = isset($post['authName']) ? $post['authName'] : '';
  35. $list = AuthService::getNameList($endId);
  36. if (in_array($authName, $list)) {
  37. util::fail('名称已经存在');
  38. }
  39. AuthService::add($_POST);
  40. util::ok();
  41. }
  42. }