BUGFIX: library upload md5重复校验优化;

This commit is contained in:
shahaibo
2023-10-18 15:54:23 +08:00
parent 4c11f2e280
commit 81d20625f5
4 changed files with 14 additions and 4 deletions

View File

@@ -90,7 +90,11 @@ public class LibraryController {
}
String md5 = MD5Utils.encryptFile(file);
if (checkMd5 == null || checkMd5 == 1) {
libraryService.checkMd5(level1Type, level2Type, sex, md5);
if (!libraryService.checkMd5(level1Type, level2Type, sex, md5)) {
LibraryUpdateVo libraryUpdateVo = new LibraryUpdateVo();
libraryUpdateVo.setCheckMd5(Boolean.FALSE);
return Response.success(libraryUpdateVo);
}
}
return Response.success(libraryService.upload(new LibraryUploadDTO(file, level1Type,level2Type,
timeZone, md5,high,width,modelType,sex)));

View File

@@ -43,5 +43,8 @@ public class LibraryUpdateVo implements Serializable {
@ApiModelProperty("存放地址")
private String minIOPath;
@ApiModelProperty("校验md5")
private Boolean checkMd5;
}

View File

@@ -72,5 +72,5 @@ public interface LibraryService extends IService<Library> {
String processMannequins(String uploadPath);
void checkMd5(String level1Type, String level2Type, String sex, String md5);
Boolean checkMd5(String level1Type, String level2Type, String sex, String md5);
}

View File

@@ -258,7 +258,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
}
@Override
public void checkMd5(String level1Type, String level2Type, String sex, String md5) {
public Boolean checkMd5(String level1Type, String level2Type, String sex, String md5) {
AuthPrincipalVo userInfo = UserContext.getUserHolder();
QueryWrapper<Library> qw = new QueryWrapper<>();
qw.lambda().eq(Library::getAccountId, userInfo.getId());
@@ -274,7 +274,10 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
qw.lambda().eq(Library::getMd5, md5);
List<Library> libraryList = libraryMapper.selectList(qw);
if (!CollectionUtils.isEmpty(libraryList)) {
throw new BusinessException("Your library already contains the images you uploaded, Are you sure to upload them");
// throw new BusinessException("Your library already contains the images you uploaded, Are you sure to upload them");
return Boolean.FALSE;
}else {
return Boolean.TRUE;
}
}