Commit 45abf238 authored by zhaji's avatar zhaji

"feature-zhaJi:修复sonar中的bug"

parent 79c324fb
...@@ -1111,6 +1111,11 @@ public class InsurancesConstants { ...@@ -1111,6 +1111,11 @@ public class InsurancesConstants {
*/ */
public static final String SUCCESS_LIST = "successList"; public static final String SUCCESS_LIST = "successList";
/**
* OSS文件上传接口异常:
*/
public static final String OSS_ERROR = "OSS文件上传接口异常:";
......
...@@ -63,15 +63,14 @@ public class TInsuranceEnclosureServiceImpl extends ServiceImpl<TInsuranceEnclos ...@@ -63,15 +63,14 @@ public class TInsuranceEnclosureServiceImpl extends ServiceImpl<TInsuranceEnclos
if (file.getSize() > (CommonConstants.FIFTY_INT*CommonConstants.BYTE*CommonConstants.BYTE)){ if (file.getSize() > (CommonConstants.FIFTY_INT*CommonConstants.BYTE*CommonConstants.BYTE)){
return R.failed(InsurancesConstants.INSURANCE_ENCLOSURE_SIZE_ERROR); return R.failed(InsurancesConstants.INSURANCE_ENCLOSURE_SIZE_ERROR);
} }
String enclosureName = Objects.requireNonNull(file.getOriginalFilename()).substring(0,file.getOriginalFilename().lastIndexOf(".")); String fileName = System.currentTimeMillis() + CommonConstants.DOWN_LINE_STRING + file.getOriginalFilename();
String fileName = System.currentTimeMillis() + "_" + file.getOriginalFilename();
//filePath不传默认存储空间的根目录 //filePath不传默认存储空间的根目录
//支持的附件格式 //支持的附件格式
String key = ""; String key = "";
if (!Common.isNotNull(filePath)) { if (!Common.isNotNull(filePath)) {
key = fileName; key = fileName;
} else { } else {
key = filePath + "/" + fileName; key = filePath + CommonConstants.SLASH_SPLIT_LINE_STRING + fileName;
} }
boolean flag = ossUtil.uploadFileByStream(file.getInputStream(), key, null); boolean flag = ossUtil.uploadFileByStream(file.getInputStream(), key, null);
if (flag) { if (flag) {
...@@ -92,7 +91,7 @@ public class TInsuranceEnclosureServiceImpl extends ServiceImpl<TInsuranceEnclos ...@@ -92,7 +91,7 @@ public class TInsuranceEnclosureServiceImpl extends ServiceImpl<TInsuranceEnclos
try { try {
this.save(insuranceEnclosure); this.save(insuranceEnclosure);
} catch (Exception e) { } catch (Exception e) {
log.error("OSS文件上传接口异常:" + e.getMessage()); log.error(InsurancesConstants.OSS_ERROR + e.getMessage());
ossUtil.deleteObject(null, key); ossUtil.deleteObject(null, key);
return R.failed("failed:" + e.getMessage()); return R.failed("failed:" + e.getMessage());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment