| | |
| | | package com.ycl.jxkg.service.impl; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.read.listener.PageReadListener; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.pagehelper.PageHelper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | this.insertUser(teacher); |
| | | // 发布注册事件,保存注册日志 |
| | | UserEventLog userEventLog = new UserEventLog(teacher.getId(), teacher.getUserName(), teacher.getRealName(), new Date()); |
| | | userEventLog.setContent("欢迎 " + teacher.getUserName() + " 注册来到江西空管音视频培训系统"); |
| | | userEventLog.setContent("欢迎 " + teacher.getUserName() + " 注册来到音视频培训系统"); |
| | | eventPublisher.publishEvent(new UserEvent(userEventLog)); |
| | | } |
| | | |
| | |
| | | this.insertUser(student); |
| | | // 发布注册事件,保存注册日志 |
| | | UserEventLog userEventLog = new UserEventLog(student.getId(), student.getUserName(), student.getRealName(), new Date()); |
| | | userEventLog.setContent("欢迎 " + student.getUserName() + " 注册来到江西空管音视频培训系统"); |
| | | userEventLog.setContent("欢迎 " + student.getUserName() + " 注册来到音视频培训系统"); |
| | | eventPublisher.publishEvent(new UserEvent(userEventLog)); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | @SneakyThrows |
| | | public void importTemplate(HttpServletResponse response) { |
| | | List<UserExcelVo> list = new ArrayList<>(); |
| | | UserExcelVo userExcelVo = new UserExcelVo(); |
| | | userExcelVo.setUserName("zhangSan"); |
| | | userExcelVo.setRealName("张三"); |
| | | userExcelVo.setSex(1); |
| | | userExcelVo.setRole(1); |
| | | userExcelVo.setPhone("12345678901"); |
| | | userExcelVo.setAge(24); |
| | | userExcelVo.setBirthDay("2000-01-01"); |
| | | list.add(userExcelVo); |
| | | ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), UserExcelVo.class).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(0, "用户信息").build(); |
| | | excelWriter.write(list, writeSheet); |
| | | excelWriter.finish(); |
| | | } |
| | | |
| | | @Override |
| | | @SneakyThrows |
| | | @Transactional |
| | | public String importExcel(MultipartFile file) { |
| | | List<User> userList = new ArrayList<>(); |
| | |
| | | user.setAge(item.getAge()); |
| | | user.setRole(item.getRole()); |
| | | user.setStatus(UserStatusEnum.Enable.getCode()); |
| | | user.setLastUpdatePasswordTime(new Date()); |
| | | userList.add(user); |
| | | }))).sheet().doRead(); |
| | | if (!errorList.isEmpty()) { |
| | | return "以下数据日期格式错误:\\n" + String.join(",", errorList); |
| | | return "以下数据日期格式错误:" + String.join(",", errorList); |
| | | } else { |
| | | saveBatch(userList); |
| | | } |