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