Przeglądaj źródła

fix 删除企业标签

zoujiajian 2 lat temu
rodzic
commit
05d4623ee6

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

@@ -365,11 +365,11 @@ public class CorpTagServiceImpl implements CorpTagService {
 		}
 		String[] tagIds = null;
 		String[] groupIds = null;
+		List<CorpTag> corpTags = null;
 		if (StrUtil.isNotEmpty(tagId)) {
-			List<CorpTag> corpTags = corpTagMapper.selectList(Wrappers.lambdaQuery(CorpTag.class)
+			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)) {
@@ -386,9 +386,12 @@ 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 (CollUtil.isNotEmpty(corpTags)) {
+				groupIds = corpTags.stream().filter(tag -> StrUtil.isNotEmpty(tag.getGroupId())).map(CorpTag::getGroupId).toArray(String[]::new);
+				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));
+				}
 			}
 		}