用户区分教师与学生,分别的导入与导出

This commit is contained in:
ire 2024-12-30 20:15:50 +08:00
parent 5fa2c495f6
commit 8264ee08fe

View File

@ -153,21 +153,21 @@ public class UserController {
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<AdminUserDO> list = userService.getUserPage(exportReqVO).getList();
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
convertList(list, AdminUserDO::getDeptId));
List<UserRespVO> userRespVOS = UserConvert.INSTANCE.convertList(list, deptMap);
//将用户转换成学生的标头
List<UserStudentExcelVO> 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<Long, DeptDO> 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<AdminUserDO> list = userService.getUserPage(exportReqVO).getList();
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
convertList(list, AdminUserDO::getDeptId));
List<UserRespVO> userRespVOS = UserConvert.INSTANCE.convertList(list, deptMap);
//将用户转换成教师的标头
List<UserTeacherExcelVO> 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<Long, DeptDO> 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<UserStudentExcelVO> 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<UserTeacherExcelVO> list = new ArrayList<>();
// 输出 Excel
ExcelUtils.write(response, "教师模板.xls", "数据", UserTeacherExcelVO.class,list);
}
}