Showing
1 changed file
with
5 additions
and
5 deletions
| ... | @@ -34,21 +34,21 @@ public class AttachmentValidate { | ... | @@ -34,21 +34,21 @@ public class AttachmentValidate { |
| 34 | */ | 34 | */ |
| 35 | public void validateFile(MultipartFile[] files, ConsignmentBo consignmentBo){ | 35 | public void validateFile(MultipartFile[] files, ConsignmentBo consignmentBo){ |
| 36 | //文件为空 | 36 | //文件为空 |
| 37 | - if(Objects.isNull(files) | 37 | + if(Objects.isNull(consignmentBo) |
| 38 | - || files.length == DigitConstants.DIGIT_ZERO | ||
| 39 | - || Objects.isNull(consignmentBo) | ||
| 40 | || Objects.isNull(consignmentBo.getAttachmentBizTypeList())){ | 38 | || Objects.isNull(consignmentBo.getAttachmentBizTypeList())){ |
| 41 | responseUtils.fail(ResponseCode.MESSAGE_CODE_30006); | 39 | responseUtils.fail(ResponseCode.MESSAGE_CODE_30006); |
| 42 | } | 40 | } |
| 43 | //上传最大文件个数限制 | 41 | //上传最大文件个数限制 |
| 44 | - if(files.length > CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_TOTAL){ | 42 | + if(Objects.nonNull(files) && files.length > CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_TOTAL){ |
| 45 | responseUtils.fail(ResponseCode.MESSAGE_CODE_30007,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_TOTAL); | 43 | responseUtils.fail(ResponseCode.MESSAGE_CODE_30007,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_TOTAL); |
| 46 | } | 44 | } |
| 47 | //上传总文件大小限制 | 45 | //上传总文件大小限制 |
| 48 | List<Long> fileSizeList = new ArrayList<>(); | 46 | List<Long> fileSizeList = new ArrayList<>(); |
| 49 | - for(MultipartFile file : files){ | 47 | + if(Objects.nonNull(files)) { |
| 48 | + for (MultipartFile file : files) { | ||
| 50 | fileSizeList.add(file.getSize()); | 49 | fileSizeList.add(file.getSize()); |
| 51 | } | 50 | } |
| 51 | + } | ||
| 52 | //总文件大小 | 52 | //总文件大小 |
| 53 | Long totalSize = Utils.listOf(fileSizeList).stream().filter(Objects::nonNull) | 53 | Long totalSize = Utils.listOf(fileSizeList).stream().filter(Objects::nonNull) |
| 54 | .mapToLong(f -> Optional.ofNullable(f).orElse(0L)).sum(); | 54 | .mapToLong(f -> Optional.ofNullable(f).orElse(0L)).sum(); | ... | ... |
-
Please register or login to post a comment