Commit Graph

141 Commits

Author SHA1 Message Date
6029d8e2fd refactor(server): remove Department/UserDepartment entities, CampusScope, and departmentId from all entities
- Delete department.entity.ts, user-department.entity.ts
- Remove Department/UserDepartment from entities/index.ts
- Remove departmentId column from 18 entities (AttendanceRecord, ArchiveAttachment, Bill, ClassSchedule, Classroom, ClassroomRental, Deposit, DepositInstallment, ExamScore, LearningRecord, Occupancy, PersonalExpense, ResultArchive, Room, RoomExpense, Student, StudentEnrollment, StudentProfile, StudentReport)
- Remove departments/ module entirely
- Delete campus-scope.ts, campus-scope.middleware.ts (request-utils.ts kept — it's just IP extraction)
- Simplify common.module.ts to empty module
- Remove CampusScopeMiddleware from app.module.ts
- Remove all CampusScope injections and filter calls across all services
- Remove departmentId from all DTOs and controllers
- Simplify dingtalk/wecom sync to only sync users (no dept table)
- Update seed module to remove department seeding
- Clean frontend compilation
2026-07-09 17:51:32 +08:00
22bc1876d8 refactor: remove departmentId from Class entity 2026-07-09 17:32:37 +08:00
40fef906cd fix: resolve DingTalk dept ID to local department ID in class create 2026-07-09 17:28:12 +08:00
9b7a8e37b4 fix: resolve 5 review findings
Critical 1: Remove broken '钉钉绑定' tab (IntegConfig) — deleted /rbac/user-ding-mappings calls
Critical 2: Fix decorator placement in CreateClassDto — @IsOptional @IsArray restored to teachers
Important 1: Restore sync.service.spec.ts from 1fa3363, strip importDingTalkUsers tests
Important 2: Fix N+1 in batchImportStudents — batched find/save with In() operator
Important 3: Add migrate-student-ding-mapping.sql
2026-07-09 17:25:44 +08:00
91035e9f2c feat: add batch-import students to class endpoint 2026-07-09 17:12:23 +08:00
7b8691866e refactor: remove User-based import and RBAC UserDingMapping endpoints 2026-07-09 17:10:33 +08:00
570ef7b7e9 revert: remove deepest-2-levels filter, restore full org tree 2026-07-09 17:07:22 +08:00
e87e5e2096 refactor: syncAll creates Student + StudentDingMapping directly 2026-07-09 17:05:54 +08:00
73c1ea7a76 fix: correct studentId-as-userId bugs in 3 files
- dingtalk.service.ts syncOneUser: find Student by userId before mapping,
  use Student.id (not User.id) as studentId FK
- sync.service.ts importDingTalkUsers: type coercion for studentId
  (method deleted in Task 4, minimal compile fix)
- schedule-sync.service.ts getStatus: remove broken teacher mapping
  query (teacher scheduling deprecated); hardcode mappedTeachers=0,
  totalTeachers=0
2026-07-09 17:04:35 +08:00
86f126671c fix: repair 5 sites where StudentDingMapping.studentId was misused as User FK
- dingtalk.service.ts syncOneUser: query studentRepo (not userRepo) by mapping.studentId
- sync.service.ts importDingTalkUsers: skip User role lookup for existing mappings
- attendance.service.ts autoMatchDingRecords: use studentId directly, remove second-hop query
- schedule-sync.service.ts syncAll: skip teacher mapping block (deprecated)
- rbac.service.ts getUnboundUsers: return [] (method deleted in Task 4)
2026-07-09 17:00:00 +08:00
ef1b46b9f4 refactor: replace UserDingMapping with StudentDingMapping entity 2026-07-09 16:53:25 +08:00
4592502876 feat(sync): add import request/result logging 2026-07-09 16:32:02 +08:00
6b232eb4ed fix(seed): only seed with SEED_DEV=true, not auto on dev env 2026-07-09 16:32:01 +08:00
c56f297f95 refactor: remove SeedModule from app imports (manual seed only) 2026-07-09 16:32:01 +08:00
b81a06e77c refactor(classes): remove CampusScope dependency 2026-07-09 16:32:01 +08:00
c928ee0f65 feat(rbac): add user-ding-mapping CRUD endpoints 2026-07-09 16:31:50 +08:00
4f3b5112b0 feat: filter org-tree-with-users to deepest 2 levels 2026-07-09 16:12:13 +08:00
0509175a57 feat: add getDeptDepthMap BFS method for org tree depth tracking 2026-07-09 16:08:53 +08:00
64c8964ea4 fix(server): handle existing User from syncAll in importDingTalkUsers to avoid UNIQUE constraint error 2026-07-09 15:51:04 +08:00
4d4db7626c chore: remove dead CampusScope references from attendance spec test 2026-07-09 15:35:59 +08:00
3240c7cfdd fix(server): restore @InjectRepository(UserDingMapping) accidentally removed with scope 2026-07-09 15:31:35 +08:00
7f355952fd fix(server): remove CampusScope from AttendanceService 2026-07-09 15:29:50 +08:00
897ffbe018 fix(server): restore staff exclusion in StudentsService.findAll default filter 2026-07-09 15:28:18 +08:00
9b36284f1a fix(server): remove CampusScope from StudentsService 2026-07-09 15:25:54 +08:00
7666baceff fix: add missing Bed and Locker entities to TypeORM registration 2026-07-09 14:00:58 +08:00
eeacab6130 test(sync): add class-marking import test cases (7 new, 5 fixed) 2026-07-09 12:53:03 +08:00
0f3fec6b44 fix(sync): remove unused classStudentRepo injection, use transactional manager for class lookup 2026-07-09 12:37:49 +08:00
00de6cbd3a feat(sync): importDingTalkUsers supports class creation and teacher/student linking 2026-07-09 12:33:10 +08:00
166066f49f feat(sync): add ImportClassItemDto and expose deptIds in org-tree-with-users 2026-07-09 12:21:39 +08:00
74e6171e17 feat: add bed occupancy stats to RoomVisual cards and API 2026-07-09 12:18:30 +08:00
454a0d24c6 fix: release beds/lockers in batchCheckOut
The batchCheckOut method was not releasing assigned beds and lockers
after checkout, leaving them orphaned as 'occupied'. Added the same
release pattern used in checkOut() — using runner.manager.update()
since batchCheckOut operates inside a QueryRunner transaction.
2026-07-09 12:05:36 +08:00
54d8d0545e feat: integrate Bed/Locker into Occupancy check-in/out flow 2026-07-09 12:02:43 +08:00
3bed3409fe feat: add Bed and Locker REST routes to RoomsController 2026-07-09 12:00:04 +08:00
79d6e97bd8 fix: restore CampusScope injection, fix batchCreate bed/locker numbering 2026-07-09 11:58:42 +08:00
12fa2e974f feat: add Bed and Locker CRUD to RoomsService 2026-07-09 11:55:37 +08:00
87a3f0c554 chore: remove unused IsArray/ArrayMinSize imports from Bed DTO 2026-07-09 11:54:24 +08:00
9b7dee17f3 feat: add Bed and Locker DTOs 2026-07-09 11:53:38 +08:00
a6fbb71251 feat: add bed_id and locker_id to Occupancy entity 2026-07-09 11:52:34 +08:00
513b6c11e4 fix: add @Unique constraints for Bed and Locker entities 2026-07-09 11:51:29 +08:00
ad6c303369 feat: add Bed and Locker entities with Room FK 2026-07-09 11:49:59 +08:00
115ee5206e Merge branch 'feat/dingtalk-sync-role-selection' 2026-07-09 11:33:07 +08:00
0cfdab95ee fix: add DTO validation, transactional imports, role-not-found handling, null role guard 2026-07-09 11:28:11 +08:00
ff6cb03419 feat: add org-tree-with-users and import-users endpoints 2026-07-09 11:08:33 +08:00
8ba3327074 fix: handle duplicate usernames and failed role lookups in importDingTalkUsers 2026-07-09 11:07:25 +08:00
cd7f9c90b3 feat: add importDingTalkUsers and org-tree-with-users to SyncService 2026-07-09 11:05:17 +08:00
3835110204 feat: add importDingTalkUsers and org-tree-with-users to SyncService 2026-07-09 11:04:24 +08:00
2b60a10927 feat: add fetchOrgTreeWithUsers to DingTalkService 2026-07-09 10:58:26 +08:00
731f74e51a refactor: remove scheduled cron sync, manual trigger only 2026-07-09 10:24:12 +08:00
17ef1adcaa feat: Students list excludes staff by default 2026-07-09 10:07:04 +08:00
14eec2852a feat: add mark-staff/mark-student endpoints with studentStatus in user list 2026-07-09 10:06:31 +08:00