diff --git a/backend/app/controller/AuthController.php b/backend/app/controller/AuthController.php index 7e4b89d..79b6f7f 100644 --- a/backend/app/controller/AuthController.php +++ b/backend/app/controller/AuthController.php @@ -560,4 +560,47 @@ HTML; return $this->error($e->getMessage()); } } + + /** + * 获取飞书配置(用于前端免登) + * 根据 company 参数返回对应的 appId + */ + public function feishuConfig(Request $request): Response + { + $companyParam = $request->get('company'); + + if (!$companyParam) { + return $this->error('缺少 company 参数'); + } + + try { + // company 参数是 company_id + $company = \app\model\Company::find($companyParam); + if (!$company) { + return $this->error('公司不存在'); + } + + $companyId = $company->id; + + // 获取该公司的默认飞书应用 + $feishuApp = \app\model\CompanyFeishuApp::where('company_id', $companyId) + ->where('system_id', 1) + ->where('status', 1) + ->first(); + + if (!$feishuApp) { + return $this->error('该公司未配置飞书应用'); + } + + error_log("✅ feishuConfig - company_id={$companyId}, app_id={$feishuApp->app_id}"); + + return $this->success([ + 'app_id' => $feishuApp->app_id, + 'company_id' => $companyId, + ]); + } catch (\Exception $e) { + error_log("❌ feishuConfig 失败: " . $e->getMessage()); + return $this->error($e->getMessage()); + } + } } diff --git a/backend/config/route.php b/backend/config/route.php index ac648d2..593397c 100644 --- a/backend/config/route.php +++ b/backend/config/route.php @@ -12,6 +12,7 @@ Route::group('/api/v1', function () { Route::post('/auth/feishu-login', [app\controller\AuthController::class, 'feishuLogin']); Route::post('/auth/qrcode-login', [app\controller\AuthController::class, 'qrcodeLogin']); Route::get('/auth/qrcode-login/status', [app\controller\AuthController::class, 'qrcodeLoginStatus']); + Route::get('/auth/feishu-config', [app\controller\AuthController::class, 'feishuConfig']); // 测试接口 Route::get('/test/notification', [app\controller\TestController::class, 'notification']); diff --git a/frontend/index.html b/frontend/index.html index fbd9950..96e9f3e 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,50 +4,11 @@ -
用于诊断飞书免登问题
+ + {/* 操作按钮 */} +请选择登录方式