HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentDisposition(ContentDisposition.builder("attachment")
.filename(templateExport.getTemplate().getName() + ".json", StandardCharsets.UTF_8).build());
byte[] bytes;
try {
bytes = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsBytes(templateExport);
} catch (JsonProcessingException e) {
throw new BizException(CommonCode.InternalError, "数据错误", e);
}
return new ResponseEntity(new InputStreamResource(new ByteArrayInputStream(bytes)), headers, HttpStatus.OK);