Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
denomelchenko committed Jul 18, 2024
1 parent 124abae commit 037865c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;
import java.util.Set;

@Repository
Expand Down
12 changes: 2 additions & 10 deletions src/main/java/com/lalabrand/ecommerce/item/ItemService.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public PageOfItems findItemsByTitle(String title, Language language, Pageable pa
return PageOfItems.fromItemsPage(itemRepository.findByTitleContainingIgnoreCase(title, pageable));
}

public List<ItemDTO> findItemsByCategoryName(String categoryName, Pageable pageable) {
return convertToItemDtoList(itemRepository.findItemsByCategoryNameIgnoreCase(categoryName, pageable));
public PageOfItems findItemsByCategoryName(String categoryName, Pageable pageable) {
return PageOfItems.fromItemsPage(itemRepository.findItemsByCategoryNameIgnoreCase(categoryName, pageable));
}

public Item findItemByIdOrThrow(String itemId) {
Expand All @@ -61,14 +61,6 @@ public Set<Item> findItemsByIdsOrThrow(Collection<String> itemsIds) {
return items;
}

private List<ItemDTO> convertToItemDtoList(List<Item> items) {
List<ItemDTO> itemDTOList = new LinkedList<>();
for (Item item : items) {
itemDTOList.add(ItemDTO.fromEntity(item));
}
return itemDTOList;
}

public ItemDTO findById(String id) {
Optional<Item> item = itemRepository.findById(id);
if (item.isEmpty()) {
Expand Down

0 comments on commit 037865c

Please sign in to comment.