<?php


namespace App\Services;


use App\Authority;
use App\Role;
use Exception;
use Illuminate\Support\Facades\Cache;
use App\Traits\ServiceAppAop;


class AuthorityService
{
    use ServiceAppAop;
    protected $modelClass=Authority::class;
//    /**
//     * @return Authority[]
//     */
//    function getAll(){
//        $authorities = Cache::get('authorities');
//        if(!$authorities){
//            $authorities = Authority::with('roles')->get();
//            Cache::put('authorities', $authorities, config('cache.expirations.authorities'));
//        }
//        return $authorities;
//    }
//
//    /**
//     * @param Authority $authority
//     * @return Role[]
//     * @throws Exception
//     */
//    function getRoles(Authority $authority){
//        if(!$authority['id']??'') throw new Exception('User对象或id不能为空');
//        $roles = Cache::get('authorityGetRoles'.$authority['id']);
//        if(!$roles){
//            $roles = Authority::with('roles')->get();
//            Cache::put('authorities', $roles, config('cache.expirations.authorities'));
//        }
//        return $roles;
//    }
}
