Commit 469f3dbc by jianan

新单跟进52

parent 1b0e783c
......@@ -2,6 +2,7 @@ package com.yd.csf.api.controller;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yd.auth.core.dto.AuthUserDto;
import com.yd.auth.core.utils.SecurityUtil;
import com.yd.common.enums.CommonEnum;
......@@ -24,6 +25,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -178,7 +180,17 @@ public class ApiFortuneController {
try {
fortuneService.downloadAccount(fortuneDownloadRequest, response);
} catch (Exception e) {
throw new BusinessException(ResultCode.FAIL.getCode(), "出账清单生成失败");
// 设置响应类型为 JSON,而不是文件流
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding("UTF-8");
Result<String> errorResult = Result.fail(
ResultCode.FAIL.getCode(),
"文件下载失败: " + e.getMessage()
);
response.getWriter().write(new ObjectMapper().writeValueAsString(errorResult));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment