This commit is contained in:
zhangyx
2021-03-25 16:44:42 +08:00
parent dfbb00e3e0
commit ab10dd37cf
4 changed files with 19 additions and 77 deletions

View File

@ -11,6 +11,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@ -58,38 +59,10 @@ public class TemplateWarehouseController {
*/
@ApiOperation("获得客户端配置文件文件id")
@GetMapping("/client/file")
public BaseResponse<FileOutputStream> getClientFile() throws IOException {
public BaseResponse<ByteArrayOutputStream> getClientFile() throws IOException {
String type = "ipassConfigFile";
BizBidTemplateWarehouse templateWarehouse = templateWarehouseService.getTemplateByType(type);
FileOutputStream clientVersion = bizBidClientVersionService.downloadFileByObjectId(templateWarehouse.getDocumentCenterId());
return BaseResponse.success(clientVersion);
}
/**
* 获得客户端配置文件相关信息
*
* @return
*/
@ApiOperation("获得客户端配置文件文件id")
@GetMapping("/client/files")
public BaseResponse<FileOutputStream> getClientFiles() throws IOException {
String type = "ipassConfigFile";
BizBidTemplateWarehouse templateWarehouse = templateWarehouseService.getTemplateByType(type);
FileOutputStream clientVersion = bizBidClientVersionService.downloadFileByObjectIds(templateWarehouse.getDocumentCenterId());
return BaseResponse.success(clientVersion);
}
/**
* 获得客户端配置文件相关信息
*
* @return
*/
@ApiOperation("获得客户端配置文件文件id")
@GetMapping("/client/filess")
public BaseResponse<FileOutputStream> getClientFiless() throws IOException {
String type = "ipassConfigFile";
BizBidTemplateWarehouse templateWarehouse = templateWarehouseService.getTemplateByType(type);
FileOutputStream clientVersion = bizBidClientVersionService.downloadFileByObjectIdss(templateWarehouse.getDocumentCenterId());
ByteArrayOutputStream clientVersion = bizBidClientVersionService.downloadFileByOId(templateWarehouse.getDocumentCenterId());
return BaseResponse.success(clientVersion);
}
@ -100,8 +73,8 @@ public class TemplateWarehouseController {
*/
@ApiOperation("通过版本号获得对应客户端文件id")
@GetMapping("/client/{version}")
public BaseResponse<BizBidClientVersion> getClientByVersion(@ApiParam(value = "版本号", required = true) @PathVariable String version){
BizBidClientVersion clientVersion = bizBidClientVersionService.getClientByVersion(version);
public BaseResponse<ByteArrayOutputStream> getClientByVersion(@ApiParam(value = "版本号", required = true) @PathVariable String version) throws IOException {
ByteArrayOutputStream clientVersion = bizBidClientVersionService.getClientByVersion(version);
return BaseResponse.success(clientVersion);
}
}

View File

@ -4,6 +4,7 @@ package com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice;
import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
import com.chinaunicom.mall.ebtp.extend.templatewarehouse.entity.BizBidClientVersion;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@ -19,11 +20,7 @@ public interface BizBidClientVersionService extends IBaseService<BizBidClientVer
* @param version
* @return
*/
BizBidClientVersion getClientByVersion(String version);
ByteArrayOutputStream getClientByVersion(String version) throws IOException;
FileOutputStream downloadFileByObjectId(String oId) throws IOException;
FileOutputStream downloadFileByObjectIds(String oId) throws IOException;
FileOutputStream downloadFileByObjectIdss(String oId) throws IOException;
ByteArrayOutputStream downloadFileByOId(String oId) throws IOException;
}

View File

@ -35,66 +35,38 @@ public class BizBidClientVersionServiceImpl extends BaseServiceImpl<BizBidClient
private final ModelConvertor modelConvertor;
@Override
public BizBidClientVersion getClientByVersion(String version) {
public ByteArrayOutputStream getClientByVersion(String version) throws IOException {
QueryWrapper<BizBidClientVersion> query = new QueryWrapper<>(new BizBidClientVersion().setIpassVersion(version));
return this.getOne(query);
BizBidClientVersion clientVersion = this.getOne(query);
return this.downloadClientByOId(clientVersion.getDocumentCenterId());
}
@Override
public FileOutputStream downloadFileByObjectId(String objectId) throws IOException {
public ByteArrayOutputStream downloadFileByOId(String objectId) throws IOException {
log.info("文档中心文件下载传入数据:"+ JsonUtils.objectToJson(objectId));
String objectInfo = documentCenterService.getFileObjectDetail(objectId);
String objectInfo = documentCenterService.getObjectDetail(objectId);
log.info("文档中心文件下载返回数据:"+ JsonUtils.objectToJson(objectInfo));
Optional<byte[]> optionalBytes = modelConvertor.toByteArray(objectInfo);
log.info("文档中心文件下载返回数据转为byte[]数据:"+ optionalBytes.get());
FileOutputStream fileOutputStream = null;
if(optionalBytes.isPresent()){
ByteArrayOutputStream fileStream = new ByteArrayOutputStream();
if(optionalBytes.isPresent()){
fileStream.write(optionalBytes.get());
log.info("文档中心文件下载返回数据转为ByteArrayOutputStream数据"+fileStream);
fileOutputStream.write(fileStream.toByteArray());
log.info("文档中心文件下载返回数据转为ByteArrayOutputStream数据"+fileOutputStream);
}
return fileOutputStream;
return fileStream;
}
@Override
public FileOutputStream downloadFileByObjectIds(String objectId) throws IOException {
public ByteArrayOutputStream downloadClientByOId(String objectId) throws IOException {
log.info("文档中心s文件下载传入数据"+ JsonUtils.objectToJson(objectId));
String objectInfo = documentCenterService.getObjectDetail(objectId);
log.info("文档中心s文件下载返回数据"+ JsonUtils.objectToJson(objectInfo));
Optional<byte[]> optionalBytes = modelConvertor.toByteArray(objectInfo);
log.info("文档中心s文件下载返回数据转为byte[]数据:"+ optionalBytes.get());
FileOutputStream fileOutputStream = null;
if(optionalBytes.isPresent()){
ByteArrayOutputStream fileStream = new ByteArrayOutputStream();
if(optionalBytes.isPresent()){
fileStream.write(optionalBytes.get());
log.info("文档中心s文件下载返回数据转为ByteArrayOutputStream数据"+fileStream);
fileOutputStream.write(fileStream.toByteArray());
log.info("文档中心s文件下载返回数据转为ByteArrayOutputStream数据"+fileOutputStream);
}
return fileOutputStream;
return fileStream;
}
@Override
public FileOutputStream downloadFileByObjectIdss(String objectId) throws IOException {
log.info("文档中心s文件下载传入数据"+ JsonUtils.objectToJson(objectId));
String objectInfo = documentCenterService.getObjectDetail(objectId);
log.info("文档中心s文件下载返回数据"+ JsonUtils.objectToJson(objectInfo));
Optional<byte[]> optionalBytes = modelConvertor.toByteArray(objectInfo);
log.info("文档中心s文件下载返回数据转为byte[]数据:"+ optionalBytes.get());
FileOutputStream fileOutputStream = null;
if(optionalBytes.isPresent()){
ByteArrayOutputStream fileStream = new ByteArrayOutputStream();
fileStream.write(optionalBytes.get());
log.info("文档中心s文件下载返回数据转为ByteArrayOutputStream数据"+fileStream);
fileOutputStream = new FileOutputStream("C:\\test.txt");
fileOutputStream.write(fileStream.toByteArray());
log.info("文档中心s文件下载返回数据转为ByteArrayOutputStream数据"+fileOutputStream);
}
return fileOutputStream;
}
}

View File

@ -1,5 +1,5 @@
server:
port: 18018
port: 9018
servlet:
context-path: /