Browse Source

新增:上传报事文件接口

dev_shibei_match
wxz 4 years ago
parent
commit
f9ac0ce789
  1. 28
      epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java

28
epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java

@ -22,6 +22,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AliyunGroup;
import com.epmet.commons.tools.validator.group.QcloudGroup;
import com.epmet.commons.tools.validator.group.QiniuGroup;
import com.epmet.constants.PrivacyType;
import com.epmet.dto.UploadDTO;
import com.epmet.dto.form.RemoveFileFormDTO;
import com.epmet.dto.result.UploadImgResultDTO;
@ -373,4 +374,31 @@ public class OssController {
return ossService.uploadImgV2(file, null, customerId);
}
/**
* @Description 上传报事文件(目前只有图片)
* @return
* @author wxz
* @date 2021.08.03 16:23
*/
@PostMapping("upload-resi-event-file")
public Result<UploadImgResultDTO> uploadResiEventFile(@RequestPart(value = "file") MultipartFile file, @RequestParam("customerId") String customerId) {
// 体积限制
int sizeMb = 10;
int sizeThreshold = sizeMb * 1024 * 1024; // 大小限制10m
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 (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType())
&& !MediaType.IMAGE_JPEG_VALUE.equals(file.getContentType())) {
throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode()
, EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg());
}
return ossService.uploadImgV2(file, PrivacyType.EXTERNAL, customerId);
}
}

Loading…
Cancel
Save