修改配置文件
This commit is contained in:
@ -21,6 +21,8 @@ public enum ExportExceptionEnum implements BusinessExceptionAssert {
|
|||||||
|
|
||||||
FRAME_EXCEPTION_GET_PROJECT_INFO(2200001, "获取项目信息失败"),
|
FRAME_EXCEPTION_GET_PROJECT_INFO(2200001, "获取项目信息失败"),
|
||||||
|
|
||||||
|
FRAME_EXCEPTION_GET_DOCUMENT_CENTER(2200009, "!"),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.impl;
|
package com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.ModelConvertor;
|
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.ModelConvertor;
|
||||||
import com.chinaunicom.mall.ebtp.common.util.JsonUtils;
|
import com.chinaunicom.mall.ebtp.common.util.JsonUtils;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.export.enums.ExportExceptionEnum;
|
||||||
import com.chinaunicom.mall.ebtp.extend.feign.client.DocumentCenterService;
|
import com.chinaunicom.mall.ebtp.extend.feign.client.DocumentCenterService;
|
||||||
import com.chinaunicom.mall.ebtp.extend.templatewarehouse.entity.BizBidClientVersion;
|
import com.chinaunicom.mall.ebtp.extend.templatewarehouse.entity.BizBidClientVersion;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -21,6 +24,9 @@ import javax.servlet.ServletOutputStream;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
@ -55,29 +61,38 @@ public class BizBidClientVersionServiceImpl extends BaseServiceImpl<BizBidClient
|
|||||||
log.info("文档中心文件下载传入数据:"+ JsonUtils.objectToJson(objectId));
|
log.info("文档中心文件下载传入数据:"+ JsonUtils.objectToJson(objectId));
|
||||||
String objectInfo = documentCenterService.getObjectDetail(objectId);
|
String objectInfo = documentCenterService.getObjectDetail(objectId);
|
||||||
log.info("文档中心文件下载返回数据:"+ JsonUtils.objectToJson(objectInfo));
|
log.info("文档中心文件下载返回数据:"+ JsonUtils.objectToJson(objectInfo));
|
||||||
|
Map map = (Map) JSON.parse(objectInfo);
|
||||||
|
ExportExceptionEnum.FRAME_EXCEPTION_GET_DOCUMENT_CENTER.customValidName("文档获取失败",!(map.containsKey("message") && map.containsKey("success")));
|
||||||
|
ExportExceptionEnum.FRAME_EXCEPTION_GET_DOCUMENT_CENTER.customValidName(map.get("message").toString(),!(boolean) map.get("success"));
|
||||||
Optional<byte[]> optionalBytes = modelConvertor.toByteArray(objectInfo);
|
Optional<byte[]> optionalBytes = modelConvertor.toByteArray(objectInfo);
|
||||||
log.info("文档中心文件下载返回数据转为byte[]数据:"+ optionalBytes.get());
|
// log.info("文档中心文件下载返回数据转为byte[]数据:"+ new String(optionalBytes.get()));
|
||||||
ServletOutputStream outputStream = response.getOutputStream();
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
response.setContentType("application/octet-stream;charset=utf-8");
|
// response.setContentType("application/octet-stream;charset=utf-8");
|
||||||
response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("客户端配置文件", "utf-8"));
|
response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("AutoUpdater.xml", "utf-8"));
|
||||||
if(optionalBytes.isPresent()){
|
if(optionalBytes.isPresent()){
|
||||||
outputStream.write(optionalBytes.get());
|
outputStream.write(optionalBytes.get());
|
||||||
}
|
}
|
||||||
|
outputStream.flush();
|
||||||
|
outputStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadClientByOId(String objectId) throws IOException {
|
public void downloadClientByOId(String objectId) throws IOException {
|
||||||
log.info("文档中心s文件下载传入数据:"+ JsonUtils.objectToJson(objectId));
|
log.info("文档中心s文件下载传入数据:"+ JsonUtils.objectToJson(objectId));
|
||||||
String objectInfo = documentCenterService.getObjectDetail(objectId);
|
String objectInfo = documentCenterService.getObjectDetail(objectId);
|
||||||
log.info("文档中心s文件下载返回数据:"+ JsonUtils.objectToJson(objectInfo));
|
log.info("文档中心s文件下载返回数据:"+ JsonUtils.objectToJson(objectInfo));
|
||||||
|
Map map = (Map) JSON.parse(objectInfo);
|
||||||
|
ExportExceptionEnum.FRAME_EXCEPTION_GET_DOCUMENT_CENTER.customValidName("文档获取失败",!(map.containsKey("message") && map.containsKey("success")));
|
||||||
|
ExportExceptionEnum.FRAME_EXCEPTION_GET_DOCUMENT_CENTER.customValidName(map.get("message").toString(),!(boolean) map.get("success"));
|
||||||
Optional<byte[]> optionalBytes = modelConvertor.toByteArray(objectInfo);
|
Optional<byte[]> optionalBytes = modelConvertor.toByteArray(objectInfo);
|
||||||
log.info("文档中心s文件下载返回数据转为byte[]数据:"+ optionalBytes.get());
|
// log.info("文档中心s文件下载返回数据转为byte[]数据:"+ optionalBytes.get());
|
||||||
ByteArrayOutputStream fileStream = new ByteArrayOutputStream();
|
|
||||||
ServletOutputStream outputStream = response.getOutputStream();
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
response.setContentType("application/octet-stream;charset=utf-8");
|
// response.setContentType("application/octet-stream;charset=utf-8");
|
||||||
response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("客户端安装包", "utf-8"));
|
response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("ebtp-ca.zip", "utf-8"));
|
||||||
if(optionalBytes.isPresent()){
|
if(optionalBytes.isPresent()){
|
||||||
outputStream.write(optionalBytes.get());
|
outputStream.write(optionalBytes.get());
|
||||||
}
|
}
|
||||||
|
outputStream.flush();
|
||||||
|
outputStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user