public void userStarCard(String userId, String[] cardIds) {
        Set<String> existIds = userStarRepository.findByUserId(userId).stream()
                .map(UserStar::getCardId).collect(Collectors.toSet());
        if (CollectionUtils.isEmpty(existIds)) {
            if (ArrayUtils.isEmpty(cardIds)) {
                return;
            }
            userStarRepository.saveAll(Arrays.stream(cardIds).map(cardId -> new UserStar().setUserId(userId)
                    .setCardId(cardId).setId(StringExtUtils.getUuid())).collect(Collectors.toList()));
            return;
        }
        Pair<Set<String>, Set<String>> savePair = ListUtils.compareSaveIds(cardIds, existIds);
        if (CollectionUtils.isNotEmpty(savePair.getLeft())) {
            userStarRepository.deleteByUserIdAndCardIdIn(userId, savePair.getLeft());
        }
        if (CollectionUtils.isNotEmpty(savePair.getRight())) {
            userStarRepository.saveAll(savePair.getRight().stream().map(cardId -> new UserStar().setUserId(userId)
                    .setCardId(cardId).setId(StringExtUtils.getUuid())).collect(Collectors.toList()));
        }
    }
userStarCard

@param userId userId
@param cardIds cardIds
src/main/java/com/tuituidan/openhub/service/UserService.java