JSON报文返回格式

来源:互联网 发布:瓷砖 斜铺 知乎 编辑:程序博客网 时间:2024/06/01 09:15

1、前后端分离

使用postman进行后台接口校验

2、controller层格式:标准controller层返回格式

 /**
  * 生成excel附件
  * @param fpInvoiceListDto
  * @return
  */
@RequestMapping(value = "/generateExcel", method = RequestMethod.POST)
@ResponseBody
public ResponseDto generateExcel(@RequestBody FpInvoiceListDto fpInvoiceListDto){
LOGGER.info("  生成excel附件开始-----------");
ResponseDto responseDto = ResponseDto.instance(null);
JSONObject rtnObj = new JSONObject();
   
try {
String fileId = fpInvoiceService.generateExcel(fpInvoiceListDto);
rtnObj.put("fileId", fileId);
rtnObj.put("resultMsg", " 生成excel附件成功!");
responseDto.setResultCode(ReinsErrorEnum.RESINS_SUCCESS.getCode());//成功
} catch (Exception e) {
LOGGER.info(" 生成excel附件失败:");
e.printStackTrace();


rtnObj.put("resultMsg", " 生成excel附件失败!");
responseDto.setResultCode(ReinsErrorEnum.RESINS_ERROR.getCode());//失败
}
LOGGER.info(" 生成excel附件结束-----------");
responseDto.setResultMsg((String) rtnObj.get("resultMsg"));
responseDto.setResultObj(rtnObj);
return responseDto;
}


原创粉丝点击