一、灵动岛(用户反馈的三处"点不开"全部修复)
- 非紧急叫人:上课时段仍以胶囊保持可见、可点开(不再只进队列导致屏幕上什么都没有);
新增 isOpenable():紧急消息 + 任何"叫人"都允许点开,但普通叫人不会自动展开打断课堂。
- 紧急叫人收起后再点:命中改为"主进程按光标位置兜底校正"(上一轮的 island:set-hit-rect 轮询),
本轮补齐叫人类专项回归(展开 → 收起 → 再次点开)。
- 设置页预览:新增 preview 通道 —— 示例岛直接展开、失焦不收起、30 秒自行消失、关掉不残留。
- 收起态胶囊汇总消息类型:多条时显示「新消息:叫人/作业/通知(共 3 条)」+「点击查看」+ 类型小标签。
- 顺带修掉两个真问题:胶囊态收到新消息会把上一条静默顶掉(现在一律回队);
syncWindow 的上课时段守卫只认"紧急"导致普通叫人被藏掉。
- 性能:岛体矩形上报限流(~10 次/秒 + 尾随补发),修掉每帧 IPC 导致的开合采样骤降。
二、作业(学生端 + Web 教师端)
- 新增**看板模式**:按科目分卡片、点卡片放大全屏、工具栏可切「看板/列表」、
开关「显示时间」、拖「看板字号」(11–28px),偏好持久化到客户端配置 homeworkBoard。
- 去掉「全班标记完成」,改为**未交名单**:勾选没交的同学,其余自动标记已交;
新增 GET/PATCH /api/homeworks/:id/submissions(教师与班级设备可用,普通学生 403)。
三、课表单双周 + ClassIsland 课程表导入
- Schedule 新增 weekParity(ALL/ODD/EVEN)+ 迁移;周视图与上课判定按「第 1 周=单周」过滤,
历史数据默认 ALL 行为不变;Web 手动新增/编辑课表可选单双周,学生端课表打「单周/双周」标签。
- 修复既有 P0 bug:ClassIsland 真实档案里 TimeLayouts 是 "Guid → { Name, Layouts }" 字典,
旧解析器只认数组/.items,导致**真实导出完全导不进来**;现已按真实形态解析(并兼容旧写法),
同时补上 TimeType=3(行动)映射。
- 新增 ClassIsland 课程表(ClassPlan)导入:解析 TimeRule.WeekCountDiv/WeekCountDivTotal → 单双周,
Classes[i] 对齐第 i 个 TimeType=0 的时间点,Subjects 映射科目(缺失自动补建课程),
星期 0=周日 换算为 1=周一 … 7=周日;replace/merge 两种模式,预览只解析不写库。
- 新增维护脚本 packages/server/scripts/apply-parity-column.cjs(手工覆盖 dist 部署时补列用)。
验证:verify:e2e 148/148(新增单双周 12 项 + 课程表导入 5 项)、verify:desktop 71/71(复跑 65/65)、
verify:web 20/20、typecheck / lint / format 全绿;服务端与 Web 已重新打包并部署到本机安装目录。
263 lines
8.2 KiB
Plaintext
263 lines
8.2 KiB
Plaintext
// 班级小助手 - 数据模型
|
|
//
|
|
// 设计说明:
|
|
// 1) 本 schema 使用 sqlite provider(本地 MVP / 离线开发)。
|
|
// 字段全部使用 String / Int / Float / Boolean / DateTime 等跨库通用类型,
|
|
// 不使用 Prisma enum 与 @db.* 原生类型,因此可平移到 MySQL。
|
|
// MySQL 版本见同目录 schema.mysql.prisma,切换步骤见 docs/mysql.md。
|
|
// 2) 角色与优先级用 String 存储('ADMIN' | 'TEACHER' | 'STUDENT'、
|
|
// 'LOW' | 'NORMAL' | 'HIGH' | 'URGENT'),在 API 层用 zod 校验,
|
|
// 这样 SQLite / MySQL 行为完全一致。
|
|
// 3) 所有主键使用 cuid 字符串,便于多端离线生成与合并。
|
|
|
|
generator client {
|
|
provider = "prisma-client"
|
|
output = "../src/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
}
|
|
|
|
/// 用户:教师 / 管理员 / 学生统一存储
|
|
model User {
|
|
id String @id @default(cuid())
|
|
username String @unique
|
|
passwordHash String
|
|
name String
|
|
role String @default("STUDENT")
|
|
classId String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
// 学生的主班级(一个学生属于一个主班级)
|
|
class Class? @relation("ClassStudents", fields: [classId], references: [id], onDelete: SetNull)
|
|
// 教师创建(负责)的班级
|
|
ownedClasses Class[] @relation("ClassOwner")
|
|
// 教师被分配协作的班级
|
|
classAssignments ClassTeacher[]
|
|
courses Course[]
|
|
homeworkStatuses HomeworkStatus[]
|
|
notificationReads NotificationRead[]
|
|
grades Grade[]
|
|
enrollments Enrollment[]
|
|
createdHomeworks Homework[] @relation("HomeworkCreator")
|
|
createdNotices Notification[] @relation("NotificationCreator")
|
|
|
|
@@index([classId])
|
|
@@index([role])
|
|
}
|
|
|
|
/// 班级
|
|
model Class {
|
|
id String @id @default(cuid())
|
|
name String
|
|
grade String
|
|
teacherId String
|
|
/// 班级码:学生端「班级账号」登录用(唯一,字母数字,4~16 位,存大写)
|
|
code String @unique
|
|
/// 班级密码(bcrypt 哈希);null = 尚未设置,此时禁止班级账号登录
|
|
passwordHash String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
teacher User @relation("ClassOwner", fields: [teacherId], references: [id], onDelete: Cascade)
|
|
students User[] @relation("ClassStudents")
|
|
teachers ClassTeacher[]
|
|
courses Course[]
|
|
schedules Schedule[]
|
|
homeworks Homework[]
|
|
notifications Notification[]
|
|
grades Grade[]
|
|
enrollments Enrollment[]
|
|
timeLayouts TimeLayout[]
|
|
|
|
@@index([teacherId])
|
|
}
|
|
|
|
/// 教师-班级 分配关系(一个教师可管理多个班级)
|
|
model ClassTeacher {
|
|
id String @id @default(cuid())
|
|
classId String
|
|
teacherId String
|
|
createdAt DateTime @default(now())
|
|
|
|
class Class @relation(fields: [classId], references: [id], onDelete: Cascade)
|
|
teacher User @relation(fields: [teacherId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([classId, teacherId])
|
|
@@index([teacherId])
|
|
}
|
|
|
|
/// 学生-班级 选课/归属记录(与 User.classId 保持同步,支持未来多班)
|
|
model Enrollment {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
classId String
|
|
createdAt DateTime @default(now())
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
class Class @relation(fields: [classId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, classId])
|
|
@@index([classId])
|
|
}
|
|
|
|
/// 课程
|
|
model Course {
|
|
id String @id @default(cuid())
|
|
name String
|
|
teacherId String
|
|
classId String
|
|
createdAt DateTime @default(now())
|
|
|
|
teacher User @relation(fields: [teacherId], references: [id], onDelete: Cascade)
|
|
class Class @relation(fields: [classId], references: [id], onDelete: Cascade)
|
|
schedules Schedule[]
|
|
homeworks Homework[]
|
|
grades Grade[]
|
|
|
|
@@unique([classId, name])
|
|
@@index([classId])
|
|
}
|
|
|
|
/// 课表条目
|
|
model Schedule {
|
|
id String @id @default(cuid())
|
|
classId String
|
|
courseId String
|
|
/// 1=周一 ... 7=周日
|
|
dayOfWeek Int
|
|
/// HH:mm
|
|
startTime String
|
|
/// HH:mm
|
|
endTime String
|
|
location String?
|
|
/// 学期起始周次(含)
|
|
weekStart Int @default(1)
|
|
/// 学期结束周次(含)
|
|
weekEnd Int @default(20)
|
|
/// 单双周:ALL=每周(默认)/ ODD=单周 / EVEN=双周(ClassIsland WeekCountDiv + WeekCountDivTotal 的映射)
|
|
weekParity String @default("ALL")
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
class Class @relation(fields: [classId], references: [id], onDelete: Cascade)
|
|
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([classId, dayOfWeek])
|
|
@@index([courseId])
|
|
}
|
|
|
|
/// 作业
|
|
model Homework {
|
|
id String @id @default(cuid())
|
|
classId String
|
|
courseId String?
|
|
title String
|
|
content String
|
|
attachmentUrl String?
|
|
/// 遗留字段:作业"截止时间"功能已下线(UI/接口均不再读写)。
|
|
/// 保留列以免对已安装的库做破坏性迁移;新库该列恒为 null。
|
|
dueAt DateTime?
|
|
createdBy String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
class Class @relation(fields: [classId], references: [id], onDelete: Cascade)
|
|
course Course? @relation(fields: [courseId], references: [id], onDelete: SetNull)
|
|
creator User @relation("HomeworkCreator", fields: [createdBy], references: [id], onDelete: Cascade)
|
|
statuses HomeworkStatus[]
|
|
|
|
@@index([classId, createdAt])
|
|
@@index([courseId])
|
|
@@index([dueAt])
|
|
}
|
|
|
|
/// 学生作业完成状态
|
|
model HomeworkStatus {
|
|
id String @id @default(cuid())
|
|
homeworkId String
|
|
userId String
|
|
completed Boolean @default(false)
|
|
updatedAt DateTime @updatedAt
|
|
|
|
homework Homework @relation(fields: [homeworkId], references: [id], onDelete: Cascade)
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([homeworkId, userId])
|
|
@@index([userId])
|
|
}
|
|
|
|
/// 通知
|
|
model Notification {
|
|
id String @id @default(cuid())
|
|
classId String
|
|
title String
|
|
content String
|
|
priority String @default("NORMAL")
|
|
createdBy String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
class Class @relation(fields: [classId], references: [id], onDelete: Cascade)
|
|
creator User @relation("NotificationCreator", fields: [createdBy], references: [id], onDelete: Cascade)
|
|
reads NotificationRead[]
|
|
|
|
@@index([classId, createdAt])
|
|
}
|
|
|
|
/// 通知已读记录
|
|
model NotificationRead {
|
|
id String @id @default(cuid())
|
|
notificationId String
|
|
userId String
|
|
readAt DateTime @default(now())
|
|
|
|
notification Notification @relation(fields: [notificationId], references: [id], onDelete: Cascade)
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([notificationId, userId])
|
|
@@index([userId])
|
|
}
|
|
|
|
|
|
/// 课表时间配置(ClassIsland 同款 JSON 导入后的节次时间表)
|
|
model TimeLayout {
|
|
id String @id @default(cuid())
|
|
classId String
|
|
name String
|
|
/// 来源:classisland | manual
|
|
source String @default("classisland")
|
|
/// 节次数组(JSON 字符串):[{ index, name, startTime, endTime, type, skipped }]
|
|
items String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
class Class @relation(fields: [classId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([classId])
|
|
}
|
|
|
|
/// 成绩
|
|
model Grade {
|
|
id String @id @default(cuid())
|
|
classId String
|
|
courseId String?
|
|
userId String
|
|
examName String
|
|
score Float
|
|
totalScore Float @default(100)
|
|
publishedAt DateTime @default(now())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
class Class @relation(fields: [classId], references: [id], onDelete: Cascade)
|
|
course Course? @relation(fields: [courseId], references: [id], onDelete: SetNull)
|
|
student User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([userId, publishedAt])
|
|
@@index([classId, examName])
|
|
@@index([courseId])
|
|
}
|