返回文件输出流
This commit is contained in:
@ -65,6 +65,20 @@ public class TemplateWarehouseController {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过版本号获得对应客户端文件id
|
||||
*
|
||||
|
@ -22,4 +22,6 @@ public interface BizBidClientVersionService extends IBaseService<BizBidClientVer
|
||||
BizBidClientVersion getClientByVersion(String version);
|
||||
|
||||
FileOutputStream downloadFileByObjectId(String oId) throws IOException;
|
||||
|
||||
FileOutputStream downloadFileByObjectIds(String oId) throws IOException;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class BizBidClientVersionServiceImpl extends BaseServiceImpl<BizBidClient
|
||||
@Override
|
||||
public FileOutputStream downloadFileByObjectId(String objectId) throws IOException {
|
||||
log.info("文档中心文件下载传入数据:"+ JsonUtils.objectToJson(objectId));
|
||||
String objectInfo = documentCenterService.getObjectDetail(objectId);
|
||||
String objectInfo = documentCenterService.getFileObjectDetail(objectId);
|
||||
log.info("文档中心文件下载返回数据:"+ JsonUtils.objectToJson(objectInfo));
|
||||
Optional<byte[]> optionalBytes = modelConvertor.toByteArray(objectInfo);
|
||||
log.info("文档中心文件下载返回数据转为byte[]数据:"+ JsonUtils.objectToJson(optionalBytes));
|
||||
@ -58,4 +58,23 @@ public class BizBidClientVersionServiceImpl extends BaseServiceImpl<BizBidClient
|
||||
}
|
||||
return fileOutputStream;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FileOutputStream downloadFileByObjectIds(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[]数据:"+ JsonUtils.objectToJson(optionalBytes));
|
||||
FileOutputStream fileOutputStream = null;
|
||||
if(optionalBytes.isPresent()){
|
||||
ByteArrayOutputStream fileStream = new ByteArrayOutputStream();
|
||||
fileStream.write(optionalBytes.get());
|
||||
log.info("文档中心s文件下载返回数据转为ByteArrayOutputStream数据:"+ JsonUtils.objectToJson(fileStream));
|
||||
fileOutputStream.write(fileStream.toByteArray());
|
||||
log.info("文档中心s文件下载返回数据转为ByteArrayOutputStream数据:"+ JsonUtils.objectToJson(fileOutputStream));
|
||||
}
|
||||
return fileOutputStream;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user