All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.saphyra.randwo.item.service.delete.DeleteItemByItemIdService Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.github.saphyra.randwo.item.service.delete;

import java.util.List;
import java.util.UUID;

import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.github.saphyra.exceptionhandling.domain.ErrorMessage;
import com.github.saphyra.exceptionhandling.exception.BadRequestException;
import com.github.saphyra.randwo.common.CollectionValidator;
import com.github.saphyra.randwo.common.ErrorCode;
import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class DeleteItemByItemIdService {
    private final CollectionValidator collectionValidator;
    private final DeleteItemService deleteItemService;

    @Transactional
    public void deleteItems(List itemIds) {
        if (itemIds.isEmpty()) {
            throw new BadRequestException(new ErrorMessage(ErrorCode.EMPTY_ITEM_IDS.getErrorCode()), "itemIds is empty.");
        }
        collectionValidator.validateDoesNotContainNull(itemIds, ErrorCode.NULL_ITEM_ID);
        itemIds.forEach(deleteItemService::delete);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy