diff --git a/catch/permissions/model/DataRangScopeTrait.php b/catch/permissions/model/DataRangScopeTrait.php index f308344..e5a480b 100644 --- a/catch/permissions/model/DataRangScopeTrait.php +++ b/catch/permissions/model/DataRangScopeTrait.php @@ -1,6 +1,8 @@ whereIn($this->aliasField('creator_id'), $this->getDepartmentUserIdsBy($roles)); + if (Utils::isSuperAdmin()) { + return $this; + } + + $userIds = $this->getDepartmentUserIdsBy($roles); + + if (empty($userIds)) { + return $this; + } + + return $this->whereIn($this->aliasField('creator_id'), $userIds); } /** diff --git a/extend/catcher/Utils.php b/extend/catcher/Utils.php index f04b06b..9131e98 100644 --- a/extend/catcher/Utils.php +++ b/extend/catcher/Utils.php @@ -118,4 +118,15 @@ class Utils { return \config('database.connections.mysql.prefix'); } + + /** + * 是否是超级管理员 + * + * @time 2020年07月04日 + * @return bool + */ + public static function isSuperAdmin() + { + return request()->user()->id == config('catch.permissions.super_admin_id'); + } }