From c3988b9618bcd97004fee47e4d3ac46ffc758d66 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Tue, 25 Aug 2020 10:25:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=BF=94=E5=9B=9E=E5=80=BC?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tms/common/utils/poi/ExcelExportUtil.java | 46 ----------------- .../tms/common/utils/poi/ExcelImportUtil.java | 2 +- .../tms/controller/QuestionsController.java | 6 +-- .../msdw/tms/entity/vo/QuestionsListVO.java | 50 +++++++++++++++++++ .../msdw/tms/service/QuestionsService.java | 2 +- .../service/impl/QuestionsServiceImpl.java | 18 +++---- .../com/msdw/tms/TmsApplicationTests.java | 5 +- .../tms/service/QuestionsServiceTest.java | 2 +- 8 files changed, 66 insertions(+), 65 deletions(-) create mode 100644 src/main/java/com/msdw/tms/entity/vo/QuestionsListVO.java diff --git a/src/main/java/com/msdw/tms/common/utils/poi/ExcelExportUtil.java b/src/main/java/com/msdw/tms/common/utils/poi/ExcelExportUtil.java index d4d9551..ffe4899 100644 --- a/src/main/java/com/msdw/tms/common/utils/poi/ExcelExportUtil.java +++ b/src/main/java/com/msdw/tms/common/utils/poi/ExcelExportUtil.java @@ -74,52 +74,6 @@ public class ExcelExportUtil { workbook.write(response.getOutputStream()); } - /** - * 基于注解导出 - * 参数: - * response: - * objs:数据 - * fileName:生成的文件名 - */ -// public void export(HttpServletResponse response, List objs, String fileName) throws Exception { -// -// //1.根据模板创建工作簿 -// Workbook workbook = new XSSFWorkbook(); //2007版本 -// -// fileName = URLEncoder.encode(fileName, "UTF-8"); -// -// Sheet sheet = workbook.createSheet(fileName); -// -// //3.提取公共的样式 -// // CellStyle[] styles = getTemplateStyles(sheet.getRow(styleIndex)); -// //4.根据数据创建每一行和每一个单元格的数据2 -// AtomicInteger datasAi = new AtomicInteger(rowIndex); //数字 -// for (T t : objs) { -// //datasAi.getAndIncrement() :获取数字,并++ i++ -// Row row = sheet.createRow(datasAi.getAndIncrement()); -// for (int i = 0; i < styles.length; i++) { -// Cell cell = row.createCell(i); -// cell.setCellStyle(styles[i]); -// for (Field field : fields) { -// if (field.isAnnotationPresent(ExcelAttribute.class)) { -// field.setAccessible(true); -// ExcelAttribute ea = field.getAnnotation(ExcelAttribute.class); -// if (i == ea.sort()) { -// if (field.get(t) != null) { -// cell.setCellValue(field.get(t).toString()); -// } -// } -// } -// } -// } -// } -// -// response.setContentType("application/octet-stream"); -// response.setHeader("content-disposition", "attachment;filename=" + new String(fileName.getBytes("ISO8859-1"))); -// response.setHeader("filename", fileName); -// workbook.write(response.getOutputStream()); -// } - CellStyle[] getTemplateStyles(Row row) { CellStyle[] styles = new CellStyle[row.getLastCellNum()]; for (int i = 0; i < row.getLastCellNum(); i++) { diff --git a/src/main/java/com/msdw/tms/common/utils/poi/ExcelImportUtil.java b/src/main/java/com/msdw/tms/common/utils/poi/ExcelImportUtil.java index 57c5627..bbcc8ba 100644 --- a/src/main/java/com/msdw/tms/common/utils/poi/ExcelImportUtil.java +++ b/src/main/java/com/msdw/tms/common/utils/poi/ExcelImportUtil.java @@ -29,7 +29,7 @@ public class ExcelImportUtil { * 基于注解读取excel */ public List readExcel(InputStream is, int rowIndex, int cellIndex) { - List list = new ArrayList(); + List list = new ArrayList<>(); T entity = null; try { XSSFWorkbook workbook = new XSSFWorkbook(is); diff --git a/src/main/java/com/msdw/tms/controller/QuestionsController.java b/src/main/java/com/msdw/tms/controller/QuestionsController.java index 86b767c..7b0e97b 100644 --- a/src/main/java/com/msdw/tms/controller/QuestionsController.java +++ b/src/main/java/com/msdw/tms/controller/QuestionsController.java @@ -88,10 +88,10 @@ public class QuestionsController implements QuestionsControllerApi { * 是否禁用试题 */ @Override - @PutMapping("/isnable") - //@RequiresPermissions("qms:questions:isnable") + @PutMapping("/isenable") + //@RequiresPermissions("qms:questions:isenable") public R isNable(Integer id) { - boolean b = questionsService.isnable(id); + boolean b = questionsService.isEnable(id); return b ? R.ok() : R.error(); } diff --git a/src/main/java/com/msdw/tms/entity/vo/QuestionsListVO.java b/src/main/java/com/msdw/tms/entity/vo/QuestionsListVO.java new file mode 100644 index 0000000..5987f22 --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/vo/QuestionsListVO.java @@ -0,0 +1,50 @@ +package com.msdw.tms.entity.vo; + +import lombok.Data; +import lombok.ToString; + +import java.io.Serializable; + +/** + * 试题列表展示信息 + * + * @author gongsj + */ +@Data +@ToString +public class QuestionsListVO implements Serializable { + + /** + * 主键 + */ + private Integer id; + /** + * 题型号:用于区分是什么题型 + */ + private Integer questionTypeNo; + /** + * 题型名称 + */ + private String questionType; + /** + * 题干信息 + */ + private String questionStem; + /** + * 正确答案 + */ + private String answer; + /** + * 答案解析 + */ + private String answerAnalysis; + /** + * 是否禁用:1:启用,0:禁用,默认是1启用 + */ + private Integer isEnable; + /** + * 修改时间,用于排序,创建时,修改时间等于创建时间 + */ + private String modifyTime; + +} diff --git a/src/main/java/com/msdw/tms/service/QuestionsService.java b/src/main/java/com/msdw/tms/service/QuestionsService.java index b1f5fec..9da3bf7 100644 --- a/src/main/java/com/msdw/tms/service/QuestionsService.java +++ b/src/main/java/com/msdw/tms/service/QuestionsService.java @@ -34,7 +34,7 @@ public interface QuestionsService extends IService { boolean updateQuestionById(QuestionsUpdateRequest questions); - boolean isnable(Integer id); + boolean isEnable(Integer id); boolean deleteByIds(List asList); diff --git a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java index 049aa69..77ab261 100644 --- a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java @@ -18,10 +18,7 @@ import com.msdw.tms.entity.request.QuestionsImportRequest; import com.msdw.tms.entity.request.QuestionsQueryRequest; import com.msdw.tms.entity.request.QuestionsUpdateRequest; import com.msdw.tms.entity.response.CommonCode; -import com.msdw.tms.entity.vo.EvaluationRulesVO; -import com.msdw.tms.entity.vo.EvaluationVO; -import com.msdw.tms.entity.vo.QuestionsDetailVO; -import com.msdw.tms.entity.vo.QuestionsVO; +import com.msdw.tms.entity.vo.*; import com.msdw.tms.service.AliyunOssService; import com.msdw.tms.service.EvaluationRulesService; import com.msdw.tms.service.QuestionsService; @@ -94,15 +91,14 @@ public class QuestionsServiceImpl extends ServiceImpl records = questionsIPage.getRecords(); - List questions = records.stream().map(question -> { - QuestionsVO questionsVO = new QuestionsVO(); - BeanUtils.copyProperties(question, questionsVO); + List questions = records.stream().map(question -> { + QuestionsListVO questionsListVO = new QuestionsListVO(); + BeanUtils.copyProperties(question, questionsListVO); //处理时间格式 - questionsVO.setCreateTime(handleTime(question.getCreateTime())); - questionsVO.setModifyTime(handleTime(question.getModifyTime())); + questionsListVO.setModifyTime(handleTime(question.getModifyTime())); - return questionsVO; + return questionsListVO; }).collect(Collectors.toList()); PageUtils questionsPage = new PageUtils(questionsIPage); @@ -246,7 +242,7 @@ public class QuestionsServiceImpl extends ServiceImpl T TestG(T t){ - return t; + public K t2(T t, K k) { + k = (K) "haha"; + return k; } } diff --git a/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java b/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java index cf15c5f..8e84695 100644 --- a/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java +++ b/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java @@ -70,7 +70,7 @@ class QuestionsServiceTest { @Transactional void isnable() { Integer id = 1; - System.out.println(questionsService.isnable(id)); + System.out.println(questionsService.isEnable(id)); } @Test