Hair Keeper v1.0.0:一个高度集成、深度定制、约定优于配置的全栈Web应用模板,旨在保持灵活性的同时提供一套基于成熟架构的开发底座,自带身份认证、权限控制、丰富前端组件、文件上传、后台任务、智能体开发等丰富功能,提供AI开发辅助,免于纠结功能如何实现,可快速上手专注于业务逻辑

This commit is contained in:
2025-11-13 15:24:54 +08:00
commit 42be39b343
249 changed files with 38843 additions and 0 deletions

243
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,243 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
// 用户表
model User {
id String @id
name String?
status String? // 在校/减离/NULL
deptCode String? @map("dept_code") // 所属院系代码(外键)
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz
password String
isSuperAdmin Boolean @default(false) @map("is_super_admin")
lastLoginAt DateTime? @map("last_login_at") @db.Timestamptz
// 关联
dept Dept? @relation(fields: [deptCode], references: [code])
roles Role[] // 多对多关联角色
selectionLogs SelectionLog[] // 选择日志
@@map("user")
}
// 院系表
model Dept {
code String @id
name String @default("")
fullName String @default("") @map("full_name")
// 关联
users User[]
@@map("dept")
}
// 角色表
model Role {
id Int @id @default(autoincrement())
name String @unique
users User[] // 多对多关联用户
permissions Permission[] // 多对多关联权限
@@map("role")
}
// 权限表
model Permission {
id Int @id @default(autoincrement())
name String @unique
roles Role[] // 多对多关联角色
@@map("permission")
}
// 选择日志表
model SelectionLog {
id Int @id @default(autoincrement())
userId String // 关联到用户
user User @relation(fields: [userId], references: [id])
// 用于标识是哪个的选项,用.进行分隔,例如"user.filter.dept"
context String
// 关键字段:被选中的选项的值
optionId String @map("option_id")
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
// 建立索引,提升查询性能
@@index([userId, context])
@@index([context, optionId])
@@map("selection_log")
}
// KV配置表 - 用于存储各种键值对配置
model KVConfig {
key String @id // 配置键
value String @db.Text // 配置值
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz
@@map("kv_config")
}
/*********************************************** 仅在开发阶段可用的数据表放在这下面 ***********************************************/
model DevFileType {
id String @id // 文件类型ID如 "COMPONENT_UI"
name String // 文件类型名称,如 "UI组件"
description String // 文件类型描述
order Int // 用来进行排序方便展示
// 关联
files DevAnalyzedFile[]
@@map("dev_file_type")
}
// 依赖包类型表
model DevPkgType {
id String @id // 依赖包类型ID如 "CORE_FRAMEWORK"
name String // 分类名称,如 "核心框架 (Core Framework)"
description String @db.Text // 职责描述
order Int // 用来进行排序方便展示
packages DevAnalyzedPkg[]
@@map("dev_pkg_type")
}
// 分析得到的项目文件信息
model DevAnalyzedFile {
id Int @id @default(autoincrement())
path String // 文件相对路径,如 "src/app/api/trpc/[trpc]/route.ts"
fileName String // 文件名,如 "route.ts"
commitId String @default("") @map("commit_id") // Git commit ID (前7位修改过的文件后面加*)
content String? @db.Text // 文件内容不超过100K的非二进制文件
fileTypeId String @map("file_type_id") // 文件类型ID外键
summary String // 主要功能一句话总结 (LLM生成)
description String // 详细功能描述 (LLM生成)
// 关键代码信息
exportedMembers Json? // 导出的函数、组件、类型、对象、列表、其他 { name, type }[]
// 元数据
tags String[] // 标签 (用于快速筛选和分类)
lastAnalyzedAt DateTime @updatedAt @db.Timestamptz
createdAt DateTime @default(now()) @db.Timestamptz // 创建时间
// 关联
fileType DevFileType @relation(fields: [fileTypeId], references: [id])
dependencies DevFileDependency[] // 该文件依赖的其他文件
pkgDependencies DevFilePkgDependency[] // 该文件依赖的包
// path 和 commitId 构成唯一键
@@unique([path, commitId], name: "uidx_path_commit")
@@map("dev_analyzed_file")
}
// 分析得到的依赖包信息
model DevAnalyzedPkg {
name String @id // 包名,如 '@tanstack/react-table'
// -- 静态信息通过读取node_modules中包的package.json获取内置包则为node的信息
version String // 版本号,如 '8.17.3'
modifiedAt DateTime // 该版本的发布时间,通过命令获取 npm view @tanstack/react-table "time[8.17.3]"
description String @db.Text // 从 package.json 中获取的官方描述
homepage String? // 包的主页URL
repositoryUrl String? @map("repository_url") // 包的仓库URL例如git+https://github.com/shadcn/ui.git
// -- 调用AI获取
pkgTypeId String @map("pkg_type_id") // 依赖包类型ID (外键)
projectRoleSummary String @db.Text // AI总结的该包的核心功能
primaryUsagePattern String @db.Text // AI总结的主要使用模式分成多点描述
// -- 统计获得
relatedFiles String[] // path[] 本次分析中,认为和该库有关联的文件(统计一定引用层数)
relatedFileCount Int // 该包在项目中被多少个文件直接或引用
// --- 时间戳 ---
lastAnalyzedAt DateTime @updatedAt @map("last_analyzed_at") @db.Timestamptz
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
// --- 关联 ---
pkgType DevPkgType @relation(fields: [pkgTypeId], references: [id])
@@index([pkgTypeId])
@@map("dev_analyzed_pkg")
}
// 文件依赖关系表
model DevFileDependency {
id Int @id @default(autoincrement())
sourceFileId Int @map("source_file_id") // 源文件ID依赖方
targetFilePath String @map("target_file_path") // 目标文件路径(被依赖方)
// AI生成的依赖用途描述
usageDescription String? @map("usage_description") @db.Text // 描述该依赖在源文件中的用途
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
// 关联
sourceFile DevAnalyzedFile @relation(fields: [sourceFileId], references: [id], onDelete: Cascade)
// 确保同一个源文件不会重复依赖同一个目标文件
@@unique([sourceFileId, targetFilePath], name: "uidx_source_target")
@@index([targetFilePath]) // 加速按目标文件路径查询
@@map("dev_file_dependency")
}
// 包依赖关系表
model DevFilePkgDependency {
id Int @id @default(autoincrement())
sourceFileId Int @map("source_file_id") // 源文件ID依赖方
packageName String @map("package_name") // 包名(如 'react' 或 '@tanstack/react-table'
// AI生成的依赖用途描述
usageDescription String? @map("usage_description") @db.Text // 描述该包在源文件中的用途和使用的功能
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
// 关联
sourceFile DevAnalyzedFile @relation(fields: [sourceFileId], references: [id], onDelete: Cascade)
// 确保同一个源文件不会重复依赖同一个包
@@unique([sourceFileId, packageName], name: "uidx_source_package")
@@index([packageName]) // 加速按包名查询
@@map("dev_file_pkg_dependency")
}
// 分析得到的项目文件夹信息
model DevAnalyzedFolder {
path String @id // 文件夹相对路径,如 "src/app/api"
name String // 文件夹名,如 "api"
summary String // 主要功能一句话总结 (LLM生成)
description String @db.Text // 详细功能描述 (LLM生成)
// 元数据
lastAnalyzedAt DateTime @updatedAt @map("last_analyzed_at") @db.Timestamptz
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
@@map("dev_analyzed_folder")
}