统一响应状态码

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;
public R() {
put("code", 0);
put("msg", "success");
put("status", 200);
put("errmessage", "success");
}
public static R error() {
@ -36,14 +36,14 @@ public class R extends HashMap<String, Object> {
public static R error(int code, String msg) {
R r = new R();
r.put("code", code);
r.put("msg", msg);
r.put("status", code);
r.put("errmessage", msg);
return r;
}
public static R ok(String msg) {
R r = new R();
r.put("msg", msg);
r.put("errmessage", msg);
return r;
}

@ -2,6 +2,7 @@ package com.msdw.tms.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -601,22 +602,18 @@ public class QuestionsServiceImpl extends ServiceImpl<QuestionsDao, QuestionsEnt
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));
// Collections.sort(parse, new Comparator<QuestionsImportFailureVO>() {
// @Override
// public int compare(QuestionsImportFailureVO o1, QuestionsImportFailureVO o2) {
// //升序
// return o1.getIndex().compareTo(o2.getIndex());
// }
// });
//2.加载模板流数据
org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/试题导入失败数据导出模板.xlsx");
FileInputStream fis = new FileInputStream(resource.getFile());
//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");
}

Loading…
Cancel
Save