Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Repository
- public class CustomItemRepositoryImpl implements CustomItemRepository {
- private final ItemRepository itemRepository;
- @Autowired
- public CustomItemRepositoryImpl(ItemRepository itemRepository) {
- this.itemRepository = itemRepository;
- }
- @Override
- public Page<Item> search(String name, String description, Collection<Long> categoryIds, Pageable pageable) {
- ItemSpecificationBuilder builder = new ItemSpecificationBuilder();
- Specification<Item> specs = builder
- .withNameLike(name)
- .withDescriptionLike(description)
- .withCategoriesIdsIn(categoryIds)
- .build();
- if (specs != null) {
- return itemRepository.findAll(specs, pageable);
- } else {
- return itemRepository.findAll(pageable);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement