123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\admin\server;
-
-
- use app\common\model\Auth;
- use app\common\model\RoleAuthIndex;
-
- class AuthServer
- {
-
-
-
- public static function getRoleNoneAuthIds($role_id)
- {
- if ($role_id == 0) {
- return [];
- }
- $role_auth = self::getRoleAuth($role_id);
- $all_auth = self::getAllAuth();
- return array_diff($all_auth, $role_auth);
- }
-
-
-
- public static function getRoleNoneAuthUris($role_id)
- {
- $ids = self::getRoleNoneAuthIds($role_id);
- $result = (new Auth())
- ->where('id', 'in', $ids)
- ->column('uri');
- $data = [];
- foreach ($result as $k => $v) {
- if (empty($v)) {
- continue;
- }
- $data[] = strtolower($v);
- }
- return $data;
- }
-
-
-
- private static function getRoleAuth($role_id)
- {
- return (new RoleAuthIndex())
- ->where(['role_id' => $role_id])
- ->column('menu_auth_id');
- }
-
-
-
- private static function getAllAuth()
- {
- return (new Auth())
- ->where(['del' => 0, 'disable' => 0])
- ->column('id');
- }
-
-
-
- public static function getRoleNoneAuthArr($role_id)
- {
- return (new Auth())
- ->where('id', 'in', self::getRoleNoneAuthIds($role_id))
- ->column('uri');
- }
-
-
- }
|