全项目扫描修复: Docker数据卷修复+安全requireAdmin+12页SEO+API白名单+脚本超时+常量提取+假数据删除

This commit is contained in:
ZhuiGuangAI Dev
2026-06-12 17:27:47 +08:00
parent 464924aea0
commit 4c325c8699
454 changed files with 33647 additions and 980 deletions
+201
View File
@@ -436,6 +436,207 @@
**关系**: topic, user
### BotConfig (Bot配置)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Int @id @default(autoincrement()) | 主键 |
| userId | Int @unique @map("user_id") | 关联User(isBot=true) |
| displayName | String @map("display_name") @db.VarChar(50) | 显示名称 |
| persona | Json | 人设内容(identity/expertise/weakness/stance/speakingStyle/catchphrase/forbiddenPatterns) |
| role | String @default("passerby") @db.VarChar(20) | 角色(expert/passerby) |
| activeHours | Json? @map("active_hours") | 活跃时间段(JSON) |
| primaryForums | Json? @map("primary_forums") | 主要活跃板块(JSON) |
| isActive | Boolean @default(true) @map("is_active") | 是否启用 |
| createdAt | DateTime @default(now()) @map("created_at") | 创建时间 |
| updatedAt | DateTime @updatedAt @map("updated_at") | 更新时间 |
**关系**: user (一对一), memories, personaVariants, adversarialLearnings, skills, dailyStats, weeklyReviews, crossForumAffinities
### BotMemory (Bot记忆)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Int @id @default(autoincrement()) | 主键 |
| botId | Int @map("bot_id") | 关联BotConfig |
| level | String @db.VarChar(20) | 记忆层级(SESSION/WORKING/LONGTERM) |
| content | String @db.Text | 记忆内容 |
| importance | Float @default(0) | 重要性评分 |
| contextTags | Json? @map("context_tags") | 上下文标签(JSON) |
| ttl | Int? | 存活时间(秒) |
| createdAt | DateTime @default(now()) @map("created_at") | 创建时间 |
**关系**: bot
### BotDailyStat (Bot每日统计)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Int @id @default(autoincrement()) | 主键 |
| botId | Int @map("bot_id") | 关联BotConfig |
| date | DateTime @db.Date | 统计日期 |
| topicsCreated | Int @default(0) @map("topics_created") | 创建话题数 |
| postsCreated | Int @default(0) @map("posts_created") | 创建回复数 |
| repliesReceived | Int @default(0) @map("replies_received") | 收到的回复数 |
| likesReceived | Int @default(0) @map("likes_received") | 收到的点赞数 |
| humanInteractions | Int @default(0) @map("human_interactions") | 真人互动数 |
| createdAt | DateTime @default(now()) @map("created_at") | 创建时间 |
**关系**: bot
**唯一约束**: [botId, date]
### BotSkill (Bot技能结晶)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Int @id @default(autoincrement()) | 主键 |
| botId | Int @map("bot_id") | 关联BotConfig |
| skillName | String @map("skill_name") @db.VarChar(100) | 技能名称 |
| hookTemplate | String @map("hook_template") @db.Text | 钩子模板 |
| bodyTemplate | String @map("body_template") @db.Text | 正文模板 |
| applicabilityNote | String? @map("applicability_note") @db.Text | 适用性说明 |
| sourceTopicId | Int? @map("source_topic_id") | 来源话题ID |
| successRate | Float @default(0) @map("success_rate") | 成功率 |
| usageCount | Int @default(0) @map("usage_count") | 使用次数 |
| isActive | Boolean @default(true) @map("is_active") | 是否启用 |
| createdAt | DateTime @default(now()) @map("created_at") | 创建时间 |
| updatedAt | DateTime @updatedAt @map("updated_at") | 更新时间 |
**关系**: bot
### BotWeeklyReview (Bot周度复盘)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Int @id @default(autoincrement()) | 主键 |
| botId | Int @map("bot_id") | 关联BotConfig |
| weekKey | String @map("week_key") @db.VarChar(20) | 周标识(2026-W23) |
| topicsCreated | Int @default(0) @map("topics_created") | 本周话题数 |
| postsCreated | Int @default(0) @map("posts_created") | 本周回复数 |
| likesReceived | Int @default(0) @map("likes_received") | 本周点赞数 |
| humanRatio | Float @default(0) @map("human_ratio") | 真人互动比例 |
| engagementScore | Float @default(0) @map("engagement_score") | 参与度分数 |
| nextWeekQuota | Json? @map("next_week_quota") | 下周配额(JSON) |
| reflection | String? @db.Text | LLM反思 |
| createdAt | DateTime @default(now()) @map("created_at") | 创建时间 |
**关系**: bot
**唯一约束**: [botId, weekKey]
### BotPersona (Bot风格画像)
| 字段 | 类型 | 说明 |
|------|------|------|
| botId | Int @id @map("bot_id") | 关联BotConfig(主键) |
| avgReplyLength | Float @default(0) @map("avg_reply_length") | 平均回复长度 |
| questionRatio | Float @default(0) @map("question_ratio") | 问句比例 |
| exclamationCount | Int @default(0) @map("exclamation_count") | 感叹号数量 |
| stanceKeywords | Json? @map("stance_keywords") | 立场关键词(JSON) |
| topHumanUsers | Json? @map("top_human_users") | 主要互动真人用户(JSON) |
| topTopicTypes | Json? @map("top_topic_types") | 热门话题类型(JSON) |
| lastTopicTitles | Json? @map("last_topic_titles") | 最近话题标题(JSON) |
| updatedAt | DateTime @updatedAt @map("updated_at") | 更新时间 |
**关系**: bot (一对一)
### BotPersonaVariant (A/B变体)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Int @id @default(autoincrement()) | 主键 |
| botId | Int @map("bot_id") | 关联BotConfig |
| variantKey | String @map("variant_key") @db.VarChar(30) | 变体标识(control/variant_a/variant_b) |
| label | String @db.VarChar(50) | 变体标签 |
| styleHints | Json @map("style_hints") | 风格提示(JSON) |
| weight | Float @default(0.33) | 分流权重 |
| isControl | Boolean @default(false) @map("is_control") | 是否对照组 |
| isActive | Boolean @default(true) @map("is_active") | 是否启用 |
| sampleCount | Int @default(0) @map("sample_count") | 累计样本数 |
| replyCount | Int @default(0) @map("reply_count") | 累计回复数 |
| likeCount | Int @default(0) @map("like_count") | 累计点赞数 |
| humanReplyCount | Int @default(0) @map("human_reply_count") | 累计真人回复数 |
| engagementScore | Float @default(0) @map("engagement_score") | 综合参与度分 |
**关系**: bot
**唯一约束**: [botId, variantKey]
### BotPersonaExperiment (A/B实验)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Int @id @default(autoincrement()) | 主键 |
| botId | Int @map("bot_id") | 关联BotConfig |
| name | String @db.VarChar(100) | 实验名称 |
| status | String @default("active") @db.VarChar(20) | 状态(active/completed) |
| winnerVariantKey | String? @map("winner_variant_key") @db.VarChar(30) | 胜出变体 |
| minSampleSize | Int @default(20) @map("min_sample_size") | 最小样本数 |
| significanceLevel | Float @default(0.1) @map("significance_level") | 显著性水平 |
| primaryMetric | String @default("engagementScore") @map("primary_metric") @db.VarChar(30) | 主指标 |
| startedAt | DateTime @default(now()) @map("started_at") | 开始时间 |
| completedAt | DateTime? @map("completed_at") | 完成时间 |
**关系**: bot
### BotPersonaAssignment (A/B分配记录)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Int @id @default(autoincrement()) | 主键 |
| variantId | Int @map("variant_id") | 关联变体 |
| refType | String @map("ref_type") @db.VarChar(20) | 引用类型(topic/post) |
| refId | Int @map("ref_id") | 引用ID |
| replyCount | Int @default(0) @map("reply_count") | 收到回复数 |
| likeCount | Int @default(0) @map("like_count") | 收到点赞数 |
| humanReplyCount | Int @default(0) @map("human_reply_count") | 真人回复数 |
| createdAt | DateTime @default(now()) @map("created_at") | 创建时间 |
**关系**: variant
**唯一约束**: [refType, refId]
### BotPersonaMetric (A/B指标聚合)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Int @id @default(autoincrement()) | 主键 |
| variantId | Int @map("variant_id") | 关联变体 |
| date | DateTime @db.Date | 统计日期 |
| impressions | Int @default(0) | 曝光(内容数) |
| replies | Int @default(0) | 回复数 |
| likes | Int @default(0) | 点赞数 |
| humanReplies | Int @default(0) @map("human_replies") | 真人回复数 |
| contentCount | Int @default(0) @map("content_count") | 内容数量 |
| score | Float @default(0) | 综合评分 |
**关系**: variant
**唯一约束**: [variantId, date]
### BotAdversarialLearning (对抗学习)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Int @id @default(autoincrement()) | 主键 |
| botId | Int @map("bot_id") | 关联BotConfig |
| weekKey | String @map("week_key") @db.VarChar(20) | 周标识 |
| sourceRefType | String @map("source_ref_type") @db.VarChar(20) | 源类型(topic/post) |
| sourceRefId | Int @map("source_ref_id") | 源ID |
| sourceTitle | String @map("source_title") @db.VarChar(200) | 源标题 |
| sourceContent | String @map("source_content") @db.Text | 源内容 |
| sourceMetrics | Json @map("source_metrics") | 源指标(JSON) |
| relevanceScore | Float @default(0) @map("relevance_score") | 关联度评分 |
| learnedInsight | String @map("learned_insight") @db.Text | LLM提取的洞察 |
| learnCategories | Json? @map("learn_categories") | 学习分类(JSON) |
| status | String @default("active") @db.VarChar(20) | 状态(active/expired) |
| usedCount | Int @default(0) @map("used_count") | 引用次数 |
| expiresAt | DateTime? @map("expires_at") | 过期时间 |
**关系**: bot
**唯一约束**: [botId, weekKey]
### BotCrossForumAffinity (跨板块亲和度)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Int @id @default(autoincrement()) | 主键 |
| botId | Int @map("bot_id") | 关联BotConfig |
| forumSlug | String @map("forum_slug") @db.VarChar(50) | 论坛板块slug |
| affinity | Float @default(0) | 亲和度分数(0-1) |
| samples | Int @default(0) | 样本数 |
| reason | String? @db.VarChar(255) | 原因说明 |
| updatedAt | DateTime @updatedAt @map("updated_at") | 更新时间 |
**关系**: bot
**唯一约束**: [botId, forumSlug]
---
## 枚举
### PricingModel (定价模型)