public void saveAttachment(String businessId, String[] ids) {
        Set<String> existIds = attachmentRepository.findByBusinessIdIn(Collections.singleton(businessId))
                .stream().map(Attachment::getId).collect(Collectors.toSet());
        if (CollectionUtils.isEmpty(existIds)) {
            if (ArrayUtils.isEmpty(ids)) {
                return;
            }
            this.saveBusinessId(businessId, Arrays.stream(ids).collect(Collectors.toSet()));
            return;
        }
        Pair<Set<String>, Set<String>> savePair = ListUtils.compareSaveIds(ids, existIds);
        if (CollectionUtils.isNotEmpty(savePair.getLeft())) {
            attachmentRepository.deleteAllById(savePair.getLeft());
        }
        if (CollectionUtils.isNotEmpty(savePair.getRight())) {
            saveBusinessId(businessId, savePair.getRight());
        }
    }
saveBusinessId

@param ids ids
@param businessId businessId
src/main/java/com/tuituidan/openhub/service/AttachmentService.java