From 90204d78b624542847a1f0e6374bee502b76d99b Mon Sep 17 00:00:00 2001 From: linfeng <2819853134@qq.com> Date: Fri, 25 Apr 2025 11:41:29 +0800 Subject: [PATCH] lin --- packages/common/prisma/schema.prisma | 87 +++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 16 deletions(-) diff --git a/packages/common/prisma/schema.prisma b/packages/common/prisma/schema.prisma index 82d6dc6..3ecf60d 100755 --- a/packages/common/prisma/schema.prisma +++ b/packages/common/prisma/schema.prisma @@ -47,13 +47,20 @@ model Term { plan Plan? @relation(fields: [planId], references: [id]) planId String? plans Plan[] @relation("plan_term") - subject Subject? @relation(fields: [subjectId], references: [id], name: "subject_term") - subjectId String? 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([parentId]) // 对parentId字段建立索引,以加快基于parentId的查找速度 @@map("term") + + } model TermAncestry { @@ -166,6 +173,9 @@ model Department { domainStaffs Staff[] @relation("DomainStaff") deptStaffs Staff[] @relation("DeptStaff") terms Term[] @relation("department_term") + progress Json? @map("progress") //单位训练进度表 + score Json? @map("score") //单位成绩评定表 + // watchedPost Post[] @relation("post_watch_dept") hasChildren Boolean? @default(false) @map("has_children") @@ -193,6 +203,9 @@ model Staff { subjects Subject[] @relation("staff_subject") domainId String? @map("domain_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]) department Department? @relation("DeptStaff", fields: [deptId], references: [id]) @@ -228,12 +241,12 @@ model Plan { updatedAt DateTime @map("updated_at") deletedAt DateTime? @map("deleted_at") // 删除时间,可为空 - terms Term[] @relation("plan_term") - termRefs Term[] - checked Boolean @default(false) @map("checked") - depts Department[] @relation("plan_dept") - meta Json? @map("meta") // 计划表 - trainPlans TrainPlan[] + terms Term[] @relation("plan_term") + termRefs Term[] + checked Boolean @default(false) @map("checked") + depts Department[] @relation("plan_dept") + meta Json? @map("meta") // 计划表 + trainPlans TrainPlan[] @@map("plan") } @@ -251,25 +264,67 @@ model TrainPlan { terms Term[] @relation("TrainPlanTerm") day DateTime? @map("day") // 日期 dayType String? @map("day_type") // 早中晚 - major String? @map("major") // 专业 - role String? @map("role") // 身份 - subject String? @map("subject") //科目 - course String? @map("course") // 课目 + outlines Outline[] @relation("train_plan_outline") trainTime Float? @map("train_time") // 培训时长 content String? @map("content") // 内容 meta Json? @map("meta") // 其他信息 @@index([day]) - @@index([major]) - @@index([subject]) - @@index([course]) @@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 { id String @id @default(cuid()) name String @map("name") - terms Term[] @relation("subject_term") parentId String? @map("parent_id") parent Subject? @relation("SubjectChildren", fields: [parentId], references: [id]) // 父级帖子,关联 Post 模型 children Subject[] @relation("SubjectChildren") // 子级帖子列表,关联 Post 模型