From 311e40760186e7109ec68898f573cabc5898fa3d Mon Sep 17 00:00:00 2001 From: "mzl@hnxinyouhe.com" Date: Thu, 14 Aug 2025 10:55:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=8E=88=E6=9D=83&=E8=B0=83=E6=95=B4=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/UserController.php | 4 ++-- app/common/utils/scaffold/Generate.php | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/admin/controller/UserController.php b/app/admin/controller/UserController.php index 10a8d57..a080444 100644 --- a/app/admin/controller/UserController.php +++ b/app/admin/controller/UserController.php @@ -76,7 +76,7 @@ class UserController extends BaseController public function authorize(Request $request) { try { - $data = $this->validate($this->service->getValidator(), $request->post(), 'authorize'); + $data = $request->post(); $res = $this->service->authorize($request, $data); return $this->success([], '分配成功'); } catch (\Throwable $e) { @@ -93,7 +93,7 @@ class UserController extends BaseController public function updateResources(Request $request) { try { - $data = $this->validate($this->service->getValidator(), $request->post(), 'updateResources'); + $data = $request->post(); $res = $this->service->updateResources($request, $data); return $this->success([], '分配成功'); } catch (\Throwable $e) { diff --git a/app/common/utils/scaffold/Generate.php b/app/common/utils/scaffold/Generate.php index 753a9cf..eb82025 100644 --- a/app/common/utils/scaffold/Generate.php +++ b/app/common/utils/scaffold/Generate.php @@ -156,8 +156,11 @@ class Generate protected function deleteFileIfExists($path) { if (file_exists($path)) { - unlink($path); - echo "删除已存在文件: {$path} \n"; + "文件: {$path} 已存在,核对后手动删除。\n"; + return; + + // unlink($path); + // echo "删除已存在文件: {$path} \n"; } } From 962f89189840e51a660e252edcf9f074d292a113 Mon Sep 17 00:00:00 2001 From: chenlan <18339827479@163.com> Date: Thu, 14 Aug 2025 11:06:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=9D=83=E9=99=90?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=9D=97=E5=84=BF=E6=B3=A8=E9=87=8A=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PermLogic.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/common/logic/PermLogic.php b/app/common/logic/PermLogic.php index d2e4505..808cb15 100644 --- a/app/common/logic/PermLogic.php +++ b/app/common/logic/PermLogic.php @@ -23,12 +23,16 @@ class PermLogic } $all = collect(); - - // 合并角色资源,排除不需要权限认证的资源 + // 遍历用户的所有角色,合并每个角色所拥有的资源 foreach ($user->roles as $role) { $all = $all->merge( + // 过滤当前角色的资源列表 $role->resources->filter(function ($resource) use($system) { - // 只保留需要权限认证的资源(或公共资源) + // 资源过滤条件: + // 1. !$resource->no_auth:资源需要权限认证(排除公共资源) + // 2. 系统匹配条件: + // - $system->id == $resource->system_id:资源属于当前系统 + // - $resource->system_id == 0:资源为全局公共资源(所有系统可用) return !$resource->no_auth && ($system->id == $resource->system_id || $resource->system_id == 0); }) );