- 废弃 RedemptionRule(集 N 换 1),新增 Prize 表与 Stamp 1:1 关联 - Redemption 记录直接绑定到 stampId + prizeId + prizeName 快照 - 兑换事务用 updateMany + stock>0 条件作乐观锁 - 兑换后保留 Collection 记录,图章持续彩色点亮并标记"已兑换" - 用户端入口改为点击已收集图章弹出兑换,库存为 0 时按钮禁用 - 管理后台删除 /admin/rules,奖品编辑嵌入 StampForm Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
99 lines
2.6 KiB
Plaintext
99 lines
2.6 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
username String @unique
|
|
phone String @unique
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
collections Collection[]
|
|
redemptions Redemption[]
|
|
}
|
|
|
|
model Stamp {
|
|
id String @id @default(uuid())
|
|
name String
|
|
note String?
|
|
imageColor String
|
|
imageGrey String
|
|
sortOrder Int @default(0)
|
|
enabled Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
collections Collection[]
|
|
redemptions Redemption[]
|
|
prize Prize?
|
|
}
|
|
|
|
model Prize {
|
|
id String @id @default(uuid())
|
|
stampId String @unique
|
|
name String
|
|
description String?
|
|
stock Int @default(0)
|
|
enabled Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
stamp Stamp @relation(fields: [stampId], references: [id], onDelete: Cascade)
|
|
redemptions Redemption[]
|
|
}
|
|
|
|
model Collection {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
stampId String
|
|
collectedAt DateTime @default(now())
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
stamp Stamp @relation(fields: [stampId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, stampId])
|
|
@@index([userId])
|
|
}
|
|
|
|
model Redemption {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
stampId String
|
|
prizeId String
|
|
prizeName String
|
|
redeemedAt DateTime @default(now())
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
stamp Stamp @relation(fields: [stampId], references: [id])
|
|
prize Prize @relation(fields: [prizeId], references: [id])
|
|
|
|
@@unique([userId, stampId])
|
|
@@index([userId])
|
|
}
|
|
|
|
model Article {
|
|
id String @id @default(uuid())
|
|
title String
|
|
subtitle String?
|
|
body String
|
|
coverImage String @default("")
|
|
caption String?
|
|
sortOrder Int @default(0)
|
|
enabled Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model Music {
|
|
id String @id @default(uuid())
|
|
title String
|
|
subtitle String?
|
|
audioFile String @default("")
|
|
sortOrder Int @default(0)
|
|
enabled Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|