| | |
| | | @Override |
| | | public StandardMethodAttachment uploadAttachment(Integer standardMethodId, MultipartFile file) { |
| | | if (standardMethodMapper.selectById(standardMethodId) == null) throw new BaseException("标准不存在"); |
| | | if (file == null || file.isEmpty() || file.getSize() > 10 * 1024 * 1024) throw new BaseException("附件不能为空且不能超过10MB"); |
| | | if (file == null || file.isEmpty() || file.getSize() > 10 * 1024 * 1024) |
| | | throw new BaseException("附件不能为空且不能超过10MB"); |
| | | String originalName = file.getOriginalFilename(); |
| | | if (originalName == null || !originalName.matches("(?i).+\\.(jpg|jpeg|png|gif|doc|docx|xls|xlsx|ppt|pptx|pdf|zip|rar)$")) throw new BaseException("不支持的附件格式"); |
| | | if (originalName == null || !originalName.matches("(?i).+\\.(jpg|jpeg|png|gif|doc|docx|xls|xlsx|ppt|pptx|pdf|zip|rar)$")) |
| | | throw new BaseException("不支持的附件格式"); |
| | | try { |
| | | boolean image = originalName.matches("(?i).+\\.(jpg|jpeg|png|gif)$"); |
| | | File directory = new File(image ? filePath : wordUrl); |