aiService = new AiService(); $this->noteService = new NoteService(); } /** * 发起 AI 总结 * POST /note/v1/ai/summary/:id */ public function summary(int $id) { try { $noteUserId = $this->getCurrentNoteUserId(); if ($id <= 0) { return Response::error('笔记 ID 不正确', 400); } $note = $this->noteService->getOwnedNote($noteUserId, $id); $data = $this->request->post(); $result = $this->aiService->createSummary( $note, (string) ($data['summary_type'] ?? 'brief'), !empty($data['force_refresh']) ); return Response::success($result, '总结生成成功'); } catch (\Throwable $e) { return Response::error($e->getMessage(), $e->getCode() ?: 500); } } /** * 查看 AI 总结结果 * GET /note/v1/ai/summary/:id */ public function readSummary(int $id) { try { $noteUserId = $this->getCurrentNoteUserId(); if ($id <= 0) { return Response::error('笔记 ID 不正确', 400); } $this->noteService->getOwnedNote($noteUserId, $id); $result = $this->aiService->getSummary($id); return Response::success($result); } catch (\Throwable $e) { return Response::error($e->getMessage(), $e->getCode() ?: 500); } } }