From 3d6c0b4a41f4c0569f885e640ac26bfd42e70bdc Mon Sep 17 00:00:00 2001 From: Caihaohan Date: Tue, 27 Jan 2026 19:30:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E8=AF=8D=E8=AF=8D=E4=BA=91=E7=B3=BB=E7=BB=9F=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prisma/schema.prisma | 94 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 2ed8aa0..7b9fa2d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -144,3 +144,97 @@ model ProjectDiscoveryTask { @@index([projectId], map: "idx_task_project_id") @@map("project_discovery_tasks") } + +// ================================ +// Keyword Cloud System Models +// ================================ + +// 季度元数据表 +model Quarter { + id Int @id @default(autoincrement()) + quarter String @unique // "2023-Q1", "2023-Q2" + title String @db.Text // "2023年第一季度" + titleEn String? @db.Text // "Q1 2023" + subtitle String? @db.Text // "聊天界面的黎明" + subtitleEn String? @db.Text // "The dawn of chat interface" + displayOrder Int @default(0) // 前端排序 + isActive Boolean @default(true) // 是否显示 + keywords Keyword[] + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + @@index([quarter], map: "idx_quarter_quarter") + @@index([displayOrder], map: "idx_quarter_displayOrder") + @@map("quarters") +} + +// 关键词核心数据表 +model Keyword { + id Int @id @default(autoincrement()) + word String // "ChatGPT" + trendScore Int // 0-100, 从 Google Trends 获取 + + // 外键关联 + quarterId Int + quarter Quarter @relation(fields: [quarterId], references: [id], onDelete: Cascade) + + // 内容字段(支持中英双语) + description String @db.Text // AI 生成的一句话描述 + descriptionEn String? @db.Text // 英文描述 + detailPoints Json // JSON 数组: ["要点1", "要点2", "要点3"] + detailPointsEn Json? // 英文版要点 + + // 视觉样式配置 + visualConfig Json // {color, size, rotation, border} + + // 元数据 + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + @@index([quarterId], map: "idx_keyword_quarterId") + @@index([trendScore], map: "idx_keyword_trendScore") + @@index([word], map: "idx_keyword_word") + @@map("keywords") +} + +// 视觉样式规则配置表 +model VisualStyleRule { + id Int @id @default(autoincrement()) + name String @unique // "热门大词-金色" + + // 分数区间 + minScore Int // 90 + maxScore Int // 100 + + // 视觉属性 + color String // "primary", "secondary", "accent" + size String // "text-5xl", "text-3xl", "text-xl" + border String // "border-4", "border-2" + rotation String? // "rotate-1", "rotate-2", null + + // 控制 + priority Int @default(0) // 优先级,分数重叠时按优先级 + enabled Boolean @default(true) // 是否启用 + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + @@index([enabled], map: "idx_visualStyleRule_enabled") + @@index([minScore, maxScore], map: "idx_visualStyleRule_scoreRange") + @@map("visual_style_rules") +} + +// 错误日志表 +model KeywordCloudErrorLog { + id Int @id @default(autoincrement()) + quarter String // "2023-Q1" + keyword String? // "ChatGPT" + errorType String // "INVALID_DATA", "API_ERROR", "DB_ERROR" + errorMessage String @db.Text // 详细错误信息 + rawData Json? // 原始数据便于调试 + createdAt DateTime @default(now()) + + @@index([quarter], map: "idx_keywordCloudErrorLog_quarter") + @@index([errorType], map: "idx_keywordCloudErrorLog_errorType") + @@map("keyword_cloud_error_logs") +}