|
|
@ -401,4 +401,35 @@ public class OssController { |
|
|
return ossService.uploadImgV2(file, PrivacyType.EXTERNAL, customerId); |
|
|
return ossService.uploadImgV2(file, PrivacyType.EXTERNAL, customerId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 办事指南上传附件 |
|
|
|
|
|
* @Param file |
|
|
|
|
|
* @Param customerId |
|
|
|
|
|
* @Return {@link Result< UploadImgResultDTO>} |
|
|
|
|
|
* @Author zhaoqifeng |
|
|
|
|
|
* @Date 2021/9/8 17:14 |
|
|
|
|
|
*/ |
|
|
|
|
|
@PostMapping("upload-guide-file") |
|
|
|
|
|
public Result<UploadImgResultDTO> uploadGuideFile(@RequestPart(value = "file") MultipartFile file, @RequestParam("customerId") String customerId) { |
|
|
|
|
|
String fileName = file.getOriginalFilename(); |
|
|
|
|
|
String format = "-" + fileName.substring(fileName.lastIndexOf(".") + NumConstant.ONE) + "-"; |
|
|
|
|
|
format = format.toLowerCase(); |
|
|
|
|
|
// 体积限制
|
|
|
|
|
|
int sizeMb = 10; |
|
|
|
|
|
// 大小限制10m
|
|
|
|
|
|
int sizeThreshold = sizeMb * 1024 * 1024; |
|
|
|
|
|
if (file.getSize() > sizeThreshold) { |
|
|
|
|
|
throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode(), |
|
|
|
|
|
EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg().concat(",限制在").concat(String.valueOf(sizeMb)).concat("M以内")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 格式限制,只允许png和jpeg
|
|
|
|
|
|
if (!ModuleConstant.GUIDE_FILE_DOC.contains(format)) { |
|
|
|
|
|
throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() |
|
|
|
|
|
, EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ossService.uploadImgV2(file, PrivacyType.EXTERNAL, customerId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|