refactor: 重构多飞书应用绑定架构和数据库清理
- 新增 user_feishu_apps 表支持用户绑定多个飞书应用 - users 表添加唯一约束(公司内邮箱/手机唯一) - 迁移现有飞书数据到 user_feishu_apps 表 - 清理冗余表(users_bak, user_feishu_binding) - 废弃 users 表中的 feishu_user_id/feishu_open_id/tenant_key 字段 - 更新 FeishuNotificationService 使用新的数据获取方式 - User 模型新增 getFeishuUserId() 等便捷方法 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,13 +18,18 @@ class TestController extends BaseController
|
||||
try {
|
||||
$notification = new FeishuNotificationService();
|
||||
|
||||
// 获取用户的company_id
|
||||
// 获取用户的company_id和feishu_app_id
|
||||
$user = \app\model\User::find($userId);
|
||||
if (!$user) {
|
||||
return $this->error('用户不存在');
|
||||
}
|
||||
|
||||
if (!$user->feishu_app_id) {
|
||||
return $this->error('用户未绑定飞书应用');
|
||||
}
|
||||
|
||||
$notification->setCompany($user->company_id);
|
||||
$notification->setApp($user->feishu_app_id);
|
||||
|
||||
// 发送测试消息
|
||||
$result = $notification->sendApprovalNotification([
|
||||
@@ -37,11 +42,15 @@ class TestController extends BaseController
|
||||
]);
|
||||
|
||||
if ($result) {
|
||||
// 获取用户在该应用下的feishu_user_id
|
||||
$feishuUserId = $user->getFeishuUserId($user->feishu_app_id);
|
||||
|
||||
return $this->success([
|
||||
'message' => '测试消息发送成功',
|
||||
'user_id' => $userId,
|
||||
'user_name' => $user->name,
|
||||
'feishu_user_id' => $user->feishu_user_id,
|
||||
'feishu_user_id' => $feishuUserId,
|
||||
'feishu_app_id' => $user->feishu_app_id,
|
||||
]);
|
||||
} else {
|
||||
return $this->error('测试消息发送失败,请查看日志');
|
||||
|
||||
Reference in New Issue
Block a user