统一响应状态码

hehai msdw_tms-v1.0.2
shijie 4 years ago
parent 5cd4262f23
commit 227fb1ce0c
  1. 10
      src/main/java/com/msdw/tms/common/utils/R.java
  2. 15
      src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java

@ -22,8 +22,8 @@ public class R extends HashMap<String, Object> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public R() { public R() {
put("code", 0); put("status", 200);
put("msg", "success"); put("errmessage", "success");
} }
public static R error() { public static R error() {
@ -36,14 +36,14 @@ public class R extends HashMap<String, Object> {
public static R error(int code, String msg) { public static R error(int code, String msg) {
R r = new R(); R r = new R();
r.put("code", code); r.put("status", code);
r.put("msg", msg); r.put("errmessage", msg);
return r; return r;
} }
public static R ok(String msg) { public static R ok(String msg) {
R r = new R(); R r = new R();
r.put("msg", msg); r.put("errmessage", msg);
return r; return r;
} }

@ -2,6 +2,7 @@ package com.msdw.tms.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -601,22 +602,18 @@ public class QuestionsServiceImpl extends ServiceImpl<QuestionsDao, QuestionsEnt
return; return;
} }
List<QuestionsImportFailureVO> parse = (List<QuestionsImportFailureVO>) JSON.parse(record);
List<QuestionsImportFailureVO> parse = JSON.parseObject(record, new TypeReference<List<QuestionsImportFailureVO>>() {
});
parse.sort(Comparator.comparing(QuestionsImportFailureVO::getIndex)); parse.sort(Comparator.comparing(QuestionsImportFailureVO::getIndex));
// Collections.sort(parse, new Comparator<QuestionsImportFailureVO>() {
// @Override
// public int compare(QuestionsImportFailureVO o1, QuestionsImportFailureVO o2) {
// //升序
// return o1.getIndex().compareTo(o2.getIndex());
// }
// });
//2.加载模板流数据 //2.加载模板流数据
org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/试题导入失败数据导出模板.xlsx"); org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/试题导入失败数据导出模板.xlsx");
FileInputStream fis = new FileInputStream(resource.getFile()); FileInputStream fis = new FileInputStream(resource.getFile());
//3、通过工具类下载文件 //3、通过工具类下载文件
new ExcelExportUtil(QuestionsImportRequest.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). new ExcelExportUtil(QuestionsImportFailureVO.class, Constant.ROW_INDEX, Constant.STYLE_INDEX).
export(response, fis, parse, "导入失败数据表.xlsx"); export(response, fis, parse, "导入失败数据表.xlsx");
} }

Loading…
Cancel
Save