findByPk(Yii::app()->user->_id); $authIds = DB::getScalerWithCriteria( 'role', DbCriteria::simpleCompare(['id' => $model->role_id])->setSelect('auth_ids') ); self::$_authIds = $authIds ? explode(',', $authIds) : []; } if (in_array($num, self::$_authIds)) { return true; } return false; } public static function adminAuth($controller, $action) { // 跳过不需要检测的 if (in_array($controller, ["site", "common"])) { return true; } $page = strtolower($controller.'/'.$action); if (in_array($page, self::$noAuthCheckRouters)) { return true; } /** * @var array $pageAuth 权限集开始检测 权限ID 和 asyncRoutes.ts 保持一致 * @link ./web/src/router/routes/asyncRoutes.ts */ $pageAuth = [ // =================== 用户及角色管理 ======================= 'useradmin/rolelist' => 110200, // 角色列表 'useradmin/saveroleauth' => 110201, // 菜单权限 'useradmin/editrole' => 110202, // 编辑角色 'useradmin/deleterole' => 110203, // 删除角色 'useradmin/userlist' => 110100, // 用户列表 'useradmin/edituser' => 110101, // 编辑用户 'useradmin/deleteuser' => 110102, // 删除用户 // =================== 学校 ======================= 'school/list' => 120100, 'school/getselectlist' => 120100, 'school/info' => 120100, 'school/add' => 120101, 'school/edit' => 120102, 'school/updateattr' => 120102, 'school/delete' => 120103, // =================== 餐饮公司 ======================= 'company/list' => 120100, 'company/getselectlist' => 120100, 'company/info' => 120100, 'company/add' => 120101, 'company/edit' => 120102, 'company/updateattr' => 120102, 'company/delete' => 120103, // =================== 餐饮公司关系 ======================= 'companyrelation/list' => 120200, 'companyrelation/getselectlist' => 120200, 'companyrelation/info' => 120200, 'companyrelation/add' => 120201, 'companyrelation/edit' => 120202, 'companyrelation/updateattr' => 120202, 'companyrelation/delete' => 120203, // =================== 餐饮公司跟进 ======================= 'follow/companylist' => 120300, 'follow/companyall' => 120300, 'follow/companyinfo' => 120300, 'follow/companyadd' => 120301, ]; return !empty($pageAuth[$page]) && self::getAuth($pageAuth[$page]); } }