Compare commits

..

No commits in common. "181e8c995d02e2a51531db04ad50d76e864d30c4" and "2acc55e58d510f5ebece94cf7757beaf33a1977c" have entirely different histories.

1 changed files with 36 additions and 25 deletions

View File

@ -44,12 +44,11 @@ model Term {
createdBy String? @map("created_by") createdBy String? @map("created_by")
depts Department[] @relation("department_term") depts Department[] @relation("department_term")
hasChildren Boolean? @default(false) @map("has_children") hasChildren Boolean? @default(false) @map("has_children")
plan Plan? @relation(fields: [planId], references: [id]) posts Post[] @relation("post_term")
Plan Plan? @relation(fields: [planId], references: [id])
planId String? planId String?
plans Plan[] @relation("plan_term") Subject Subject? @relation(fields: [subjectId], references: [id])
subject Subject? @relation(fields: [subjectId], references: [id], name: "subject_term")
subjectId String? subjectId String?
trainPlans TrainPlan[] @relation("TrainPlanTerm")
@@index([name]) // 对name字段建立索引以加快基于name的查找速度 @@index([name]) // 对name字段建立索引以加快基于name的查找速度
@@index([parentId]) // 对parentId字段建立索引以加快基于parentId的查找速度 @@index([parentId]) // 对parentId字段建立索引以加快基于parentId的查找速度
@ -143,6 +142,8 @@ model Resource {
isPublic Boolean? @default(true) @map("is_public") isPublic Boolean? @default(true) @map("is_public")
owner Staff? @relation(fields: [ownerId], references: [id]) owner Staff? @relation(fields: [ownerId], references: [id])
ownerId String? @map("owner_id") ownerId String? @map("owner_id")
post Post? @relation(fields: [postId], references: [id])
postId String? @map("post_id")
// 索引 // 索引
@@index([type]) @@index([type])
@ -154,6 +155,7 @@ model Department {
id String @id @default(cuid()) id String @id @default(cuid())
name String name String
order Float? order Float?
posts Post[] @relation("post_dept")
ancestors DeptAncestry[] @relation("DescendantToAncestor") ancestors DeptAncestry[] @relation("DescendantToAncestor")
descendants DeptAncestry[] @relation("AncestorToDescendant") descendants DeptAncestry[] @relation("AncestorToDescendant")
parentId String? @map("parent_id") parentId String? @map("parent_id")
@ -167,11 +169,13 @@ model Department {
deptStaffs Staff[] @relation("DeptStaff") deptStaffs Staff[] @relation("DeptStaff")
terms Term[] @relation("department_term") terms Term[] @relation("department_term")
trainPlans TrainPlan[] @relation("TrainPlanDept")
// watchedPost Post[] @relation("post_watch_dept") // watchedPost Post[] @relation("post_watch_dept")
hasChildren Boolean? @default(false) @map("has_children") hasChildren Boolean? @default(false) @map("has_children")
planId String? planId String?
plans Plan[] @relation("plan_dept") Plan Plan? @relation(fields: [planId], references: [id])
@@index([parentId]) @@index([parentId])
@@index([isDomain]) @@index([isDomain])
@ -181,18 +185,21 @@ model Department {
} }
model Staff { model Staff {
id String @id @default(cuid()) id String @id @default(cuid())
showname String? @map("showname") showname String? @map("showname")
username String @unique @map("username") username String @unique @map("username")
avatar String? @map("avatar") avatar String? @map("avatar")
password String? @map("password") password String? @map("password")
phoneNumber String? @unique @map("phone_number") phoneNumber String? @unique @map("phone_number")
age Int? @default(22) @map("age") age Int? @default(22) @map("age")
gender Int? @default(1) @map("gender") sex Boolean? @default(true) @map("sex")
absent Boolean? @default(false) @map("absent") absent Boolean? @default(false) @map("absent")
subjects Subject[] @relation("staff_subject") trainSituations TrainSituation[]
domainId String? @map("domain_id") position Position? @relation("StaffPosition", fields: [positionId], references: [id])
deptId String? @map("dept_id") positionId String? @map("position_id")
domainId String? @map("domain_id")
deptId String? @map("dept_id")
domain Department? @relation("DomainStaff", fields: [domainId], references: [id]) domain Department? @relation("DomainStaff", fields: [domainId], references: [id])
department Department? @relation("DeptStaff", fields: [deptId], references: [id]) department Department? @relation("DeptStaff", fields: [deptId], references: [id])
@ -205,10 +212,17 @@ model Staff {
officerId String? @map("officer_id") officerId String? @map("officer_id")
// watchedPost Post[] @relation("post_watch_staff") // 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? registerToken String?
enrollments Enrollment[]
teachedPosts PostInstructor[]
ownedResources Resource[] ownedResources Resource[]
plans Plan[] Plan Plan[]
@@index([officerId]) @@index([officerId])
@@index([deptId]) @@index([deptId])
@ -228,12 +242,10 @@ model Plan {
updatedAt DateTime @map("updated_at") updatedAt DateTime @map("updated_at")
deletedAt DateTime? @map("deleted_at") // 删除时间,可为空 deletedAt DateTime? @map("deleted_at") // 删除时间,可为空
terms Term[] @relation("plan_term") terms Term[] @relation("plan_term")
termRefs Term[] checked Boolean @default(false) @map("checked")
checked Boolean @default(false) @map("checked") depts Department[] @relation("plan_dept")
depts Department[] @relation("plan_dept") meta Json? @map("meta") // 计划表
meta Json? @map("meta") // 计划表
trainPlans TrainPlan[]
@@map("plan") @@map("plan")
} }
@ -275,7 +287,6 @@ model Subject {
children Subject[] @relation("SubjectChildren") // 子级帖子列表,关联 Post 模型 children Subject[] @relation("SubjectChildren") // 子级帖子列表,关联 Post 模型
ancestors SubjectAncestry[] @relation("DescendantToAncestor") ancestors SubjectAncestry[] @relation("DescendantToAncestor")
descendants SubjectAncestry[] @relation("AncestorToDescendant") descendants SubjectAncestry[] @relation("AncestorToDescendant")
staffs Staff[] @relation("staff_subject")
@@map("subject") @@map("subject")
} }