feat: 初始化 PicAnalysis 项目
完整的前后端图片分析应用,包含: - 后端:Express + Prisma + SQLite,101个单元测试全部通过 - 前端:React + TypeScript + Vite,47个单元测试,89.73%覆盖率 - E2E测试:Playwright 测试套件 - MCP集成:Playwright MCP配置完成并测试通过 功能模块: - 用户认证(JWT) - 文档管理(CRUD) - 待办管理(三态工作流) - 图片管理(上传、截图、OCR) 测试覆盖: - 后端单元测试:101/101 ✅ - 前端单元测试:47/47 ✅ - E2E测试:通过 ✅ - MCP Playwright测试:通过 ✅ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
// Prisma Schema - 图片OCR与智能文档管理系统
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
// 用户
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
username String @unique
|
||||
email String? @unique
|
||||
password_hash String
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
documents Document[]
|
||||
todos Todo[]
|
||||
categories Category[]
|
||||
tags Tag[]
|
||||
images Image[]
|
||||
configs Config[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
// 文档
|
||||
model Document {
|
||||
id String @id @default(uuid())
|
||||
user_id String
|
||||
title String?
|
||||
content String
|
||||
category_id String?
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
||||
category Category? @relation(fields: [category_id], references: [id])
|
||||
images Image[]
|
||||
todos Todo[]
|
||||
aiAnalysis AIAnalysis?
|
||||
|
||||
@@index([user_id])
|
||||
@@index([category_id])
|
||||
@@map("documents")
|
||||
}
|
||||
|
||||
// 图片
|
||||
model Image {
|
||||
id String @id @default(uuid())
|
||||
user_id String
|
||||
document_id String?
|
||||
file_path String
|
||||
file_size Int
|
||||
mime_type String
|
||||
ocr_result String?
|
||||
ocr_confidence Float?
|
||||
processing_status String @default("pending")
|
||||
quality_score Float?
|
||||
error_message String?
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
||||
document Document? @relation(fields: [document_id], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([user_id])
|
||||
@@index([processing_status])
|
||||
@@index([document_id])
|
||||
@@map("images")
|
||||
}
|
||||
|
||||
// 待办事项
|
||||
model Todo {
|
||||
id String @id @default(uuid())
|
||||
user_id String
|
||||
document_id String?
|
||||
title String
|
||||
description String?
|
||||
priority String @default("medium")
|
||||
status String @default("pending")
|
||||
due_date DateTime?
|
||||
category_id String?
|
||||
completed_at DateTime?
|
||||
confirmed_at DateTime?
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
||||
document Document? @relation(fields: [document_id], references: [id], onDelete: SetNull)
|
||||
category Category? @relation(fields: [category_id], references: [id])
|
||||
|
||||
@@index([user_id])
|
||||
@@index([status])
|
||||
@@index([category_id])
|
||||
@@map("todos")
|
||||
}
|
||||
|
||||
// 分类
|
||||
model Category {
|
||||
id String @id @default(uuid())
|
||||
user_id String
|
||||
name String
|
||||
type String
|
||||
color String?
|
||||
icon String?
|
||||
parent_id String?
|
||||
sort_order Int @default(0)
|
||||
usage_count Int @default(0)
|
||||
is_ai_created Boolean @default(false)
|
||||
created_at DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
||||
parent Category? @relation("CategoryToCategory", fields: [parent_id], references: [id])
|
||||
children Category[] @relation("CategoryToCategory")
|
||||
documents Document[]
|
||||
todos Todo[]
|
||||
|
||||
@@index([user_id])
|
||||
@@index([type])
|
||||
@@map("categories")
|
||||
}
|
||||
|
||||
// 标签
|
||||
model Tag {
|
||||
id String @id @default(uuid())
|
||||
user_id String
|
||||
name String
|
||||
color String?
|
||||
usage_count Int @default(0)
|
||||
is_ai_created Boolean @default(false)
|
||||
created_at DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([user_id, name])
|
||||
@@index([user_id])
|
||||
@@map("tags")
|
||||
}
|
||||
|
||||
// AI分析结果
|
||||
model AIAnalysis {
|
||||
id String @id @default(uuid())
|
||||
document_id String @unique
|
||||
provider String
|
||||
model String
|
||||
suggested_tags String
|
||||
suggested_category String?
|
||||
summary String?
|
||||
raw_response String
|
||||
created_at DateTime @default(now())
|
||||
|
||||
document Document @relation(fields: [document_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("ai_analyses")
|
||||
}
|
||||
|
||||
// 配置
|
||||
model Config {
|
||||
id String @id @default(uuid())
|
||||
user_id String
|
||||
key String
|
||||
value String
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([user_id, key])
|
||||
@@index([user_id])
|
||||
@@map("configs")
|
||||
}
|
||||
Reference in New Issue
Block a user