c17b13b6a8
- 扩展 WeekendPlan schema: 新增 endTime 字段与 userId 索引 - PATCH /api/blindbox/plan 支持 accept/complete/expire 操作, 接受时自动计算契约结束时间 - GET /api/blindbox/plan 支持 mode 参数 (latest/pending/history) - 房间页接受契约后自动返回想法池,顶部显示"契约进行中"指示器 - 契约到期时触发浏览器通知 + 页面加载时弹出完成确认弹窗 - 新增 /achievements 成就墙页面:统计数据 + 决策记录/契约记录双标签 - 首页和个人中心新增成就墙入口
131 lines
3.4 KiB
Plaintext
131 lines
3.4 KiB
Plaintext
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
model Room {
|
|
id String @id
|
|
data String
|
|
createdAt DateTime @default(now())
|
|
expiresAt DateTime
|
|
|
|
@@index([expiresAt])
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
username String @unique
|
|
passwordHash String
|
|
avatar String @default("🐱")
|
|
email String? @unique
|
|
preferences String @default("{}")
|
|
createdAt DateTime @default(now())
|
|
decisions Decision[]
|
|
favorites Favorite[]
|
|
|
|
createdBlindBoxRooms BlindBoxRoom[] @relation("RoomCreator")
|
|
blindBoxMemberships BlindBoxMember[]
|
|
submittedIdeas BlindBoxIdea[] @relation("IdeaSubmitter")
|
|
drawnIdeas BlindBoxIdea[] @relation("IdeaDrawer")
|
|
weekendPlans WeekendPlan[]
|
|
}
|
|
|
|
model Decision {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
roomId String
|
|
restaurantName String
|
|
restaurantData String
|
|
matchType String
|
|
participants Int
|
|
createdAt DateTime @default(now())
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([userId])
|
|
@@index([roomId])
|
|
}
|
|
|
|
model Favorite {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
restaurantId String @default("")
|
|
restaurantData String
|
|
createdAt DateTime @default(now())
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, restaurantId])
|
|
@@index([userId])
|
|
}
|
|
|
|
model BlindBoxRoom {
|
|
id String @id @default(cuid())
|
|
code String @unique
|
|
name String
|
|
creatorId String
|
|
city String?
|
|
lat Float?
|
|
lng Float?
|
|
createdAt DateTime @default(now())
|
|
|
|
creator User @relation("RoomCreator", fields: [creatorId], references: [id])
|
|
members BlindBoxMember[]
|
|
ideas BlindBoxIdea[]
|
|
plans WeekendPlan[]
|
|
}
|
|
|
|
model BlindBoxMember {
|
|
id String @id @default(cuid())
|
|
roomId String
|
|
userId String
|
|
joinedAt DateTime @default(now())
|
|
|
|
room BlindBoxRoom @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([roomId, userId])
|
|
}
|
|
|
|
model BlindBoxIdea {
|
|
id String @id @default(uuid())
|
|
roomId String
|
|
userId String
|
|
content String
|
|
status String @default("in_pool")
|
|
drawnById String?
|
|
createdAt DateTime @default(now())
|
|
|
|
category String?
|
|
timeSlot String?
|
|
estimatedMinutes Int?
|
|
outdoor Boolean?
|
|
searchQuery String?
|
|
searchType String?
|
|
|
|
room BlindBoxRoom @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
|
user User @relation("IdeaSubmitter", fields: [userId], references: [id], onDelete: Cascade)
|
|
drawnBy User? @relation("IdeaDrawer", fields: [drawnById], references: [id], onDelete: SetNull)
|
|
|
|
@@index([roomId, status])
|
|
@@index([userId])
|
|
}
|
|
|
|
model WeekendPlan {
|
|
id String @id @default(cuid())
|
|
roomId String
|
|
userId String
|
|
planData String
|
|
status String @default("active")
|
|
endTime DateTime?
|
|
createdAt DateTime @default(now())
|
|
|
|
room BlindBoxRoom @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([roomId])
|
|
@@index([userId])
|
|
}
|