2024-09-03 20:19:33 +08:00
|
|
|
|
// This is your Prisma schema file,
|
|
|
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
|
|
|
|
|
|
generator client {
|
2024-12-30 08:26:40 +08:00
|
|
|
|
provider = "prisma-client-js"
|
2024-09-03 20:19:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datasource db {
|
2024-12-30 08:26:40 +08:00
|
|
|
|
provider = "postgresql"
|
|
|
|
|
url = env("DATABASE_URL")
|
2024-09-03 20:19:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Taxonomy {
|
2024-12-30 13:44:30 +08:00
|
|
|
|
id String @id @default(cuid())
|
2024-12-30 08:26:40 +08:00
|
|
|
|
name String @unique
|
|
|
|
|
slug String @unique @map("slug")
|
|
|
|
|
deletedAt DateTime? @map("deleted_at")
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
terms Term[]
|
|
|
|
|
objectType String[] @map("object_type")
|
|
|
|
|
order Float? @map("order")
|
2024-09-03 20:19:33 +08:00
|
|
|
|
|
2024-12-30 08:26:40 +08:00
|
|
|
|
@@index([order, deletedAt])
|
|
|
|
|
@@map("taxonomy")
|
2024-09-03 20:19:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Term {
|
2024-12-30 13:44:30 +08:00
|
|
|
|
id String @id @default(cuid())
|
2024-12-30 08:26:40 +08:00
|
|
|
|
name String
|
|
|
|
|
taxonomy Taxonomy? @relation(fields: [taxonomyId], references: [id])
|
|
|
|
|
taxonomyId String? @map("taxonomy_id")
|
|
|
|
|
order Float? @map("order")
|
|
|
|
|
description String?
|
|
|
|
|
parentId String? @map("parent_id")
|
|
|
|
|
parent Term? @relation("ChildParent", fields: [parentId], references: [id], onDelete: Cascade)
|
|
|
|
|
children Term[] @relation("ChildParent")
|
|
|
|
|
ancestors TermAncestry[] @relation("DescendantToAncestor")
|
|
|
|
|
descendants TermAncestry[] @relation("AncestorToDescendant")
|
|
|
|
|
domainId String? @map("domain_id")
|
|
|
|
|
domain Department? @relation("TermDom", fields: [domainId], references: [id])
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
|
deletedAt DateTime? @map("deleted_at")
|
|
|
|
|
createdBy String? @map("created_by")
|
|
|
|
|
depts Department[] @relation("department_term")
|
|
|
|
|
hasChildren Boolean? @default(false) @map("has_children")
|
2025-02-21 13:20:15 +08:00
|
|
|
|
posts Post[] @relation("post_term")
|
|
|
|
|
|
2024-12-30 08:26:40 +08:00
|
|
|
|
@@index([name]) // 对name字段建立索引,以加快基于name的查找速度
|
|
|
|
|
@@index([parentId]) // 对parentId字段建立索引,以加快基于parentId的查找速度
|
|
|
|
|
@@map("term")
|
2024-09-03 20:19:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model TermAncestry {
|
2024-12-30 13:44:30 +08:00
|
|
|
|
id String @id @default(cuid())
|
2024-12-30 08:26:40 +08:00
|
|
|
|
ancestorId String? @map("ancestor_id")
|
|
|
|
|
descendantId String @map("descendant_id")
|
|
|
|
|
relDepth Int @map("rel_depth")
|
|
|
|
|
ancestor Term? @relation("AncestorToDescendant", fields: [ancestorId], references: [id])
|
|
|
|
|
descendant Term @relation("DescendantToAncestor", fields: [descendantId], references: [id])
|
2024-09-03 20:19:33 +08:00
|
|
|
|
|
2024-12-30 08:26:40 +08:00
|
|
|
|
// 索引建议
|
|
|
|
|
@@index([ancestorId]) // 针对祖先的查询
|
|
|
|
|
@@index([descendantId]) // 针对后代的查询
|
|
|
|
|
@@index([ancestorId, descendantId]) // 组合索引,用于查询特定的祖先-后代关系
|
|
|
|
|
@@index([relDepth]) // 根据关系深度的查询
|
|
|
|
|
@@map("term_ancestry")
|
2024-09-03 20:19:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model DeptAncestry {
|
2024-12-30 13:44:30 +08:00
|
|
|
|
id String @id @default(cuid())
|
2024-12-30 08:26:40 +08:00
|
|
|
|
ancestorId String? @map("ancestor_id")
|
|
|
|
|
descendantId String @map("descendant_id")
|
|
|
|
|
relDepth Int @map("rel_depth")
|
|
|
|
|
ancestor Department? @relation("AncestorToDescendant", fields: [ancestorId], references: [id])
|
|
|
|
|
descendant Department @relation("DescendantToAncestor", fields: [descendantId], references: [id])
|
|
|
|
|
|
|
|
|
|
// 索引建议
|
|
|
|
|
@@index([ancestorId]) // 针对祖先的查询
|
|
|
|
|
@@index([descendantId]) // 针对后代的查询
|
|
|
|
|
@@index([ancestorId, descendantId]) // 组合索引,用于查询特定的祖先-后代关系
|
|
|
|
|
@@index([relDepth]) // 根据关系深度的查询
|
|
|
|
|
@@map("dept_ancestry")
|
2024-09-03 20:19:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model RoleMap {
|
2024-12-30 13:44:30 +08:00
|
|
|
|
id String @id @default(cuid())
|
2024-12-30 08:26:40 +08:00
|
|
|
|
objectId String @map("object_id")
|
|
|
|
|
roleId String @map("role_id")
|
|
|
|
|
domainId String? @map("domain_id")
|
|
|
|
|
objectType String @map("object_type")
|
|
|
|
|
role Role @relation(fields: [roleId], references: [id])
|
|
|
|
|
|
|
|
|
|
@@index([domainId])
|
|
|
|
|
@@index([objectId])
|
|
|
|
|
@@map("rolemap")
|
2024-09-03 20:19:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Role {
|
2024-12-30 13:44:30 +08:00
|
|
|
|
id String @id @default(cuid())
|
2024-12-30 08:26:40 +08:00
|
|
|
|
name String @unique @map("name")
|
|
|
|
|
permissions String[] @default([]) @map("permissions")
|
|
|
|
|
roleMaps RoleMap[]
|
|
|
|
|
system Boolean? @default(false) @map("system")
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
|
deletedAt DateTime? @map("deleted_at")
|
|
|
|
|
|
|
|
|
|
@@map("role")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model AppConfig {
|
2024-12-30 13:44:30 +08:00
|
|
|
|
id String @id @default(cuid())
|
2024-12-30 08:26:40 +08:00
|
|
|
|
slug String @unique
|
|
|
|
|
title String?
|
|
|
|
|
description String?
|
|
|
|
|
meta Json?
|
|
|
|
|
|
|
|
|
|
@@map("app_config")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Post {
|
2024-12-31 15:57:32 +08:00
|
|
|
|
// 字符串类型字段
|
2025-03-11 16:15:05 +08:00
|
|
|
|
id String @id @default(cuid()) // 帖子唯一标识,使用 cuid() 生成默认值
|
|
|
|
|
type String? // Post类型,课程、章节、小节、讨论都用Post实现
|
|
|
|
|
level String?
|
|
|
|
|
state String?
|
|
|
|
|
title String? // 帖子标题,可为空
|
|
|
|
|
subTitle String?
|
|
|
|
|
content String? // 帖子内容,可为空
|
|
|
|
|
important Boolean? //是否重要/精选/突出
|
|
|
|
|
domainId String? @map("domain_id")
|
|
|
|
|
terms Term[] @relation("post_term")
|
|
|
|
|
order Float? @default(0) @map("order")
|
|
|
|
|
duration Int?
|
|
|
|
|
rating Int? @default(0)
|
|
|
|
|
students Staff[] @relation("post_student")
|
|
|
|
|
depts Department[] @relation("post_dept")
|
|
|
|
|
views Int @default(0) @map("views")
|
|
|
|
|
hates Int @default(0) @map("hates")
|
|
|
|
|
likes Int @default(0) @map("likes")
|
2025-02-21 13:14:47 +08:00
|
|
|
|
// 索引
|
2024-12-31 15:57:32 +08:00
|
|
|
|
// 日期时间类型字段
|
2025-03-11 16:15:05 +08:00
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
publishedAt DateTime? @map("published_at") // 发布时间
|
|
|
|
|
updatedAt DateTime @map("updated_at")
|
|
|
|
|
deletedAt DateTime? @map("deleted_at") // 删除时间,可为空
|
|
|
|
|
instructors PostInstructor[]
|
2024-12-31 15:57:32 +08:00
|
|
|
|
// 关系类型字段
|
2025-03-11 16:15:05 +08:00
|
|
|
|
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 模型
|
|
|
|
|
hasChildren Boolean? @default(false) @map("has_children")
|
2025-02-21 13:20:15 +08:00
|
|
|
|
// 闭包表关系
|
2025-03-11 16:15:05 +08:00
|
|
|
|
ancestors PostAncestry[] @relation("DescendantPosts")
|
|
|
|
|
descendants PostAncestry[] @relation("AncestorPosts")
|
|
|
|
|
resources Resource[] // 附件列表
|
|
|
|
|
meta Json? // 封面url 视频url objectives具体的学习目标 rating评分Int
|
2025-02-21 13:20:15 +08:00
|
|
|
|
|
2025-02-06 16:32:52 +08:00
|
|
|
|
// 索引
|
|
|
|
|
@@index([type, domainId])
|
|
|
|
|
@@index([authorId, type])
|
|
|
|
|
@@index([parentId, type])
|
|
|
|
|
@@index([parentId, order])
|
|
|
|
|
@@index([createdAt])
|
|
|
|
|
@@index([updatedAt])
|
|
|
|
|
@@index([type, publishedAt])
|
|
|
|
|
@@index([state])
|
|
|
|
|
@@index([level])
|
2025-02-27 22:37:15 +08:00
|
|
|
|
@@index([views])
|
2025-02-06 16:32:52 +08:00
|
|
|
|
@@index([important])
|
|
|
|
|
@@map("post")
|
|
|
|
|
}
|
2024-12-30 08:26:40 +08:00
|
|
|
|
|
2025-02-06 16:32:52 +08:00
|
|
|
|
model PostAncestry {
|
2025-03-11 16:15:05 +08:00
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
ancestorId String? @map("ancestor_id")
|
|
|
|
|
descendantId String @map("descendant_id")
|
|
|
|
|
relDepth Int @map("rel_depth")
|
|
|
|
|
ancestor Post? @relation("AncestorPosts", fields: [ancestorId], references: [id])
|
|
|
|
|
descendant Post @relation("DescendantPosts", fields: [descendantId], references: [id])
|
|
|
|
|
|
2025-02-06 16:32:52 +08:00
|
|
|
|
// 复合索引优化
|
2025-02-21 13:20:15 +08:00
|
|
|
|
// 索引建议
|
2025-02-06 16:32:52 +08:00
|
|
|
|
@@index([ancestorId]) // 针对祖先的查询
|
|
|
|
|
@@index([descendantId]) // 针对后代的查询
|
|
|
|
|
@@index([ancestorId, descendantId]) // 组合索引,用于查询特定的祖先-后代关系
|
|
|
|
|
@@index([relDepth]) // 根据关系深度的查询
|
|
|
|
|
@@map("post_ancestry")
|
2024-12-30 08:26:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Message {
|
2024-12-31 15:57:32 +08:00
|
|
|
|
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[]
|
2025-03-02 16:45:34 +08:00
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
2024-12-31 15:57:32 +08:00
|
|
|
|
updatedAt DateTime? @updatedAt @map("updated_at")
|
2025-03-11 16:15:05 +08:00
|
|
|
|
|
2024-12-31 15:57:32 +08:00
|
|
|
|
@@index([type, createdAt])
|
2024-12-30 08:26:40 +08:00
|
|
|
|
@@map("message")
|
|
|
|
|
}
|
2025-01-21 19:48:54 +08:00
|
|
|
|
|
2024-12-30 08:26:40 +08:00
|
|
|
|
model Visit {
|
2025-03-11 16:15:05 +08:00
|
|
|
|
id String @id @default(cuid()) @map("id")
|
2025-01-21 19:48:54 +08:00
|
|
|
|
type String?
|
2025-03-11 16:15:05 +08:00
|
|
|
|
views Int @default(1) @map("views")
|
2025-01-21 19:48:54 +08:00
|
|
|
|
// sourceIP String? @map("source_ip")
|
2024-12-31 15:57:32 +08:00
|
|
|
|
// 关联关系
|
2025-02-28 09:23:36 +08:00
|
|
|
|
visitorId String? @map("visitor_id")
|
|
|
|
|
visitor Staff? @relation(fields: [visitorId], references: [id])
|
2025-03-11 16:15:05 +08:00
|
|
|
|
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
|
2025-02-21 13:20:15 +08:00
|
|
|
|
createdAt DateTime @default(now()) @map("created_at") // 创建时间
|
|
|
|
|
updatedAt DateTime @updatedAt @map("updated_at") // 更新时间
|
2025-02-06 16:32:52 +08:00
|
|
|
|
deletedAt DateTime? @map("deleted_at") // 删除时间,可为空
|
2025-02-21 13:20:15 +08:00
|
|
|
|
meta Json?
|
2025-01-21 19:48:54 +08:00
|
|
|
|
|
2024-12-31 15:57:32 +08:00
|
|
|
|
@@index([postId, type, visitorId])
|
|
|
|
|
@@index([messageId, type, visitorId])
|
2024-12-30 08:26:40 +08:00
|
|
|
|
@@map("visit")
|
2024-09-03 20:19:33 +08:00
|
|
|
|
}
|
2024-12-30 13:44:30 +08:00
|
|
|
|
|
2024-12-31 15:57:32 +08:00
|
|
|
|
model Enrollment {
|
|
|
|
|
id String @id @default(cuid()) @map("id")
|
|
|
|
|
status String @map("status")
|
|
|
|
|
completionRate Float @default(0) @map("completion_rate")
|
2024-12-30 13:44:30 +08:00
|
|
|
|
|
2025-01-21 19:48:54 +08:00
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
|
completedAt DateTime? @map("completed_at")
|
2024-12-30 13:44:30 +08:00
|
|
|
|
|
|
|
|
|
// 关联关系
|
2025-01-21 19:48:54 +08:00
|
|
|
|
student Staff @relation(fields: [studentId], references: [id])
|
|
|
|
|
studentId String @map("student_id")
|
2025-02-21 13:20:15 +08:00
|
|
|
|
post Post @relation(fields: [postId], references: [id])
|
|
|
|
|
postId String @map("post_id")
|
2024-12-31 15:57:32 +08:00
|
|
|
|
|
2025-02-06 16:32:52 +08:00
|
|
|
|
@@unique([studentId, postId])
|
2024-12-31 15:57:32 +08:00
|
|
|
|
@@index([status])
|
|
|
|
|
@@index([completedAt])
|
|
|
|
|
@@map("enrollment")
|
2024-12-30 13:44:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-06 16:32:52 +08:00
|
|
|
|
model PostInstructor {
|
2025-02-21 13:20:15 +08:00
|
|
|
|
postId String @map("post_id")
|
2024-12-31 15:57:32 +08:00
|
|
|
|
instructorId String @map("instructor_id")
|
|
|
|
|
role String @map("role")
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
order Float? @default(0) @map("order")
|
2024-12-30 13:44:30 +08:00
|
|
|
|
|
2025-02-21 13:20:15 +08:00
|
|
|
|
post Post @relation(fields: [postId], references: [id])
|
|
|
|
|
instructor Staff @relation(fields: [instructorId], references: [id])
|
2024-12-30 13:44:30 +08:00
|
|
|
|
|
2025-02-06 16:32:52 +08:00
|
|
|
|
@@id([postId, instructorId])
|
|
|
|
|
@@map("post_instructor")
|
2024-12-30 13:44:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Resource {
|
2025-01-06 18:30:16 +08:00
|
|
|
|
id String @id @default(cuid()) @map("id")
|
|
|
|
|
title String? @map("title")
|
|
|
|
|
description String? @map("description")
|
|
|
|
|
type String? @map("type")
|
|
|
|
|
fileId String? @unique
|
|
|
|
|
url String?
|
2025-01-03 09:24:46 +08:00
|
|
|
|
// 元数据
|
2025-02-21 13:20:15 +08:00
|
|
|
|
meta Json? @map("meta")
|
2025-01-03 09:24:46 +08:00
|
|
|
|
// 处理状态控制
|
2025-01-06 18:30:16 +08:00
|
|
|
|
status String?
|
|
|
|
|
createdAt DateTime? @default(now()) @map("created_at")
|
|
|
|
|
updatedAt DateTime? @updatedAt @map("updated_at")
|
|
|
|
|
createdBy String? @map("created_by")
|
|
|
|
|
updatedBy String? @map("updated_by")
|
|
|
|
|
deletedAt DateTime? @map("deleted_at")
|
|
|
|
|
isPublic Boolean? @default(true) @map("is_public")
|
2025-01-21 19:48:54 +08:00
|
|
|
|
owner Staff? @relation(fields: [ownerId], references: [id])
|
|
|
|
|
ownerId String? @map("owner_id")
|
|
|
|
|
post Post? @relation(fields: [postId], references: [id])
|
|
|
|
|
postId String? @map("post_id")
|
2025-02-21 13:20:15 +08:00
|
|
|
|
|
2025-01-03 09:24:46 +08:00
|
|
|
|
// 索引
|
2024-12-31 15:57:32 +08:00
|
|
|
|
@@index([type])
|
2025-01-03 09:24:46 +08:00
|
|
|
|
@@index([createdAt])
|
2024-12-31 15:57:32 +08:00
|
|
|
|
@@map("resource")
|
2024-12-30 13:44:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Node {
|
2024-12-31 15:57:32 +08:00
|
|
|
|
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")
|
2024-12-30 13:44:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model NodeEdge {
|
2024-12-31 15:57:32 +08:00
|
|
|
|
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")
|
2024-12-30 13:44:30 +08:00
|
|
|
|
|
|
|
|
|
@@unique([sourceId, targetId, type])
|
|
|
|
|
@@index([sourceId])
|
|
|
|
|
@@index([targetId])
|
2024-12-31 15:57:32 +08:00
|
|
|
|
@@map("node_edge")
|
2024-12-30 13:44:30 +08:00
|
|
|
|
}
|
2025-03-11 16:15:05 +08:00
|
|
|
|
|
2025-03-10 20:31:05 +08:00
|
|
|
|
model TrainContent {
|
2025-03-11 16:21:21 +08:00
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
title String @map("title")
|
|
|
|
|
trainSituations TrainSituation[]
|
2025-03-12 16:34:43 +08:00
|
|
|
|
trainPlans TrainPlan[] @relation("TrainPlanContent")
|
|
|
|
|
|
2025-03-12 19:38:28 +08:00
|
|
|
|
type String @map("type")
|
|
|
|
|
parentId String? @map("parent_id")
|
|
|
|
|
parent TrainContent? @relation("ContentParent", fields: [parentId], references: [id]) // 指向自身
|
|
|
|
|
children TrainContent[] @relation("ContentParent") // 指向自身
|
|
|
|
|
deletedAt DateTime? @map("deleted_at")
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
2025-03-11 16:15:05 +08:00
|
|
|
|
|
|
|
|
|
@@map("train_content")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model TrainSituation {
|
2025-03-11 16:21:21 +08:00
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
|
2025-03-11 16:15:05 +08:00
|
|
|
|
staffId String @map("staff_id")
|
|
|
|
|
staff Staff @relation(fields: [staffId], references: [id])
|
|
|
|
|
trainContentId String @map("train_content_id")
|
|
|
|
|
trainContent TrainContent @relation(fields: [trainContentId], references: [id])
|
|
|
|
|
|
2025-03-12 08:25:08 +08:00
|
|
|
|
score Float @default(0.0) @map("score")
|
|
|
|
|
mustTrainTime Float @map("must_train_time")
|
|
|
|
|
alreadyTrainTime Float @map("already_train_time")
|
|
|
|
|
dailyTrainTime DailyTrainTime[] @relation("DailyTrainSituation")
|
2025-03-11 16:21:21 +08:00
|
|
|
|
|
2025-03-11 16:15:05 +08:00
|
|
|
|
@@map("train_situation")
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-11 22:36:54 +08:00
|
|
|
|
model DailyTrainTime {
|
2025-03-12 08:25:08 +08:00
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
trainSituationId String @map("train_situatio_id")
|
|
|
|
|
trainSituation TrainSituation @relation("DailyTrainSituation", fields: [trainSituationId], references: [id])
|
|
|
|
|
trainTime Float @default(0.0) @map("trainTime")
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
|
2025-03-11 22:36:54 +08:00
|
|
|
|
@@map("daily_train_situation")
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-11 16:15:05 +08:00
|
|
|
|
model Position {
|
|
|
|
|
id String @id @default(cuid()) @map("id")
|
|
|
|
|
type String @map("type")
|
|
|
|
|
|
|
|
|
|
staff Staff[] @relation("StaffPosition")
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
2025-03-10 20:31:05 +08:00
|
|
|
|
|
2025-03-11 16:15:05 +08:00
|
|
|
|
@@map("position")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Department {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
name String
|
|
|
|
|
order Float?
|
|
|
|
|
posts Post[] @relation("post_dept")
|
|
|
|
|
ancestors DeptAncestry[] @relation("DescendantToAncestor")
|
|
|
|
|
descendants DeptAncestry[] @relation("AncestorToDescendant")
|
2025-03-10 20:31:05 +08:00
|
|
|
|
parentId String? @map("parent_id")
|
2025-03-11 16:15:05 +08:00
|
|
|
|
parent Department? @relation("ChildParent", fields: [parentId], references: [id])
|
|
|
|
|
children Department[] @relation("ChildParent")
|
|
|
|
|
domainId String? @map("domain_id")
|
|
|
|
|
domainTerms Term[] @relation("TermDom")
|
|
|
|
|
deletedAt DateTime? @map("deleted_at")
|
|
|
|
|
isDomain Boolean? @default(false) @map("is_domain")
|
|
|
|
|
domainStaffs Staff[] @relation("DomainStaff")
|
|
|
|
|
deptStaffs Staff[] @relation("DeptStaff")
|
|
|
|
|
terms Term[] @relation("department_term")
|
2025-03-10 20:31:05 +08:00
|
|
|
|
|
2025-03-12 19:38:28 +08:00
|
|
|
|
trainPlans TrainPlan[] @relation("TrainPlanDept")
|
|
|
|
|
|
2025-03-11 16:15:05 +08:00
|
|
|
|
// watchedPost Post[] @relation("post_watch_dept")
|
|
|
|
|
hasChildren Boolean? @default(false) @map("has_children")
|
2025-03-10 20:31:05 +08:00
|
|
|
|
|
2025-03-11 16:15:05 +08:00
|
|
|
|
@@index([parentId])
|
|
|
|
|
@@index([isDomain])
|
|
|
|
|
@@index([name])
|
|
|
|
|
@@index([order])
|
|
|
|
|
@@map("department")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Staff {
|
2025-03-19 15:57:48 +08:00
|
|
|
|
// 基础信息
|
2025-03-11 16:15:05 +08:00
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
username String @unique @map("username")
|
|
|
|
|
password String? @map("password")
|
2025-03-19 15:57:48 +08:00
|
|
|
|
showname String? @map("showname")
|
|
|
|
|
avatar String? @map("avatar")
|
|
|
|
|
enabled Boolean? @default(true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 个人基本信息
|
|
|
|
|
idNumber String? @unique @map("id_number") // 身份证号
|
|
|
|
|
type String? @map("type") // 人员类型
|
|
|
|
|
officerId String? @unique @map("officer_id") // 警号
|
|
|
|
|
phoneNumber String? @unique @map("phone_number") // 手机号
|
|
|
|
|
age Int? @map("age") // 年龄
|
|
|
|
|
sex Boolean? @map("sex") // 性别
|
|
|
|
|
bloodType String? @map("blood_type") // 血型
|
|
|
|
|
birthplace String? @map("birthplace") // 籍贯
|
|
|
|
|
source String? @map("source") // 来源
|
|
|
|
|
|
|
|
|
|
// 政治信息
|
|
|
|
|
politicalStatus String? @map("political_status") // 政治面貌
|
|
|
|
|
partyPosition String? @map("party_position") // 党内职务
|
|
|
|
|
|
|
|
|
|
// 职务信息
|
|
|
|
|
rank String? @map("rank") // 衔职级别
|
|
|
|
|
rankDate DateTime? @map("rank_date") // 衔职时间
|
|
|
|
|
proxyPosition String? @map("proxy_position") // 代理职务
|
2025-03-20 23:09:41 +08:00
|
|
|
|
post String? @map("post") // 岗位
|
|
|
|
|
|
2025-03-19 15:57:48 +08:00
|
|
|
|
|
|
|
|
|
// 入职相关信息
|
|
|
|
|
hireDate DateTime? @map("hire_date") // 入职时间
|
|
|
|
|
seniority DateTime? @map("seniority_date") // 工龄认定时间
|
|
|
|
|
sourceType String? @map("source_type") // 来源类型
|
|
|
|
|
isReentry Boolean? @default(false) @map("is_reentry") // 是否二次入职
|
|
|
|
|
isExtended Boolean? @default(false) @map("is_extended") // 是否延期服役
|
|
|
|
|
currentPositionDate DateTime? @map("current_position_date") // 现岗位开始时间
|
|
|
|
|
|
|
|
|
|
// 教育背景
|
|
|
|
|
education String? @map("education") // 学历
|
|
|
|
|
educationType String? @map("education_type") // 学历形式
|
|
|
|
|
isGraduated Boolean? @default(true) @map("is_graduated") // 是否毕业
|
|
|
|
|
major String? @map("major") // 专业
|
|
|
|
|
foreignLang String? @map("foreign_lang") // 外语能力
|
|
|
|
|
|
|
|
|
|
// 培训
|
|
|
|
|
trainType String? @map("train_type") // 培训类型
|
|
|
|
|
trainInstitute String? @map("train_institute") // 培训机构
|
|
|
|
|
trainMajor String? @map("train_major") // 培训专业
|
|
|
|
|
hasTrain Boolean? @default(false) @map("has_train") // 是否参加培训
|
|
|
|
|
|
|
|
|
|
//鉴定
|
|
|
|
|
certRank String? @map("cert_rank") // 鉴定等级
|
|
|
|
|
certWork String? @map("cert_work") // 鉴定工种
|
|
|
|
|
hasCert Boolean? @default(false) @map("has_cert") // 是否参加鉴定
|
|
|
|
|
|
|
|
|
|
// 工作信息
|
|
|
|
|
equipment String? @map("equipment") // 操作维护装备
|
|
|
|
|
projects String? @map("projects") // 演训任务经历
|
|
|
|
|
awards String? @map("awards") // 奖励信息
|
|
|
|
|
punishments String? @map("staff_punishments") // 处分信息
|
|
|
|
|
|
|
|
|
|
// 部门关系
|
|
|
|
|
domainId String? @map("domain_id")
|
|
|
|
|
deptId String? @map("dept_id")
|
|
|
|
|
domain Department? @relation("DomainStaff", fields: [domainId], references: [id])
|
|
|
|
|
department Department? @relation("DeptStaff", fields: [deptId], references: [id])
|
|
|
|
|
order Float?
|
2025-03-11 16:15:05 +08:00
|
|
|
|
|
2025-03-19 15:57:48 +08:00
|
|
|
|
// 关联关系
|
2025-03-11 16:15:05 +08:00
|
|
|
|
trainSituations TrainSituation[]
|
2025-03-19 15:57:48 +08:00
|
|
|
|
visits Visit[]
|
|
|
|
|
posts Post[]
|
|
|
|
|
learningPosts Post[] @relation("post_student")
|
|
|
|
|
sentMsgs Message[] @relation("message_sender")
|
|
|
|
|
receivedMsgs Message[] @relation("message_receiver")
|
|
|
|
|
enrollments Enrollment[]
|
|
|
|
|
teachedPosts PostInstructor[]
|
|
|
|
|
ownedResources Resource[]
|
2025-03-20 23:09:41 +08:00
|
|
|
|
position Position? @relation("StaffPosition", fields: [positionId], references: [id])
|
|
|
|
|
positionId String? @map("position_id")
|
2025-03-19 15:57:48 +08:00
|
|
|
|
// 系统信息
|
|
|
|
|
registerToken String?
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
|
deletedAt DateTime? @map("deleted_at")
|
|
|
|
|
absent Boolean? @default(false) @map("absent")
|
2025-03-11 16:15:05 +08:00
|
|
|
|
|
|
|
|
|
@@index([officerId])
|
|
|
|
|
@@index([deptId])
|
|
|
|
|
@@index([domainId])
|
|
|
|
|
@@index([username])
|
|
|
|
|
@@index([order])
|
|
|
|
|
@@map("staff")
|
2025-03-11 16:21:21 +08:00
|
|
|
|
}
|
2025-03-12 16:34:43 +08:00
|
|
|
|
|
|
|
|
|
model TrainPlan {
|
2025-03-12 19:38:28 +08:00
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
|
|
|
|
|
trainDate DateTime @map("train_date")
|
|
|
|
|
trainTime DateTime @map("train_time")
|
|
|
|
|
trainType String @map("train_type")
|
|
|
|
|
trainContext String @map("train_context")
|
|
|
|
|
|
2025-03-12 16:34:43 +08:00
|
|
|
|
trainContents TrainContent[] @relation("TrainPlanContent")
|
2025-03-12 19:38:28 +08:00
|
|
|
|
departmentId String? @map("department_id")
|
|
|
|
|
department Department? @relation("TrainPlanDept", fields: [departmentId], references: [id])
|
2025-03-12 16:34:43 +08:00
|
|
|
|
|
2025-03-12 19:38:28 +08:00
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
|
deletedAt DateTime? @map("deleted_at")
|
2025-03-12 16:34:43 +08:00
|
|
|
|
|
|
|
|
|
@@map("train_plan")
|
|
|
|
|
}
|
2025-03-21 10:55:44 +08:00
|
|
|
|
|
|
|
|
|
model ShareCode {
|
|
|
|
|
id String @id @default(cuid())
|
2025-03-21 17:25:39 +08:00
|
|
|
|
code String? @unique
|
|
|
|
|
fileId String? @unique
|
2025-03-21 10:55:44 +08:00
|
|
|
|
createdAt DateTime @default(now())
|
2025-03-21 17:25:39 +08:00
|
|
|
|
expiresAt DateTime? @map("expires_at")
|
|
|
|
|
isUsed Boolean? @default(false)
|
|
|
|
|
fileName String? @map("file_name")
|
2025-03-21 10:55:44 +08:00
|
|
|
|
@@index([code])
|
|
|
|
|
@@index([fileId])
|
|
|
|
|
@@index([expiresAt])
|
|
|
|
|
}
|