AuthorityService.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Services;
  3. use App\Authority;
  4. use App\Role;
  5. use Exception;
  6. use Illuminate\Support\Facades\Cache;
  7. use App\Traits\ServiceAppAop;
  8. class AuthorityService
  9. {
  10. use ServiceAppAop;
  11. // /**
  12. // * @return Authority[]
  13. // */
  14. // function getAll(){
  15. // $authorities = Cache::get('authorities');
  16. // if(!$authorities){
  17. // $authorities = Authority::with('roles')->get();
  18. // Cache::put('authorities', $authorities, config('cache.expirations.authorities'));
  19. // }
  20. // return $authorities;
  21. // }
  22. //
  23. // /**
  24. // * @param Authority $authority
  25. // * @return Role[]
  26. // * @throws Exception
  27. // */
  28. // function getRoles(Authority $authority){
  29. // if(!$authority['id']??'') throw new Exception('User对象或id不能为空');
  30. // $roles = Cache::get('authorityGetRoles'.$authority['id']);
  31. // if(!$roles){
  32. // $roles = Authority::with('roles')->get();
  33. // Cache::put('authorities', $roles, config('cache.expirations.authorities'));
  34. // }
  35. // return $roles;
  36. // }
  37. }