| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Servers;
- use App\Models\Menu;
- /**
- * 权限验证
- */
- class PermissionServer
- {
- /**
- * 新版后台权限检查
- * @param $role_id
- * @param $clientRoute
- * @return bool
- */
- public static function verifyAuth($role_id, $clientRoute){
- $url_list = [
- 'common.total',
- 'common.sts',
- 'adminApi.shop.login_url',
- 'adminApi.user.get_menu',//前端登录后获取后台菜单权限id
- 'adminApi.statistics.count',//获取概览统计
- 'adminApi.statistics.curve',//获取曲线统计
- 'adminApi.statistics.pie_chart',//获取饼图统计
- 'adminApi.statistics.bar_chart',//获取柱状图统计
- 'adminApi.adopted.type',//认养类目
- ];
- if (in_array($clientRoute, $url_list)) {
- return true;
- }
- $where = [['url_name',$clientRoute]];
- $client_id = Menu::where($where)->value('id');
- if (empty($client_id)) {
- return false;
- }
- //获取该角色的权限节点
- $url_ids = MenuServer::creatServer()->getRole($role_id);
- if (empty($url_ids) || !in_array($client_id, $url_ids)) {
- return false;
- }
- return true;
- }
- }
|