-
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.
- Loading branch information
1 parent
fe02cb8
commit c429652
Showing
5 changed files
with
35 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
@Data | ||
public class FindOrderQuery { | ||
String orderId; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
order-service/src/main/java/com.nashtech.order/query/FindOrdersByUserQuery.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,12 @@ | ||
package com.nashtech.order.query; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Data | ||
public class FindOrdersByUserQuery { | ||
String userId; | ||
} |
13 changes: 5 additions & 8 deletions
13
order-service/src/main/java/com.nashtech.order/query/OrderQueriesHandler.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 |
---|---|---|
@@ -1,26 +1,23 @@ | ||
package com.nashtech.order.query; | ||
|
||
import com.nashtech.common.utils.OrderStatus; | ||
import com.nashtech.order.repository.OrderRepository; | ||
import com.nashtech.order.restapi.response.OrderSummary; | ||
import com.nashtech.order.repository.entity.OrderEntity; | ||
import org.axonframework.queryhandling.QueryHandler; | ||
import org.springframework.stereotype.Component; | ||
import java.util.List; | ||
|
||
@Component | ||
public class OrderQueriesHandler { | ||
|
||
OrderRepository ordersRepository; | ||
private final OrderRepository ordersRepository; | ||
|
||
public OrderQueriesHandler(OrderRepository ordersRepository) { | ||
this.ordersRepository = ordersRepository; | ||
} | ||
|
||
@QueryHandler | ||
public OrderSummary findOrder(FindOrderQuery findOrderQuery) { | ||
return OrderSummary.builder() | ||
.orderId(findOrderQuery.getOrderId()) | ||
.orderStatus(OrderStatus.ORDER_PLACED.toString()) | ||
.build(); | ||
public List<OrderEntity> findOrders(FindOrdersByUserQuery findOrdersByUserQuery) { | ||
return ordersRepository.findByUserId(findOrdersByUserQuery.getUserId()); | ||
} | ||
|
||
} |
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