This commit is contained in:
linfeng 2025-04-25 11:41:29 +08:00
parent 181e8c995d
commit 90204d78b6
1 changed files with 71 additions and 16 deletions

View File

@ -47,13 +47,20 @@ model Term {
plan Plan? @relation(fields: [planId], references: [id]) plan Plan? @relation(fields: [planId], references: [id])
planId String? planId String?
plans Plan[] @relation("plan_term") plans Plan[] @relation("plan_term")
subject Subject? @relation(fields: [subjectId], references: [id], name: "subject_term")
subjectId String?
trainPlans TrainPlan[] @relation("TrainPlanTerm") trainPlans TrainPlan[] @relation("TrainPlanTerm")
majorId String? @map("major_id")
major Outline? @relation("major_term", fields: [majorId], references: [id])
identityId String? @map("identity_id")
identity Outline? @relation("identity_term", fields: [identityId], references: [id])
subjectId String? @map("subject_id")
subject Outline? @relation("subject_term", fields: [subjectId], references: [id])
courses Course[] @relation("course_term")
@@index([name]) // 对name字段建立索引以加快基于name的查找速度 @@index([name]) // 对name字段建立索引以加快基于name的查找速度
@@index([parentId]) // 对parentId字段建立索引以加快基于parentId的查找速度 @@index([parentId]) // 对parentId字段建立索引以加快基于parentId的查找速度
@@map("term") @@map("term")
} }
model TermAncestry { model TermAncestry {
@ -166,6 +173,9 @@ model Department {
domainStaffs Staff[] @relation("DomainStaff") domainStaffs Staff[] @relation("DomainStaff")
deptStaffs Staff[] @relation("DeptStaff") deptStaffs Staff[] @relation("DeptStaff")
terms Term[] @relation("department_term") terms Term[] @relation("department_term")
progress Json? @map("progress") //单位训练进度表
score Json? @map("score") //单位成绩评定表
// 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")
@ -193,6 +203,9 @@ model Staff {
subjects Subject[] @relation("staff_subject") subjects Subject[] @relation("staff_subject")
domainId String? @map("domain_id") domainId String? @map("domain_id")
deptId String? @map("dept_id") deptId String? @map("dept_id")
outlines Outline[] @relation("staff_outline")
alreadyTime Json? @map("already_time") //个人训练进度表
score Json? @map("score") //个人成绩评定表
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])
@ -228,12 +241,12 @@ 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[] 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[] trainPlans TrainPlan[]
@@map("plan") @@map("plan")
} }
@ -251,25 +264,67 @@ model TrainPlan {
terms Term[] @relation("TrainPlanTerm") terms Term[] @relation("TrainPlanTerm")
day DateTime? @map("day") // 日期 day DateTime? @map("day") // 日期
dayType String? @map("day_type") // 早中晚 dayType String? @map("day_type") // 早中晚
major String? @map("major") // 专业 outlines Outline[] @relation("train_plan_outline")
role String? @map("role") // 身份
subject String? @map("subject") //科目
course String? @map("course") // 课目
trainTime Float? @map("train_time") // 培训时长 trainTime Float? @map("train_time") // 培训时长
content String? @map("content") // 内容 content String? @map("content") // 内容
meta Json? @map("meta") // 其他信息 meta Json? @map("meta") // 其他信息
@@index([day]) @@index([day])
@@index([major])
@@index([subject])
@@index([course])
@@map("train_plan") @@map("train_plan")
} }
model Outline {
id String @id @default(cuid())
major Term[] @relation("major_term") //专业
identity Term[] @relation("identity_term") //身份
subject Term[] @relation("subject_term") //科目
courses Course[] @relation("course") //课目
daytime Float? @map("day_time") //昼间时长
nighttime Float? @map("night_time") //夜间时长
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @map("updated_at")
deletedAt DateTime? @map("deleted_at") // 删除时间,可为空
staffs Staff[] @relation("staff_outline")
trainplans TrainPlan[] @relation("train_plan_outline")
}
model Course {
id String @id @default(cuid())
outlineId String? @map("course_id")
outline Outline? @relation("course", fields: [outlineId], references: [id])
terms Term[] @relation("course_term")
daytime Float? @map("day_time") //昼间时长
nighttime Float? @map("night_time") //夜间时长
score String? @map("score") //成绩标准
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @map("updated_at")
deletedAt DateTime? @map("deleted_at") // 删除时间,可为空
@@map("course")
@@index([score])
}
model Sport{
id String @id @default(cuid())
type String? @map("type") // 基础、站斗、实用
name String? @map("name") // 名称
standard Json? @map("standard") // 标准
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @map("updated_at")
deletedAt DateTime? @map("deleted_at") // 删除时间,可为空
}
model Subject { model Subject {
id String @id @default(cuid()) id String @id @default(cuid())
name String @map("name") name String @map("name")
terms Term[] @relation("subject_term")
parentId String? @map("parent_id") parentId String? @map("parent_id")
parent Subject? @relation("SubjectChildren", fields: [parentId], references: [id]) // 父级帖子,关联 Post 模型 parent Subject? @relation("SubjectChildren", fields: [parentId], references: [id]) // 父级帖子,关联 Post 模型
children Subject[] @relation("SubjectChildren") // 子级帖子列表,关联 Post 模型 children Subject[] @relation("SubjectChildren") // 子级帖子列表,关联 Post 模型