gongxiangp2/prisma/schema.prisma
chenpei d17f6df2c7 feat: 部门管理和文件上传优化
新功能:
1. 部门管理功能
   - 管理员可在系统设置中添加/删除部门
   - 用户注册时从下拉框选择部门
   - 新增Department数据库表和API

2. 文件上传优化
   - 支持直接上传源文件(.max/.psd/.ai/.cad/.dwg/.c4d)
   - 自动识别文件类型并设置素材类型
   - 压缩包需手动选择类型
   - 优化拖拽上传体验

数据库变更:
- 新增departments表
- User表新增department字段
2025-10-26 14:06:19 +08:00

118 lines
3.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(uuid())
email String @unique
username String @unique
password String
department String @default("") // 用户部门
role Role @default(USER)
isActive Boolean @default(false) // 是否激活,默认未激活
canDownload Boolean @default(true) // 是否允许下载,默认允许
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
materials Material[]
likes MaterialLike[]
@@map("users")
}
model Material {
id String @id @default(uuid())
previewUrl String // S3 URL for preview image
productModel String // SPU
categoryName String // 使用店铺
sceneName String // 场景类别
materialType String @default("3DMAX") // 素材类型:3DMAX/PSD/AI/CAD/C4D/其他
renderer String @default("CR") // 渲染器:CR/VR/其它(仅3DMAX使用)
authorName String // 作者花名
zipFileName String // 压缩包文件名
zipFilePath String // 本地压缩包路径
zipFileSize BigInt @default(0) // 压缩包文件大小(字节)
downloadCount Int @default(0) // 下载次数
likeCount Int @default(0) // 点赞次数
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
likes MaterialLike[]
@@map("materials")
@@index([userId])
@@index([createdAt])
@@index([categoryName])
@@index([sceneName])
@@index([materialType])
@@index([downloadCount])
@@index([likeCount])
}
model MaterialLike {
id String @id @default(uuid())
materialId String
userId String
createdAt DateTime @default(now())
material Material @relation(fields: [materialId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([materialId, userId]) // 确保一个用户只能点赞一次
@@map("material_likes")
@@index([materialId])
@@index([userId])
}
model Category {
id String @id @default(uuid())
name String @unique // 使用店铺名称
createdAt DateTime @default(now())
@@map("categories")
}
model Scene {
id String @id @default(uuid())
name String @unique // 场景类别名称
createdAt DateTime @default(now())
@@map("scenes")
}
model SystemSettings {
id String @id @default(uuid())
headerBgColor String @default("#1f2937") // 顶部导航栏背景色
logoUrl String @default("http://s3.1080p.hk/shuzhou/2025/05/18/8ebadf0a7cc34eaea00e8619b8efb827.png") // LOGO URL
siteName String @default("由壹点3D素材") // 网站名称
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
@@map("system_settings")
}
model Department {
id String @id @default(uuid())
name String @unique // 部门名称
createdAt DateTime @default(now())
@@map("departments")
}
enum Role {
USER
ADMIN
}