Repository navigation
Add Excel import feature for admin and instructors, fix student photo update - #50
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR introduces async Excel import/export flows for admin and lecturer user management, and expands the student face-profile UX (including a required enrollment modal + improved update workflow).
Changes:
- Add async Excel import with batch status polling (Redis-backed) and export endpoints for admin students/lecturers; update lecturer student import to queue/poll.
- Add student face-profile navigation entry and a blocking enrollment modal when face is not enrolled; improve face-profile panel with polling + image validation.
- UI pagination/page-size adjustments in admin/lecturer management screens.
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/pages/StudentPage.jsx | Adds face enrollment status check and required blocking modal + feature registration. |
| frontend/src/features/student/components/StudentUtilitiesPanel.jsx | Adds “Ảnh khuôn mặt” utility item. |
| frontend/src/features/student/components/StudentMobileNav.jsx | Adds face-profile to mobile utilities features set. |
| frontend/src/features/student/components/StudentFaceProfilePanel.jsx | Adds silent refresh/polling, image validation, and pending overlay UX. |
| frontend/src/features/lecturer/components/LecturerStudentManagement.jsx | Changes import to queued polling UX and adjusts page size/pagination rendering. |
| frontend/src/features/admin/hooks/useAdminStudentWorkspace.js | Adds admin student import/export helpers and batch polling. |
| frontend/src/features/admin/hooks/useAdminLecturerWorkspace.js | Adds admin lecturer import/export helpers and batch polling. |
| frontend/src/features/admin/components/AdminStudentManagement.jsx | Adds import/export UI, import result modal, and client-side pagination. |
| frontend/src/features/admin/components/AdminSemesterManagement.jsx | Minor confirmation/header text adjustments. |
| frontend/src/features/admin/components/AdminLecturerManagement.jsx | Adds import/export UI, import result modal, and client-side pagination. |
| frontend/src/api/faceApi.js | Adds cache-busting query params to face status/update-request endpoints. |
| frontend/src/api/adminUserExcelApi.js | New API module for admin excel import/export + filename extraction. |
| frontend/package.json | Adds xlsx dependency. |
| frontend/package-lock.json | Lockfile updates for xlsx and related transitive deps. |
| backend/src/main/java/ct01/n06/backend/service/impl/LecturerServiceImpl.java | Removes old synchronous lecturer import implementation. |
| backend/src/main/java/ct01/n06/backend/service/impl/AdminStudentServiceImpl.java | Adds Excel export and introduces password-hash caching for created students. |
| backend/src/main/java/ct01/n06/backend/service/impl/AdminLecturerServiceImpl.java | Adds Excel export helpers. |
| backend/src/main/java/ct01/n06/backend/service/RedisImportTrackerService.java | New Redis tracker for import job status persistence. |
| backend/src/main/java/ct01/n06/backend/service/LecturerService.java | Removes synchronous import method from interface. |
| backend/src/main/java/ct01/n06/backend/service/AsyncLecturerExcelImportService.java | New async lecturer Excel import processor using EasyExcel + Redis job tracking. |
| backend/src/main/java/ct01/n06/backend/service/AsyncExcelImportService.java | New async student Excel import processor using EasyExcel + Redis job tracking. |
| backend/src/main/java/ct01/n06/backend/service/AdminStudentService.java | Adds exportStudentsExcel() API. |
| backend/src/main/java/ct01/n06/backend/service/AdminLecturerService.java | Adds exportLecturersExcel() API. |
| backend/src/main/java/ct01/n06/backend/repository/UserRepository.java | Adds queries to fetch all emails/usernames lower-cased for import dedupe. |
| backend/src/main/java/ct01/n06/backend/repository/StudentRepository.java | Adds query to fetch all student codes lower-cased. |
| backend/src/main/java/ct01/n06/backend/repository/LecturerRepository.java | Adds query to fetch all lecturer codes lower-cased. |
| backend/src/main/java/ct01/n06/backend/dto/admin/JobStatus.java | New DTO for import batch tracking. |
| backend/src/main/java/ct01/n06/backend/controller/admin/AdminStudentController.java | Adds async import endpoints + export endpoint for students. |
| backend/src/main/java/ct01/n06/backend/controller/admin/AdminLecturerController.java | Adds async import/status endpoints + export endpoint for lecturers. |
| backend/src/main/java/ct01/n06/backend/controller/LecturerController.java | Switches lecturer student import to async queue + adds batch status endpoint. |
| backend/src/main/java/ct01/n06/backend/config/AsyncConfig.java | Enables Spring async processing. |
| backend/pom.xml | Adds EasyExcel dependency. |
Files not reviewed (1)
- frontend/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)
frontend/src/features/lecturer/components/LecturerStudentManagement.jsx:550
- Phân trang cho bảng desktop đã bị xóa, trong khi footer hiện tại dùng class
mobile-paginationbị CSS ẩn ở ≥768px. Kết quả là trên desktop không còn cách chuyển trang (chỉ xem được PAGE_SIZE dòng đầu). Cần thêm lại pagination cho.table-panelhoặc hiển thị footer pagination cho cả desktop.
</div>
{/* Mobile pagination */}
<footer className="table-footer mobile-pagination">
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (result) { | ||
| setImportResult(result); | ||
| setShowErrors(false); | ||
| } |
| private final java.util.concurrent.ConcurrentHashMap<String, String> passwordHashCache = new java.util.concurrent.ConcurrentHashMap<>(); | ||
|
|
||
| private String getCachedPasswordHash(String rawPassword) { | ||
| return passwordHashCache.computeIfAbsent(rawPassword, passwordEncoder::encode); |
| setIsImporting(true); | ||
| try { | ||
| const result = await importLecturers(files); | ||
| if (result) { | ||
| setImportResult(result); |
| setStatus((prevStatus) => { | ||
| if (silent && prevStatus?.status === "PENDING_APPROVAL" && statusPayload?.status === "APPROVED") { | ||
| if (onCompleted) setTimeout(onCompleted, 1500); | ||
| } | ||
| return statusPayload; |
| @PostMapping(value = "/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) | ||
| public java.util.Map<String, String> importExcel(@RequestParam("file") org.springframework.web.multipart.MultipartFile file) { | ||
| if (file.isEmpty()) { | ||
| throw new ct01.n06.backend.exception.ApiException(HttpStatus.BAD_REQUEST, "File Excel trống."); | ||
| } |
| @RestController | ||
| @RequestMapping("/lecturer/students") | ||
| public class LecturerController { | ||
|
|
||
| private final LecturerService lecturerService; |
| boolean isExcel = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(contentType) | ||
| || "application/vnd.ms-excel".equals(contentType) | ||
| || (originalFilename != null && originalFilename.endsWith(".xlsx")); | ||
|
|
||
| if (!isExcel) { | ||
| throw new ApiException(HttpStatus.BAD_REQUEST, "Chỉ chấp nhận file Excel (.xlsx)"); |
| "react-router-dom": "^7.13.2", | ||
| "xlsx": "^0.18.5" |
| @PostMapping(value = "/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) | ||
| public ImportStudentsResponse importExcel( | ||
| public java.util.Map<String, String> importExcel( | ||
| @RequestParam String lecturerId, | ||
| @RequestPart("file") MultipartFile file | ||
| @RequestParam("file") org.springframework.web.multipart.MultipartFile file | ||
| ) { |




No description provided.