|
@@ -8,11 +8,14 @@ import com.qmth.sop.business.mapper.BasicAttachmentMapper;
|
|
|
import com.qmth.sop.business.service.BasicAttachmentService;
|
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
|
import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.sop.common.util.ServletUtil;
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.io.FilenameUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
@@ -39,7 +42,7 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
|
|
|
* @param file
|
|
|
*/
|
|
|
@Override
|
|
|
- public void validateAttachment(MultipartFile file) {
|
|
|
+ public void validateAttachment(MultipartFile file) throws IOException {
|
|
|
String fileName = FilenameUtils.getBaseName(file.getOriginalFilename());
|
|
|
String format = "." + FilenameUtils.getExtension(file.getOriginalFilename());
|
|
|
|
|
@@ -71,5 +74,10 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
|
|
|
if (b.doubleValue() > attachmentSize) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("文件大小不能超过" + attachmentSize + "MB");
|
|
|
}
|
|
|
+ String fileMd5 = DigestUtils.md5Hex(file.getBytes());
|
|
|
+ String md5 = ServletUtil.getRequestMd5();
|
|
|
+ if (!Objects.equals(fileMd5, md5)) {
|
|
|
+ throw ExceptionResultEnum.MD5_EQUALS_FALSE.exception();
|
|
|
+ }
|
|
|
}
|
|
|
}
|