fix: 修复多处边界条件问题 #27

Merged
wangziqi merged 3 commits from fix/boundary-conditions into main 2026-07-20 06:50:22 +00:00
Owner

修复内容

数据校验

  • rooms/parseRoomNumber: 未知房间号格式返回默认 capacity=4,防止 undefined 绕过入住容量检查
  • rooms: 修复 parseInt() || undefined 导致真实楼层 0 被 falsy 吞掉
  • rooms/batchImport: capacity 用 ?? 代替 ||,显式 capacity=0 不被覆盖
  • occupancies: 所有 >= room.capacity?? 0 防御性兜底,fail closed
  • schedules: assertValidScheduleRange 增加 startTime > endTime 校验
  • expenses: 个人附加费批量导入增加 assertPositiveAmount 校验
  • expenses: 水电费导入增加 periodEnd >= periodStart 校验

逻辑修复

  • attendance: 时段重叠检查改为按 startTime 排序后再比较相邻,消除 sortOrder 与时间顺序不一致时的漏检
  • attendance: 移除 getScheduleOptionsForAttendance 中不可靠的 raw[index] fallback(getRawAndEntities 无 1:1 对应)
## 修复内容 ### 数据校验 - **rooms/parseRoomNumber**: 未知房间号格式返回默认 capacity=4,防止 undefined 绕过入住容量检查 - **rooms**: 修复 `parseInt() || undefined` 导致真实楼层 0 被 falsy 吞掉 - **rooms/batchImport**: capacity 用 `??` 代替 `||`,显式 capacity=0 不被覆盖 - **occupancies**: 所有 `>= room.capacity` 加 `?? 0` 防御性兜底,fail closed - **schedules**: `assertValidScheduleRange` 增加 `startTime > endTime` 校验 - **expenses**: 个人附加费批量导入增加 `assertPositiveAmount` 校验 - **expenses**: 水电费导入增加 `periodEnd >= periodStart` 校验 ### 逻辑修复 - **attendance**: 时段重叠检查改为按 startTime 排序后再比较相邻,消除 sortOrder 与时间顺序不一致时的漏检 - **attendance**: 移除 `getScheduleOptionsForAttendance` 中不可靠的 `raw[index]` fallback(getRawAndEntities 无 1:1 对应)
wangziqi added 3 commits 2026-07-20 06:46:51 +00:00
- docker-compose.yml: 移除 MySQL 容器,后端连宿主机 MySQL
- main.ts: 启动时自动 runMigrations
- 前端 Nginx 反代 /api/ → backend:3000 不变
- docker-compose.yml: 移除 MySQL 容器,连宿主机 MySQL
- main.ts: 启动前通过独立 DataSource 执行 runMigrations
- migration-runner.ts: 独立 migration 执行器
- app.module.ts: TypeORM 配置增加 migrations
- 修复 InitialSchema 中 room_expenses 和 financial_operations 重复索引
- rooms: parseRoomNumber 未知格式返回默认 capacity=4,防止 undefined 绕过入住容量检查
- rooms: 修复 parseInt() || undefined 导致楼层 0 被吞掉
- rooms: batchImport 中 capacity 使用 ?? 代替 ||,显式 0 不被覆盖
- occupancies: 所有 capacity 比较加 ?? 0 防守兜底,fail closed
- schedules: assertValidScheduleRange 增加 startTime > endTime 校验
- attendance: 时段重叠检查改为按 startTime 排序后再比较,消除漏检
- attendance: 移除 getScheduleOptionsForAttendance 中不可靠的 raw[index] fallback
- expenses: 个人附加费批量导入增加 assertPositiveAmount 校验
- expenses: 水电费导入增加 periodEnd >= periodStart 校验
wangziqi merged commit bbd700369c into main 2026-07-20 06:50:22 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangziqi/gongxue-base#27
No description provided.