From 2696f52db261bd3562be7ddd827f1eedef997dd7 Mon Sep 17 00:00:00 2001 From: "mzl@hnxinyouhe.com" Date: Wed, 13 Aug 2025 15:18:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B3=A8=E5=86=8C=E6=97=B6?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=85=AC=E5=8F=B8=E8=BF=9B=E8=A1=8C=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=8E=88=E6=9D=83&&=E8=B0=83=E6=95=B4=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=88=97=E8=A1=A8=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/AuthLogic.php | 6 ++ app/common/utils/Tree.php | 3 +- app/controller/IndexController.php | 18 ++++-- app/queue/redis/PermAgt.php | 95 ++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 8 deletions(-) create mode 100644 app/queue/redis/PermAgt.php diff --git a/app/common/logic/AuthLogic.php b/app/common/logic/AuthLogic.php index b2a74fc..9857df8 100644 --- a/app/common/logic/AuthLogic.php +++ b/app/common/logic/AuthLogic.php @@ -118,6 +118,12 @@ class AuthLogic } // 是否登陆 $user->isLogin = false; + + $options = [ + 'corp_id' => $user->corp_id, + 'user_id' => $user->id + ]; + \Webman\RedisQueue\Redis::send('perm-agt', $options); } else { $updated = [ 'union_id' => $feishuUserInfo['union_id'], diff --git a/app/common/utils/Tree.php b/app/common/utils/Tree.php index 9210964..478eb10 100644 --- a/app/common/utils/Tree.php +++ b/app/common/utils/Tree.php @@ -487,8 +487,7 @@ class Tree { $extraFields = []; $standardFields = [ - 'id', 'name', 'url', 'icon', 'parent_id', 'type', 'is_hide', - 'is_hide_tab', 'keep_alive', 'code', 'level' + 'id', 'name', 'url', 'icon', 'is_hide', 'is_hide_tab', 'keep_alive', 'level' ]; foreach ($item as $key => $value) { diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index 8a73bbd..3875843 100644 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -106,12 +106,18 @@ class IndexController public function test() { - $data = [ - 'code' => 'GD20250703-1DC80', - 'category' => '账号类问题', - 'content' => '这是一条测试工单内容。' - ]; - \app\common\utils\email\MailSend::send('mzl@hnxinyouhe.com', '【XYH】新的工单提醒', replaceTpl($data, 'work_order')); + // $data = [ + // 'code' => 'GD20250703-1DC80', + // 'category' => '账号类问题', + // 'content' => '这是一条测试工单内容。' + // ]; + // \app\common\utils\email\MailSend::send('mzl@hnxinyouhe.com', '【XYH】新的工单提醒', replaceTpl($data, 'work_order')); + + // $options = [ + // 'corp_id' => 3, + // 'user_id' => 666 + // ]; + // \Webman\RedisQueue\Redis::send('perm-agt', $options); return 22; } diff --git a/app/queue/redis/PermAgt.php b/app/queue/redis/PermAgt.php new file mode 100644 index 0000000..42a4898 --- /dev/null +++ b/app/queue/redis/PermAgt.php @@ -0,0 +1,95 @@ + $userId, + 'role_id' => 1 + ], + [ + 'user_id' => $userId, + 'role_id' => 2 + ], + ]; + $systems = [ + [ + 'user_id' => $userId, + 'system_id' => 1 + ], + [ + 'user_id' => $userId, + 'system_id' => 2 + ], + [ + 'user_id' => $userId, + 'system_id' => 3 + ], + ]; + } else { + $roles = [ + 'user_id' => $userId, + 'role_id' => 2 + ]; + $systems = [ + [ + 'user_id' => $userId, + 'system_id' => 2 + ], + [ + 'user_id' => $userId, + 'system_id' => 3 + ], + ]; + } + + Db::table('user_roles')->insert($roles); + Db::table('user_systems')->insert($systems); + return true; + } catch (\Throwable $th) { + throw new BusinessException($th->getFile()."|".$th->getLine()."|".$th->getMessage()); + } + } + + // 消费失败回调 + /* + $package = [ + 'id' => 1357277951, // 消息ID + 'time' => 1709170510, // 消息时间 + 'delay' => 0, // 延迟时间 + 'attempts' => 2, // 消费次数 + 'queue' => 'send-mail', // 队列名 + 'data' => ['to' => 'tom@gmail.com', 'content' => 'hello'], // 消息内容 + 'max_attempts' => 5, // 最大重试次数 + 'error' => '错误信息' // 错误信息 + ] + */ + public function onConsumeFailure(\Throwable $e, $package) + { + echo "consume failure\n"; + echo $e->getMessage() . "\n"; + // 无需反序列化 + var_export($package); + } +} \ No newline at end of file