Compare commits
No commits in common. "7079de93ff8a99a2e7188d1219d94f763bd2b9fc" and "5a4ca4f971d86e2c61e9752bcac992a91bfeb907" have entirely different histories.
7079de93ff
...
5a4ca4f971
@ -54,9 +54,9 @@ public class ReportController {
|
||||
|
||||
|
||||
@PostMapping(path="/downLoadReport")
|
||||
public CommonResult<ResponseEntity<String>> downLoadReport(@RequestBody @NotNull @Valid BaseIdReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||
public CommonResult<ResponseEntity<byte[]>> downLoadReport(@RequestBody @NotNull @Valid BaseIdReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||
|
||||
ResponseEntity<String> fileInputStream = reportService.downLoadReport(req);
|
||||
ResponseEntity<byte[]> fileInputStream = reportService.downLoadReport(req);
|
||||
|
||||
return CommonResult.success(fileInputStream);
|
||||
}
|
||||
|
@ -88,16 +88,13 @@ public class ScaBinaryWorker extends HttpWorker {
|
||||
|
||||
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
log.error("文件不存在: {}", file.getAbsolutePath());
|
||||
append(context, "文件不存在: " + file.getAbsolutePath());
|
||||
} else if (!file.canRead()) {
|
||||
log.error("文件存在但不可读: {}", file.getAbsolutePath());
|
||||
append(context, "文件存在但不可读: " + file.getAbsolutePath());
|
||||
} else {
|
||||
// 正常处理文件上传
|
||||
handleUpload(pipTask.getTaskProperties(), file, context);
|
||||
if (!file.exists() || !file.canRead()) {
|
||||
log.error("目标文件不存在或不可读");
|
||||
localVariables.put("statusCode", "-1");
|
||||
append(context,"目标文件不存在或不可读");
|
||||
}
|
||||
|
||||
handleUpload(pipTask.getTaskProperties(), file,context);
|
||||
}catch (Exception e){
|
||||
append(context,"==================SCA-BINARY节点执行失败=================");
|
||||
append(context,"SCA-BINARY节点执行失败失败,请检查当前节点配置!");
|
||||
|
@ -24,5 +24,5 @@ public interface ReportService{
|
||||
|
||||
ReportResp deleteReport(@Valid ReportDeleteReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException;
|
||||
|
||||
ResponseEntity<String> downLoadReport(@Valid BaseIdReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException;
|
||||
ResponseEntity<byte[]> downLoadReport(@Valid BaseIdReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException;
|
||||
}
|
||||
|
@ -19,7 +19,8 @@ import org.springframework.web.client.RestTemplate;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cd.casic.ci.process.engine.worker.base.HttpWorker.getRestTemplateWithoutSANCheck;
|
||||
|
||||
@ -94,7 +95,7 @@ public class ReportServiceImpl implements ReportService {
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> downLoadReport(BaseIdReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||
public ResponseEntity<byte[]> downLoadReport(BaseIdReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||
RestTemplate restTemplate = getRestTemplateWithoutSANCheck();
|
||||
String reportDeleteUrl = ConstantContextHolder.getScaIp() + PATH;
|
||||
String body = buildDownloadRequestBody(req);
|
||||
@ -108,14 +109,11 @@ public class ReportServiceImpl implements ReportService {
|
||||
if (responseEntity.getStatusCode() == HttpStatus.OK && responseEntity.hasBody()) {
|
||||
log.info("===============报告下载接口成功=================");
|
||||
|
||||
byte[] responseBody = responseEntity.getBody();
|
||||
String base64ResponseBody = Base64.getEncoder().encodeToString(responseBody);
|
||||
// 构建返回给前端的 ResponseEntity<byte[]>
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=report.zip")
|
||||
.body(base64ResponseBody);
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=report.bin")
|
||||
.body(responseEntity.getBody());
|
||||
}else {
|
||||
log.error("===============报告下载接口失败=================");
|
||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(), "删除报告失败");
|
||||
|
Loading…
x
Reference in New Issue
Block a user