159 lines
5.0 KiB
Plaintext
159 lines
5.0 KiB
Plaintext
// 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("") // 用户部门
|
||
managedDepartment String? // 管理员负责的部门(如果是部门管理员)
|
||
role Role @default(USER)
|
||
isActive Boolean @default(false) // 是否激活,默认未激活
|
||
canDownload Boolean @default(true) // 是否允许下载,默认允许
|
||
|
||
// 钉钉登录相关字段
|
||
dingtalkUserId String? @unique // 钉钉userId
|
||
loginType String @default("normal") // 登录类型:normal/dingtalk
|
||
realName String? // 真实姓名
|
||
phone String? @unique // 手机号
|
||
avatar String? // 头像URL
|
||
|
||
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 // 场景类别
|
||
platformName String @default("") // 平台分类(可选)
|
||
materialType String @default("3DMAX") // 素材类型:3DMAX/PSD/AI/CAD/C4D/材质/模特/标准饰品/其他
|
||
renderer String @default("CR") // 渲染器:CR/VR/其它(仅3DMAX使用)
|
||
authorName String // 作者花名
|
||
zipFileName String @default("") // 压缩包文件名(模特类型可为空)
|
||
zipFilePath String @default("") // 本地压缩包路径(模特类型可为空)
|
||
zipFileSize BigInt @default(0) // 压缩包文件大小(字节)
|
||
downloadCount Int @default(0) // 下载次数
|
||
likeCount Int @default(0) // 点赞次数
|
||
displayImages String[] @default([]) // PSD/模特展示图片URLs数组(切割后的图片按顺序存储)
|
||
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([platformName])
|
||
@@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 Platform {
|
||
id String @id @default(uuid())
|
||
name String @unique // 平台分类名称
|
||
createdAt DateTime @default(now())
|
||
|
||
@@map("platforms")
|
||
}
|
||
|
||
model SystemSettings {
|
||
id String @id @default(uuid())
|
||
headerBgColor String @default("#1f2937") // 顶部导航栏背景色
|
||
headerLogoUrl String @default("http://s3.1080p.hk/shuzhou/2025/05/18/8ebadf0a7cc34eaea00e8619b8efb827.png") // 导航栏LOGO URL(深色背景用)
|
||
loginLogoUrl String @default("http://s3.1080p.hk/shuzhou/2025/05/18/8ebadf0a7cc34eaea00e8619b8efb827.png") // 登录页面LOGO URL(浅色背景用)
|
||
siteName String @default("由壹点3D素材") // 网站名称
|
||
|
||
// S3存储桶配置
|
||
s3Endpoint String @default("") // S3端点
|
||
s3AccessKey String @default("") // S3访问密钥
|
||
s3SecretKey String @default("") // S3密钥
|
||
s3Bucket String @default("") // 存储桶名称
|
||
s3Region String @default("us-east-1") // 区域
|
||
s3PublicUrl String @default("") // 公网访问URL
|
||
|
||
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")
|
||
}
|
||
|
||
model Danmaku {
|
||
id String @id @default(uuid())
|
||
content String // 弹幕内容
|
||
username String // 发送者用户名
|
||
userId String // 发送者ID
|
||
createdAt DateTime @default(now())
|
||
|
||
@@map("danmakus")
|
||
@@index([createdAt])
|
||
}
|
||
|
||
enum Role {
|
||
USER
|
||
ADMIN
|
||
}
|
||
|