feat: 首次推送到Gitea - 完整项目代码 + 安全加固 + 知识库

This commit is contained in:
ZhuiGuangAI Dev
2026-10-02 18:52:49 +08:00
parent b44601bb66
commit 8205ae709c
1185 changed files with 49841 additions and 12802 deletions
+66 -3
View File
@@ -53,6 +53,7 @@ model Tool {
pricingModel PricingModel @default(freemium) @map("pricing_model")
pricingDetail String? @map("pricing_detail") @db.VarChar(200)
features Json?
screenshots Json? // Array of { url: string, alt?: string } - max 5 screenshots
tags Json?
viewCount Int @default(0) @map("view_count")
commentCount Int @default(0) @map("comment_count")
@@ -71,6 +72,8 @@ model Tool {
collectionItems CollectionItem[]
comments Comment[]
@@index([status, viewCount]) // for published tools sorted by views
@@index([status, createdAt]) // for recent published tools
@@index([categoryId, status])
@@fulltext([name, description])
@@map("tools")
@@ -137,6 +140,8 @@ model Skill {
commentCount Int @default(0) @map("comment_count")
avgRating Float @default(0) @map("avg_rating")
@@index([status, viewCount]) // for published skills sorted by views
@@index([status, createdAt]) // for recent published skills
@@index([categoryId, status])
@@map("skills")
}
@@ -229,7 +234,12 @@ model User {
achievements UserAchievement[]
topicSubscriptions ForumTopicSubscription[]
apiKeys ApiKey[]
@@unique([oauthProvider, oauthId])
@@index([isBot]) // for filtering bot users
@@index([role]) // for role-based queries
@@map("users")
}
@@ -371,6 +381,9 @@ model Collection {
name String @db.VarChar(50)
description String? @db.Text
sortOrder Int @default(0) @map("sort_order")
isPublic Boolean @default(false) @map("is_public")
publicSlug String? @unique @map("public_slug") @db.VarChar(100)
viewCount Int @default(0) @map("view_count")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@ -378,6 +391,7 @@ model Collection {
items CollectionItem[]
@@index([userId])
@@index([isPublic, viewCount])
@@map("collections")
}
@@ -526,7 +540,7 @@ model Comment {
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
user User @relation(fields: [userId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
tool Tool? @relation(fields: [toolId], references: [id], onDelete: Cascade)
skill Skill? @relation(fields: [skillId], references: [id], onDelete: Cascade)
parent Comment? @relation("CommentReplies", fields: [parentId], references: [id])
@@ -583,6 +597,7 @@ enum NotifType {
POST_LIKE
TOPIC_LIKE
SYSTEM
DIGEST
}
model ForumCategory {
@@ -622,9 +637,12 @@ model ForumTopic {
lastReplyAt DateTime? @map("last_reply_at")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
// 行业智库元数据:{ kind:"thinktank", industry:<板块slug>, version: n, lastTopic, lastRoundAt }
// 主题帖 topic.content = 最新"打法"(1 楼),楼层 post = 每周研讨对话原文/真人问答
thinktank Json? @map("thinktank")
category ForumCategory @relation(fields: [categoryId], references: [id])
user User @relation(fields: [userId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
posts ForumPost[]
likes ForumTopicLike[]
tags ForumTopicTag[]
@@ -634,6 +652,8 @@ model ForumTopic {
@@index([categoryId, lastReplyAt])
@@index([categoryId, isPinned, createdAt])
@@index([categoryId, updatedAt]) // for recent topics by category
@@index([createdAt]) // for chronological queries
@@index([userId])
@@index([isFeatured, lastReplyAt])
@@index([isHidden])
@@ -656,12 +676,13 @@ model ForumPost {
updatedAt DateTime @updatedAt @map("updated_at")
topic ForumTopic @relation(fields: [topicId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
likes ForumPostLike[]
replyTo ForumPost? @relation("PostReplies", fields: [replyToId], references: [id], onDelete: SetNull)
replies ForumPost[] @relation("PostReplies")
@@index([topicId, createdAt])
@@index([topicId, isHidden, createdAt]) // for filtered post queries
@@index([userId])
@@index([replyToId])
@@index([isHidden])
@@ -836,6 +857,8 @@ model BotConfig {
botPersonaVariants BotPersonaVariant[] @relation("BotVariants")
adversarialLearnings BotAdversarialLearning[] @relation("BotAdversarialLearnings")
crossForumAffinities BotCrossForumAffinity[]
@@map("bot_configs")
}
@@ -873,6 +896,7 @@ model BotDailyStat {
updatedAt DateTime @updatedAt @map("updated_at")
@@unique([botId, date])
@@index([botId, date]) // for bot daily stats queries
@@index([date])
@@map("bot_daily_stats")
}
@@ -1076,6 +1100,8 @@ model BotCrossForumAffinity {
reason String? @db.VarChar(100)
updatedAt DateTime @updatedAt @map("updated_at")
bot BotConfig @relation(fields: [botId], references: [id], onDelete: Cascade)
@@unique([botId, forumSlug])
@@index([botId, affinity])
@@map("bot_cross_forum_affinities")
@@ -1132,3 +1158,40 @@ model ForumTopicSubscription {
@@index([userId, createdAt])
@@map("forum_topic_subscriptions")
}
model Feedback {
id Int @id @default(autoincrement())
type String @default("suggestion") @db.VarChar(20)
content String @db.Text
contact String? @db.VarChar(255)
pageUrl String? @map("page_url") @db.VarChar(500)
userId String? @map("user_id") @db.VarChar(50)
status String @default("pending") @db.VarChar(20)
adminNote String? @map("admin_note") @db.Text
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@index([status, createdAt])
@@map("feedbacks")
}
model ApiKey {
id Int @id @default(autoincrement())
userId Int @map("user_id")
name String @db.VarChar(100)
keyHash String @unique @map("key_hash") @db.VarChar(64)
keyPrefix String @map("key_prefix") @db.VarChar(8)
tier String @default("free") @db.VarChar(20)
rateLimit Int @default(100) @map("rate_limit")
lastUsedAt DateTime? @map("last_used_at")
requestCount Int @default(0) @map("request_count")
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
expiresAt DateTime? @map("expires_at")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
@@index([keyPrefix])
@@map("api_keys")
}