Эх сурвалжийг харах

fix 唯一标签删除后删除对应标签组

zoujiajian 2 жил өмнө
parent
commit
b2c0b908fa

+ 5 - 0
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpTagServiceImpl.java

@@ -364,6 +364,7 @@ public class CorpTagServiceImpl implements CorpTagService {
 			List<CorpTag> corpTags = corpTagMapper.selectList(Wrappers.lambdaQuery(CorpTag.class)
 					.eq(CorpTag::getTagId, tagId));
 			tagIds = corpTags.stream().filter(tag -> StrUtil.isNotBlank(tag.getTagId())).map(CorpTag::getTagId).toArray(String[]::new);
+			groupIds = corpTags.stream().filter(tag -> StrUtil.isNotEmpty(tag.getGroupId())).map(CorpTag::getGroupId).toArray(String[]::new);
 		}
 
 		if (StrUtil.isNotEmpty(groupId)) {
@@ -377,6 +378,10 @@ public class CorpTagServiceImpl implements CorpTagService {
 		}
 		if (StrUtil.isNotBlank(tagId)) {
 			corpTagMapper.delete(Wrappers.lambdaQuery(CorpTag.class).eq(CorpTag::getTagId, tagId));
+			Integer count = corpTagMapper.selectCount(Wrappers.lambdaQuery(CorpTag.class).in(CorpTag::getGroupId, groupIds));
+			if (count == 0) {
+				corpTagGroupMapper.delete(Wrappers.lambdaQuery(CorpTagGroup.class).in(CorpTagGroup::getGroupId, groupIds));
+			}
 		}
 
 		if (StrUtil.isNotBlank(groupId)) {