AuthService.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace bizHd\auth\services;
  3. use bizHd\base\services\BaseService;
  4. use common\components\tree;
  5. use Yii;
  6. class AuthService extends BaseService
  7. {
  8. public static $baseFile = '\bizHd\auth\classes\AuthClass';
  9. //获取指定业务端的权限列表 ssh 2019.11.24
  10. public static function getEndAuth($endId)
  11. {
  12. return self::getAllByCondition(['endId' => $endId], null, '*');
  13. }
  14. //某业务端的权限id ssh 2019.11.25
  15. public static function getListId($endId)
  16. {
  17. $list = self::getEndAuth($endId);
  18. $ids = empty($list) ? [] : array_column($list,'id');
  19. return $ids;
  20. }
  21. //获取指定业务端的权限树
  22. public static function getTree($endId)
  23. {
  24. $data = self::getEndAuth($endId);
  25. if(empty($data)){
  26. return [];
  27. }
  28. $tree = tree::makeTree($data, ['primary_key' => 'id', 'parent_key' => 'parentId', 'children_key' => 'children',]);
  29. return $tree;
  30. }
  31. //获取业务端所有权限名称 ssh 2019.11.24
  32. public static function getNameList($endId)
  33. {
  34. $list = self::getEndAuth($endId);
  35. $arr = !empty($list) ? array_column($list, 'authName') : [];
  36. return $arr;
  37. }
  38. }