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
This commit is contained in:
2026-07-09 17:25:44 +08:00
parent 1f63a53222
commit 9b7a8e37b4
6 changed files with 77 additions and 172 deletions

View File

@@ -1,23 +1,14 @@
## Task 7 — Cleanup test files
## Fix Task 7 — Build-breaking issues in RoomsPage
### Sync service spec
- `apps/server/src/sync/sync.service.spec.ts` was already deleted in commit `7b86918` (Task 4: remove importDingTalkUsers). No action needed.
### Changes made to `apps/admin/src/pages/Rooms/index.tsx`
1. **Restored `const RoomsPage: React.FC = () => {` wrapper** — was accidentally removed, leaving state hooks dangling at module scope. Added at line 66.
2. **Restored `const [data, setData] = useState<any[]>([]);`** — was removed but referenced by `buildings` useMemo and `fetchData`. Added right after the component opener.
3. **Added `useCallback` to React import** (line 1) — needed for wrapping fetchBeds/fetchLockers.
4. **Fixed `handleSave` function** — its closing `};` was accidentally overwritten by the fetchBeds edit. Restored at line 160.
5. **Wrapped `fetchBeds` and `fetchLockers` in `useCallback`** — they're in the `columns` useMemo deps array, but as plain `const` functions they'd be recreated every render, causing unnecessary re-renders. Now wrapped with `[]` deps since they only reference stable `api` and state setters.
6. **Deleted orphaned leftover code** — old `} catch (e) { console.error(e); }\n };` from the pre-useCallback fetchBeds definition was still present after the replacement.
7. **Fixed broken action column JSX** — the ternary for archived/non-archived rows had mixed branches: the archived=true branch contained ALL buttons (恢复, 查看, 编辑, 归档) instead of only 恢复, with a dangling `</>` closing a non-existent fragment. Restructured to: archived branch → just `<Popconfirm>恢复</Popconfirm>`; else branch → fragment-wrapped `<查看/编辑/归档>`. Also fixed missing `]: [deps]` useMemo closing after the action column array member.
8. **Removed Tooltip** — not imported/unused. (Already clean; no action needed.)
### Attendance service spec
- `apps/server/src/attendance/attendance.service.spec.ts` already uses `StudentDingMapping` (lines 12, 42). No `UserDingMapping` references remain. Updated in commit `ef1b46b`.
### Verification
- `npx tsc --noEmit` passes with zero errors.
- `npx tsc --noEmit` in apps/server: 277 diagnostics, all pre-existing jest type errors (`@types/jest` not installed). Zero errors related to `UserDingMapping` or `StudentDingMapping`.
- No files to commit — both targets are already clean.
### Conclusion
Task complete with zero changes needed. Previous tasks (Task 4 entity rename, Task 2 import swap) already handled these test updates.