diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java index 4fc64984c9..8ab04b8758 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java @@ -401,4 +401,35 @@ public class OssController { 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 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); + } + } diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/utils/ModuleConstant.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/utils/ModuleConstant.java index 07a11d9ed7..71d5f177e2 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/utils/ModuleConstant.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/utils/ModuleConstant.java @@ -43,6 +43,7 @@ public interface ModuleConstant extends Constant { * 项目附件-允许的文件类型 */ String PROJECT_FILE_DOC = "-pdf-ppt-pptx-doc-docx-xls-xlsx-"; + String GUIDE_FILE_DOC = "-pdf-doc-docx-xls-xlsx-"; /** * 项目附件-允许的音频类型 */