/**
* 下载协议文件
*
* @param fileId
* @param response
* @return
*/
@RequestMapping(value = "offer/download/{fileId}", method = RequestMethod.GET)
public R download(@PathVariable("fileId") String fileId, HttpServletResponse response) {
if (StringUtil.isBlank(fileId)) {
LoggerUtil.error(LOGGER, null, "[OfferController-aggrement-fileId-null]:", ErrorCodeEnum.REQUEST_PARAM_ERROR.getCode(),
ErrorCodeEnum.REQUEST_PARAM_ERROR.getMsg());
return R.error(WebCodeEnum.FIELD_ID_ENPTY.getCode(), WebCodeEnum.FIELD_ID_ENPTY.getMsg());
} else {
fileId = fileId.replace(Constant.UNDERLINE, Constant.DOT);
}
ByteArrayOutputStream bos = null;
try {
bos = ossClientService.download(OssClientUtil.getOssPathByFileId(fileId, OssConstant.FORMAL));
if (bos == null) {
bos = ossClientService.download(OssClientUtil.getOssPathByFileId(fileId, OssConstant.TEMP));
}
byte[] output = bos.toByteArray();
response.setContentLengthLong(output.length);
response.getOutputStream().write(output);
} catch (Exception e) {
throw new RRException(e.getMessage());
}
return null;
}