From 8264ee08fe20196e898130c5cf1fff781823e20e Mon Sep 17 00:00:00 2001 From: ire <931903008@qq.com> Date: Mon, 30 Dec 2024 20:15:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8C=BA=E5=88=86=E6=95=99?= =?UTF-8?q?=E5=B8=88=E4=B8=8E=E5=AD=A6=E7=94=9F=EF=BC=8C=E5=88=86=E5=88=AB?= =?UTF-8?q?=E7=9A=84=E5=AF=BC=E5=85=A5=E4=B8=8E=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/user/UserController.java | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java index 9ec325c4b..a8bcc0551 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java @@ -153,21 +153,21 @@ public class UserController { exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); List list = userService.getUserPage(exportReqVO).getList(); + Map deptMap = deptService.getDeptMap( + convertList(list, AdminUserDO::getDeptId)); + + List userRespVOS = UserConvert.INSTANCE.convertList(list, deptMap); //将用户转换成学生的标头 List studentUserList = new ArrayList<>(); - if (!list.isEmpty()) { - list.stream().forEach(sysUser ->{ + if (!userRespVOS.isEmpty()) { + userRespVOS.stream().forEach(sysUser ->{ UserStudentExcelVO student = new UserStudentExcelVO(); BeanUtil.copyProperties(sysUser, student); studentUserList.add(student); }); } - // 输出 Excel - Map deptMap = deptService.getDeptMap( - convertList(list, AdminUserDO::getDeptId)); - ExcelUtils.write(response, "学生数据.xls", "数据", UserRespVO.class, - UserConvert.INSTANCE.convertList(list, deptMap)); + ExcelUtils.write(response, "学生数据.xls", "数据", UserStudentExcelVO.class, studentUserList ); } @GetMapping("/teacher/export") @@ -178,22 +178,21 @@ public class UserController { HttpServletResponse response) throws IOException { exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); List list = userService.getUserPage(exportReqVO).getList(); - + Map deptMap = deptService.getDeptMap( + convertList(list, AdminUserDO::getDeptId)); + List userRespVOS = UserConvert.INSTANCE.convertList(list, deptMap); //将用户转换成教师的标头 List studentUserList = new ArrayList<>(); - if (!list.isEmpty()) { - list.stream().forEach(sysUser ->{ + if (!userRespVOS.isEmpty()) { + userRespVOS.stream().forEach(sysUser ->{ UserTeacherExcelVO student = new UserTeacherExcelVO(); BeanUtil.copyProperties(sysUser, student); studentUserList.add(student); }); } - // 输出 Excel - Map deptMap = deptService.getDeptMap( - convertList(list, AdminUserDO::getDeptId)); - ExcelUtils.write(response, "教师数据.xls", "数据", UserRespVO.class, - UserConvert.INSTANCE.convertList(list, deptMap)); + ExcelUtils.write(response, "教师数据.xls", "数据", UserTeacherExcelVO.class, + studentUserList); } @GetMapping("/get-import-template") @@ -263,4 +262,25 @@ public class UserController { return success(userService.importUserStudentTeacher(userList)); } + @GetMapping("/student/importTemplate") + @Operation(summary = "导出学生") + @PreAuthorize("@ss.hasPermission('system:user:export')") + @ApiAccessLog(operateType = EXPORT) + public void importStudentTemplate(HttpServletResponse response) throws IOException { + List list = new ArrayList<>(); + // 输出 Excel + ExcelUtils.write(response, "学生模板.xls", "数据", UserStudentExcelVO.class,list); + } + + + @GetMapping("/teacher/importTemplate") + @Operation(summary = "导出教师模板") + @PreAuthorize("@ss.hasPermission('system:user:export')") + @ApiAccessLog(operateType = EXPORT) + public void importTeacherTemplate(HttpServletResponse response) throws IOException { + List list = new ArrayList<>(); + // 输出 Excel + ExcelUtils.write(response, "教师模板.xls", "数据", UserTeacherExcelVO.class,list); + } + }