fix(分享): 分享目标重复

This commit is contained in:
fit2cloud-chenyw 2022-11-01 09:58:37 +08:00
parent 818d064370
commit 45929f8d10

View File

@ -31,6 +31,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@ -171,8 +172,6 @@ public class ShareService {
}
// 以上是业务代码
// 下面是消息发送
Set<Long> addUserIdSet = AuthUtils.userIdsByURD(addAuthURD);
@ -212,7 +211,6 @@ public class ShareService {
}
/**
*
* @param newTargets 新的分享目标
* @param shareNodes 已景分享目标
* @return
@ -384,7 +382,7 @@ public class ShareService {
if (CollectionUtils.isEmpty(targets))
return new ArrayList<>();
return targets.stream().filter(item -> StringUtils.isNotEmpty(item.getTargetName()))
.collect(Collectors.toList());
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(item -> item.getPanelId() + item.getType() + item.getTargetId()))), ArrayList::new));
}
public void removeSharesyPanel(String panelId) {
@ -447,7 +445,9 @@ public class ShareService {
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.UNSHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelId, panelGroup.getPid(), removeRequest.getTargetId(), targetType);
AuthURD sharedAuthURD = new AuthURD();
List<Long> removeIds = new ArrayList<Long>(){{add(removeRequest.getTargetId());}};
List<Long> removeIds = new ArrayList<Long>() {{
add(removeRequest.getTargetId());
}};
buildRedAuthURD(removeRequest.getType(), removeIds, sharedAuthURD);
CurrentUserDto user = AuthUtils.getUser();
Gson gson = new Gson();