AdminRoleAuthController.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace ghs\controllers;
  3. use bizHd\admin\services\AdminRoleAuthService;
  4. use bizHd\admin\services\AdminRoleService;
  5. use bizHd\admin\services\AdminService;
  6. use common\components\util;
  7. use Yii;
  8. class AdminRoleAuthController extends BaseController
  9. {
  10. //管理员角色权限 ssh 2020.1.23
  11. public function actionAuth()
  12. {
  13. $roleId = Yii::$app->request->get('roleId', 0);
  14. $role = AdminRoleService::getById($roleId);
  15. AdminRoleService::valid($role, $this->sjId);
  16. $roleAuth = AdminRoleAuthService::getByCondition(['roleId' => $roleId, 'endId' => 1]);
  17. $auth = isset($roleAuth['auth']) ? $roleAuth['auth'] : '';
  18. $ids = !empty($auth) ? explode(',', $auth) : [];
  19. util::success(['ids' => $ids]);
  20. }
  21. //权限更新 ssh 2020.1.23
  22. public function actionUpdate()
  23. {
  24. $roleId = Yii::$app->request->post('roleId', 0);
  25. $authIdList = Yii::$app->request->post('authIdList', ['*']);
  26. $auth = AdminRoleAuthService::getByCondition(['roleId' => $roleId, 'endId' => 1]);
  27. AdminRoleAuthService::valid($auth, $this->sjId);
  28. AdminRoleAuthService::updateByCondition(['roleId' => $roleId, 'endId' => 1], ['auth' => implode(',', $authIdList)]);
  29. util::complete();
  30. }
  31. }