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, // =================== 学校关系 ======================= 'schoolrelation/list' => 120200, 'schoolrelation/getselectlist' => 120200, 'schoolrelation/info' => 120200, 'schoolrelation/add' => 120201, 'schoolrelation/edit' => 120202, 'schoolrelation/updateattr' => 120202, 'schoolrelation/delete' => 120203, // =================== 学校跟进 ======================= 'follow/schoollist' => 120300, 'follow/schoolall' => 120300, 'follow/schoolinfo' => 120300, 'follow/schooladd' => 120301, // =================== 食堂 ======================= 'canteen/list' => 130100, 'canteen/getselectlist' => 130100, 'canteen/info' => 130100, 'canteen/add' => 130101, 'canteen/edit' => 130102, 'canteen/updateattr' => 130102, 'canteen/delete' => 130103, // =================== 食堂跟进 ======================= 'follow/canteenlist' => 130300, 'follow/canteenall' => 130300, 'follow/canteeninfo' => 130300, 'follow/canteenadd' => 130301, ]; return !empty($pageAuth[$page]) && self::getAuth($pageAuth[$page]); } }