-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
realized function to get order items by order id
- Loading branch information
1 parent
bed87ee
commit 9eeeb25
Showing
6 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/com/app/bookstore/repository/order/item/OrderItemRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.app.bookstore.repository.order.item; | ||
|
||
import com.app.bookstore.model.OrderItem; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import java.util.List; | ||
|
||
public interface OrderItemRepository extends JpaRepository<OrderItem, Long> { | ||
@Query("SELECT oi FROM OrderItem oi " | ||
+ "JOIN FETCH oi.order " | ||
+ "JOIN FETCH oi.book " | ||
+ "WHERE oi.order.id = :id") | ||
List<OrderItem> findAllById(Long id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/com/app/bookstore/service/order/item/OrderItemService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.app.bookstore.service.order.item; | ||
|
||
import com.app.bookstore.model.OrderItem; | ||
|
||
import java.util.List; | ||
|
||
public interface OrderItemService { | ||
|
||
List<OrderItem> getAllById(Long id); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/app/bookstore/service/order/item/OrderItemServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.app.bookstore.service.order.item; | ||
|
||
import com.app.bookstore.model.OrderItem; | ||
import com.app.bookstore.repository.order.OrderRepository; | ||
import com.app.bookstore.repository.order.item.OrderItemRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class OrderItemServiceImpl implements OrderItemService { | ||
private final OrderItemRepository orderItemRepository; | ||
|
||
@Override | ||
public List<OrderItem> getAllById(Long id) { | ||
return orderItemRepository.findAllById(id); | ||
} | ||
} |