diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/controller/TemplateWarehouseController.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/controller/TemplateWarehouseController.java index f5d3dfe..e1a3ac4 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/controller/TemplateWarehouseController.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/controller/TemplateWarehouseController.java @@ -5,6 +5,7 @@ import com.chinaunicom.mall.ebtp.extend.templatewarehouse.entity.BizBidClientVer import com.chinaunicom.mall.ebtp.extend.templatewarehouse.entity.BizBidTemplateWarehouse; import com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.BizBidClientVersionService; import com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.BizBidTemplateWarehouseService; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -59,13 +60,14 @@ public class TemplateWarehouseController { */ @ApiOperation("获得客户端配置文件文件id") @GetMapping("/client/file") - public BaseResponse getClientFile() throws IOException { + public BaseResponse getClientFile() throws IOException { String type = "ipassConfigFile"; BizBidTemplateWarehouse templateWarehouse = templateWarehouseService.getTemplateByType(type); - ByteArrayOutputStream clientVersion = bizBidClientVersionService.downloadFileByOId(templateWarehouse.getDocumentCenterId()); - return BaseResponse.success(clientVersion); + bizBidClientVersionService.downloadFileByOId(templateWarehouse.getDocumentCenterId()); + return BaseResponse.success(); } + /** * 通过版本号获得对应客户端文件id * @@ -73,8 +75,8 @@ public class TemplateWarehouseController { */ @ApiOperation("通过版本号获得对应客户端文件id") @GetMapping("/client/{version}") - public BaseResponse getClientByVersion(@ApiParam(value = "版本号", required = true) @PathVariable String version) throws IOException { - ByteArrayOutputStream clientVersion = bizBidClientVersionService.getClientByVersion(version); - return BaseResponse.success(clientVersion); + public BaseResponse getClientByVersion(@ApiParam(value = "版本号", required = true) @PathVariable String version) throws IOException { + bizBidClientVersionService.getClientByVersion(version); + return BaseResponse.success(); } } diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/BizBidClientVersionService.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/BizBidClientVersionService.java index 0172b5b..8c09013 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/BizBidClientVersionService.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/BizBidClientVersionService.java @@ -20,7 +20,7 @@ public interface BizBidClientVersionService extends IBaseService query = new QueryWrapper<>(new BizBidClientVersion().setIpassVersion(version)); BizBidClientVersion clientVersion = this.getOne(query); - return this.downloadClientByOId(clientVersion.getDocumentCenterId()); + this.downloadClientByOId(clientVersion.getDocumentCenterId()); } @Override - public ByteArrayOutputStream downloadFileByOId(String objectId) throws IOException { + public void downloadFileByOId(String objectId) throws IOException { log.info("文档中心文件下载传入数据:"+ JsonUtils.objectToJson(objectId)); String objectInfo = documentCenterService.getObjectDetail(objectId); log.info("文档中心文件下载返回数据:"+ JsonUtils.objectToJson(objectInfo)); Optional optionalBytes = modelConvertor.toByteArray(objectInfo); log.info("文档中心文件下载返回数据转为byte[]数据:"+ optionalBytes.get()); - ByteArrayOutputStream fileStream = new ByteArrayOutputStream(); + ServletOutputStream outputStream = response.getOutputStream(); + response.setContentType("application/octet-stream;charset=utf-8"); + response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("客户端配置文件", "utf-8")); if(optionalBytes.isPresent()){ - fileStream.write(optionalBytes.get()); + outputStream.write(optionalBytes.get()); } - return fileStream; } - public ByteArrayOutputStream downloadClientByOId(String objectId) throws IOException { + public void downloadClientByOId(String objectId) throws IOException { log.info("文档中心s文件下载传入数据:"+ JsonUtils.objectToJson(objectId)); String objectInfo = documentCenterService.getObjectDetail(objectId); log.info("文档中心s文件下载返回数据:"+ JsonUtils.objectToJson(objectInfo)); Optional optionalBytes = modelConvertor.toByteArray(objectInfo); log.info("文档中心s文件下载返回数据转为byte[]数据:"+ optionalBytes.get()); ByteArrayOutputStream fileStream = new ByteArrayOutputStream(); + ServletOutputStream outputStream = response.getOutputStream(); + response.setContentType("application/octet-stream;charset=utf-8"); + response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("客户端安装包", "utf-8")); if(optionalBytes.isPresent()){ - fileStream.write(optionalBytes.get()); + outputStream.write(optionalBytes.get()); } - return fileStream; } }