1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\shop\server;
-
- use app\common\model\shop\ShopAuth;
- use app\common\model\shop\ShopRoleAuthIndex;
-
- 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 = ShopAuth::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 ShopRoleAuthIndex::where(['role_id' => $role_id])
- ->column('menu_auth_id');
- }
-
-
-
- private static function getAllAuth()
- {
- return ShopAuth::where(['del' => 0, 'disable' => 0])
- ->column('id');
- }
-
-
-
- public static function getRoleNoneAuthArr($role_id)
- {
- return ShopAuth::where('id', 'in', self::getRoleNoneAuthIds($role_id))
- ->column('uri');
- }
- }
|