fix:进行design后library中可能会生成同样的图片

fix:ageGroup在designSingle时不会被存入数据库导致收藏页面不能显示完整
This commit is contained in:
litianxiang
2025-11-14 13:32:57 +08:00
parent ef84f32ca0
commit f3d6d7b000
5 changed files with 21 additions and 2 deletions

View File

@@ -124,4 +124,6 @@ public interface DesignService extends IService<Design> {
Boolean cloudTaskNameUpdate(CloudTaskDTO cloudTaskDTO);
Boolean cloudTaskDelete(CloudTaskDTO cloudTaskDTO);
String getAgeGroupByProjectOrCollectionId(Long projectId, Long collectionId);
}

View File

@@ -358,6 +358,16 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
if (CollectionUtils.isEmpty(elements)) {
return Boolean.TRUE;
}
// 根据MD5去重保留第一个出现的元素其余重复MD5的丢弃
elements = elements.stream()
.collect(Collectors.collectingAndThen(
Collectors.toMap(
CollectionElement::getMd5,
e -> e,
(e1, e2) -> e1 // 冲突时保留第一个
),
map -> new ArrayList<>(map.values())
));
//获取已存在相同的library
List<String> md5List = elements.stream().map(CollectionElement::getMd5).collect(Collectors.toList());
List<Library> existsLibrarys = libraryService.getByMD5List(md5List);

View File

@@ -1032,6 +1032,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
library.setLevel1Type(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName());
library.setLevel2Type(designSingleItem.getType());
library.setLevel3Type(designSingleIncludeLayersDTO.getGender());
String ageGroup = designService.getAgeGroupByProjectOrCollectionId(designSingleIncludeLayersDTO.getProjectId(), null);
library.setAgeGroup(ageGroup);
library.setUrl(designSingleItem.getPath());
library.setName(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")));
library.setMd5(md5);

View File

@@ -419,7 +419,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return requestId;
}
private String getAgeGroupByProjectOrCollectionId(Long projectId, Long collectionId){
public String getAgeGroupByProjectOrCollectionId(Long projectId, Long collectionId){
if (Objects.nonNull(projectId)){
Workspace workspace = workspaceService.getWSByProjectId(projectId);
if (workspace != null && !StringUtil.isNullOrEmpty(workspace.getAgeGroup())){

View File

@@ -789,7 +789,12 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
} else {
library.setLevel3Type(uploadDTO.getModelSex());
}
library.setAgeGroup(uploadDTO.getAgeGroup());
if (uploadDTO.getLevel1Type().equals(LibraryLevel1TypeEnum.SKETCH_BOARD.getRealName())&&StringUtils.isEmpty(uploadDTO.getAgeGroup())) {
log.error("前端未传ageGroup");
library.setAgeGroup("Adult");
} else {
library.setAgeGroup(uploadDTO.getAgeGroup());
}
libraryMapper.insert(library);
return library;
} else if (uploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {