AuthorityService.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. protected $modelClass=Authority::class;
  12. // /**
  13. // * @return Authority[]
  14. // */
  15. // function getAll(){
  16. // $authorities = Cache::get('authorities');
  17. // if(!$authorities){
  18. // $authorities = Authority::with('roles')->get();
  19. // Cache::put('authorities', $authorities, config('cache.expirations.authorities'));
  20. // }
  21. // return $authorities;
  22. // }
  23. //
  24. // /**
  25. // * @param Authority $authority
  26. // * @return Role[]
  27. // * @throws Exception
  28. // */
  29. // function getRoles(Authority $authority){
  30. // if(!$authority['id']??'') throw new Exception('User对象或id不能为空');
  31. // $roles = Cache::get('authorityGetRoles'.$authority['id']);
  32. // if(!$roles){
  33. // $roles = Authority::with('roles')->get();
  34. // Cache::put('authorities', $roles, config('cache.expirations.authorities'));
  35. // }
  36. // return $roles;
  37. // }
  38. }