Skip to content

Commit

Permalink
changed return type to dto
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorovychh committed Jan 3, 2024
1 parent 30d7efa commit d6659cf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public OrderResponseDto updateStatus(
summary = "Get all items by order id",
description = "Retrieve all OrderItems for a specific order"
)
public List<OrderItem> getAllById(@PathVariable Long id) {
public List<OrderItemResponseDto> getAllById(@PathVariable Long id) {
return orderItemService.getAllById(id);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
package com.app.bookstore.dto.order.item;

import lombok.Data;

@Data
public class OrderItemResponseDto {
private Long id;
private Long bookId;
private int quantity;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public interface OrderItemService {

List<OrderItem> getAllById(Long id);
List<OrderItemResponseDto> getAllById(Long id);

OrderItemResponseDto getItemById(Long id, Long itemId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ public class OrderItemServiceImpl implements OrderItemService {
private final OrderItemMapper orderItemMapper;

@Override
public List<OrderItem> getAllById(Long id) {
return orderItemRepository.findAllById(id);
public List<OrderItemResponseDto> getAllById(Long id) {
List<OrderItem> items = orderItemRepository.findAllById(id);
return items.stream()
.map(orderItemMapper::toDto)
.toList();
}

@Override
Expand Down

0 comments on commit d6659cf

Please sign in to comment.