This commit is contained in:
Rao 2025-04-22 12:31:59 +08:00
parent 6c26d26c2a
commit e5f3954e67
1 changed files with 0 additions and 148 deletions

View File

@ -89,14 +89,10 @@ model Staff {
officerId String? @map("officer_id")
// watchedPost Post[] @relation("post_watch_staff")
visits Visit[]
posts Post[]
learningPosts Post[] @relation("post_student")
sentMsgs Message[] @relation("message_sender")
receivedMsgs Message[] @relation("message_receiver")
registerToken String?
enrollments Enrollment[]
teachedPosts PostInstructor[]
ownedResources Resource[]
@ -218,8 +214,6 @@ model Post {
// 关系类型字段
authorId String? @map("author_id")
author Staff? @relation(fields: [authorId], references: [id]) // 帖子作者,关联 Staff 模型
enrollments Enrollment[] // 学生报名记录
visits Visit[] // 访问记录,关联 Visit 模型
parentId String? @map("parent_id")
parent Post? @relation("PostChildren", fields: [parentId], references: [id]) // 父级帖子,关联 Post 模型
children Post[] @relation("PostChildren") // 子级帖子列表,关联 Post 模型
@ -262,69 +256,6 @@ model PostAncestry {
@@map("post_ancestry")
}
model Message {
id String @id @default(cuid())
url String?
intent String?
option Json?
senderId String? @map("sender_id")
type String?
sender Staff? @relation(name: "message_sender", fields: [senderId], references: [id])
title String?
content String?
receivers Staff[] @relation("message_receiver")
visits Visit[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt @map("updated_at")
@@index([type, createdAt])
@@map("message")
}
model Visit {
id String @id @default(cuid()) @map("id")
type String?
views Int @default(1) @map("views")
// sourceIP String? @map("source_ip")
// 关联关系
visitorId String? @map("visitor_id")
visitor Staff? @relation(fields: [visitorId], references: [id])
postId String? @map("post_id")
post Post? @relation(fields: [postId], references: [id])
message Message? @relation(fields: [messageId], references: [id])
messageId String? @map("message_id")
lectureId String? @map("lecture_id") // 课时ID
createdAt DateTime @default(now()) @map("created_at") // 创建时间
updatedAt DateTime @updatedAt @map("updated_at") // 更新时间
deletedAt DateTime? @map("deleted_at") // 删除时间,可为空
meta Json?
@@index([postId, type, visitorId])
@@index([messageId, type, visitorId])
@@map("visit")
}
model Enrollment {
id String @id @default(cuid()) @map("id")
status String @map("status")
completionRate Float @default(0) @map("completion_rate")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
completedAt DateTime? @map("completed_at")
// 关联关系
student Staff @relation(fields: [studentId], references: [id])
studentId String @map("student_id")
post Post @relation(fields: [postId], references: [id])
postId String @map("post_id")
@@unique([studentId, postId])
@@index([status])
@@index([completedAt])
@@map("enrollment")
}
model PostInstructor {
postId String @map("post_id")
instructorId String @map("instructor_id")
@ -360,88 +291,9 @@ model Resource {
ownerId String? @map("owner_id")
post Post? @relation(fields: [postId], references: [id])
postId String? @map("post_id")
shareCode ShareCode?
// 索引
@@index([type])
@@index([createdAt])
@@map("resource")
}
model Node {
id String @id @default(cuid()) @map("id")
title String @map("title")
description String? @map("description")
type String @map("type")
style Json? @map("style")
position Json? @map("position")
data Json? @map("data")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
// 关联关系
sourceEdges NodeEdge[] @relation("source_node")
targetEdges NodeEdge[] @relation("target_node")
@@map("node")
}
model NodeEdge {
id String @id @default(cuid()) @map("id")
type String? @map("type")
label String? @map("label")
description String? @map("description")
style Json? @map("style")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
source Node @relation("source_node", fields: [sourceId], references: [id], onDelete: Cascade)
sourceId String @map("source_id")
target Node @relation("target_node", fields: [targetId], references: [id], onDelete: Cascade)
targetId String @map("target_id")
@@unique([sourceId, targetId, type])
@@index([sourceId])
@@index([targetId])
@@map("node_edge")
}
model Animal {
id String @id @default(cuid())
name String
age Int
gender Boolean
personId String?
person Person? @relation(fields: [personId], references: [id])
}
model Person {
id String @id @default(cuid())
name String
age Int
gender Boolean
animals Animal[]
}
model ShareCode {
id String @id @default(cuid())
code String? @unique
fileId String? @unique
fileName String? @map("file_name")
resource Resource? @relation(fields: [fileId], references: [fileId])
createdAt DateTime @default(now())
expiresAt DateTime? @map("expires_at")
deletedAt DateTime? @map("deleted_at")
isUsed Boolean? @default(false)
canUseTimes Int?
uploadIp String? @map("upload_ip")
@@index([code])
@@index([fileId])
@@index([expiresAt])
@@map("share_code")
}