4f4220652e
批次A:重命名 + 路由拆分 - store.ts → roomRepository.ts,更新全部 import - blindbox/plan/route.ts 精简为薄路由,业务逻辑抽取到 planActions.ts / planQueries.ts 批次B:blindboxPlanGen.ts 拆分(710行 → src/lib/plan/) - agentPlan.ts:Agent 工具调用与系统提示 - legacyPlan.ts:非 Agent 备用生成逻辑 - ideaSelection.ts:Idea 筛选与 Slot 映射 - transitEnrichment.ts:交通信息查询与填充 - index.ts:runPlanGeneration 主入口 批次C:SSE 连接稳定性 - useRoomPolling.ts 加入指数退避重连(上限60s,含Jitter) - plan/stream/route.ts 添加30s心跳 + abort信号清理 批次D:无障碍修复 - Modal:role=dialog、aria-modal、aria-labelledby - AuthModal:aria-label关闭按钮、tablist/tab/aria-selected - PlanItemEditModal、QrInviteModal:补全aria-label - BlindboxPlan:图标按钮aria-label 批次E:Zod 引入 - src/lib/schemas/ai.ts:AI返回值 Schema(IdeaTagsSchema等5个) - src/lib/schemas/requests.ts:请求体 Schema - ai.ts 手工验证替换为 Zod safeParse 批次F:Server Components - achievements/page.tsx → Server Component + AchievementsClient.tsx - profile/page.tsx → Server Component + ProfileClient.tsx 批次G:Room 关系化模型 - prisma/schema.prisma:新增 RoomMember、RoomRestaurant、RoomLike、RoomSwipe 4张表 - migration:20260302010000_room_relational_model - roomRepository.ts 完整重写(关系查询+应用锁) - buildRoomStatus.ts 适配关系查询 测试:全部329个用例通过,修复68个因auth mock缺失导致的测试失败
189 lines
4.7 KiB
Plaintext
189 lines
4.7 KiB
Plaintext
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
model Room {
|
|
id String @id
|
|
creatorId String
|
|
scene String @default("eat")
|
|
locked Boolean @default(false)
|
|
match String?
|
|
createdAt DateTime @default(now())
|
|
expiresAt DateTime
|
|
|
|
members RoomMember[]
|
|
restaurants RoomRestaurant[]
|
|
likes RoomLike[]
|
|
swipes RoomSwipe[]
|
|
|
|
@@index([expiresAt])
|
|
}
|
|
|
|
model RoomMember {
|
|
id String @id @default(cuid())
|
|
roomId String
|
|
userId String
|
|
kicked Boolean @default(false)
|
|
joinedAt DateTime @default(now())
|
|
|
|
room Room @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([roomId, userId])
|
|
@@index([roomId])
|
|
}
|
|
|
|
model RoomRestaurant {
|
|
id String @id @default(cuid())
|
|
roomId String
|
|
restaurantData String
|
|
|
|
room Room @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([roomId])
|
|
}
|
|
|
|
model RoomLike {
|
|
id String @id @default(cuid())
|
|
roomId String
|
|
userId String
|
|
restaurantId String
|
|
|
|
room Room @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([roomId, userId, restaurantId])
|
|
@@index([roomId])
|
|
}
|
|
|
|
model RoomSwipe {
|
|
id String @id @default(cuid())
|
|
roomId String
|
|
userId String
|
|
count Int @default(0)
|
|
|
|
room Room @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([roomId, userId])
|
|
@@index([roomId])
|
|
}
|
|
|
|
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?
|
|
address 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?
|
|
costLevel String?
|
|
intensity String?
|
|
needsBooking 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])
|
|
}
|