初始化项目结构和基础模块

完成内容:
- 创建前后端项目目录结构
- 初始化 Node.js + TypeScript 后端项目 (Fastify)
- 初始化 Vue 3 + TypeScript 前端项目 (Vite)
- 配置 Prisma ORM 和 MySQL 数据库
- 创建数据库 Schema 和种子数据
- 实现后端基础模块 (配置、日志、错误处理、验证)
- 创建基础服务类 (BaseService)
- 配置 Git 仓库和忽略文件

技术栈:
- 后端:Fastify + Prisma + MySQL + Winston
- 前端:Vue 3 + TypeScript + Element Plus + Pinia

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
hughhuangandClaude Sonnet 4.5 committed 2026-02-03 12:11:57 +08:00
commit 830a17bf46
53 files changed
+16893

No files matched your search

+231
View File
@@ -0,0 +1,231 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
// LLM 配置表
model LlmConfig {
id Int @id @default(autoincrement())
name String @db.VarChar(100)
baseUrl String @map("base_url") @db.VarChar(500)
model String @db.VarChar(100)
apiKey String @map("api_key") @db.VarChar(500)
enabled Boolean @default(true) @db.TinyInt
userId Int? @map("user_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
topics Topic[]
@@index([userId, enabled], map: "idx_user_enabled")
@@map("llm_configs")
}
// 数据源表
model Source {
id Int @id @default(autoincrement())
name String @db.VarChar(100)
type String @db.VarChar(50) // api/playwright/rss
config Json
cronExpression String @map("cron_expression") @db.VarChar(100)
enabled Boolean @default(true) @db.TinyInt
lastCollectedAt DateTime? @map("last_collected_at")
userId Int? @map("user_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
articles Article[]
topicSources TopicSource[]
collectionLogs CollectionLog[]
@@index([userId, enabled], map: "idx_user_enabled")
@@index([type], map: "idx_type")
@@map("sources")
}
// 推送渠道表
model Channel {
id Int @id @default(autoincrement())
name String @db.VarChar(100)
type String @db.VarChar(50) // email/dingtalk/wechat/slack
config Json
enabled Boolean @default(true) @db.TinyInt
userId Int? @map("user_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
topicChannels TopicChannel[]
pushLogs PushLog[]
@@index([userId, enabled], map: "idx_user_enabled")
@@index([type], map: "idx_type")
@@map("channels")
}
// 主题表
model Topic {
id Int @id @default(autoincrement())
name String @db.VarChar(100)
description String? @db.Text
processMode String @map("process_mode") @db.VarChar(50) // aggregate/summary/deep_analysis
llmConfigId Int? @map("llm_config_id")
scheduleConfig Json @map("schedule_config")
enabled Boolean @default(true) @db.TinyInt
userId Int? @map("user_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
llmConfig LlmConfig? @relation(fields: [llmConfigId], references: [id])
topicSources TopicSource[]
topicChannels TopicChannel[]
reports Report[]
conversations Conversation[]
@@index([userId, enabled], map: "idx_user_enabled")
@@map("topics")
}
// 主题-数据源关联表
model TopicSource {
id Int @id @default(autoincrement())
topicId Int @map("topic_id")
sourceId Int @map("source_id")
createdAt DateTime @default(now()) @map("created_at")
topic Topic @relation(fields: [topicId], references: [id], onDelete: Cascade)
source Source @relation(fields: [sourceId], references: [id], onDelete: Cascade)
@@unique([topicId, sourceId], map: "uk_topic_source")
@@index([topicId], map: "idx_topic")
@@index([sourceId], map: "idx_source")
@@map("topic_sources")
}
// 主题-推送渠道关联表
model TopicChannel {
id Int @id @default(autoincrement())
topicId Int @map("topic_id")
channelId Int @map("channel_id")
createdAt DateTime @default(now()) @map("created_at")
topic Topic @relation(fields: [topicId], references: [id], onDelete: Cascade)
channel Channel @relation(fields: [channelId], references: [id], onDelete: Cascade)
@@unique([topicId, channelId], map: "uk_topic_channel")
@@index([topicId], map: "idx_topic")
@@index([channelId], map: "idx_channel")
@@map("topic_channels")
}
// 资讯表
model Article {
id Int @id @default(autoincrement())
sourceId Int @map("source_id")
title String @db.VarChar(500)
content String? @db.Text
summary String? @db.Text
url String? @db.VarChar(1000)
publishedAt DateTime? @map("published_at")
collectedAt DateTime @map("collected_at")
rawData Json? @map("raw_data")
createdAt DateTime @default(now()) @map("created_at")
source Source @relation(fields: [sourceId], references: [id])
conversations Conversation[]
@@index([sourceId], map: "idx_source")
@@index([publishedAt], map: "idx_published")
@@index([collectedAt], map: "idx_collected")
@@index([url(length: 255)], map: "idx_url")
@@map("articles")
}
// 报告表
model Report {
id Int @id @default(autoincrement())
topicId Int @map("topic_id")
title String @db.VarChar(500)
content String @db.LongText
periodStart DateTime @map("period_start")
periodEnd DateTime @map("period_end")
status String @db.VarChar(50) // pending/generating/completed/failed
errorMessage String? @map("error_message") @db.Text
articleCount Int @default(0) @map("article_count")
userId Int? @map("user_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
topic Topic @relation(fields: [topicId], references: [id])
pushLogs PushLog[]
conversations Conversation[]
@@index([topicId], map: "idx_topic")
@@index([status], map: "idx_status")
@@index([periodStart, periodEnd], map: "idx_period")
@@index([userId, createdAt], map: "idx_user_created")
@@map("reports")
}
// 采集日志表
model CollectionLog {
id Int @id @default(autoincrement())
sourceId Int @map("source_id")
status String @db.VarChar(50) // success/failed
errorMessage String? @map("error_message") @db.Text
articlesCount Int @default(0) @map("articles_count")
startedAt DateTime @map("started_at")
finishedAt DateTime? @map("finished_at")
durationMs Int? @map("duration_ms")
createdAt DateTime @default(now()) @map("created_at")
source Source @relation(fields: [sourceId], references: [id])
@@index([sourceId], map: "idx_source")
@@index([status], map: "idx_status")
@@index([startedAt], map: "idx_started")
@@map("collection_logs")
}
// 推送日志表
model PushLog {
id Int @id @default(autoincrement())
reportId Int @map("report_id")
channelId Int @map("channel_id")
status String @db.VarChar(50) // success/failed
errorMessage String? @map("error_message") @db.Text
createdAt DateTime @default(now()) @map("created_at")
report Report @relation(fields: [reportId], references: [id])
channel Channel @relation(fields: [channelId], references: [id])
@@index([reportId], map: "idx_report")
@@index([channelId], map: "idx_channel")
@@index([status], map: "idx_status")
@@map("push_logs")
}
// AI对话记录表
model Conversation {
id Int @id @default(autoincrement())
reportId Int? @map("report_id")
articleId Int? @map("article_id")
topicId Int @map("topic_id")
messages Json
userId Int? @map("user_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
report Report? @relation(fields: [reportId], references: [id])
article Article? @relation(fields: [articleId], references: [id])
topic Topic @relation(fields: [topicId], references: [id])
@@index([reportId], map: "idx_report")
@@index([articleId], map: "idx_article")
@@index([topicId], map: "idx_topic")
@@index([userId], map: "idx_user")
@@map("conversations")
}