-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
8 changed files
with
87 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
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
31 changes: 31 additions & 0 deletions
31
query-service/src/main/java/org/learn/eventuate/queryservice/controller/QueryController.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,31 @@ | ||
package org.learn.eventuate.queryservice.controller; | ||
|
||
import org.learn.eventuate.coreapi.ProductInfo; | ||
import org.learn.eventuate.queryservice.model.Order; | ||
import org.learn.eventuate.queryservice.repository.OrderRepository; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class QueryController { | ||
|
||
public static final Logger log = LoggerFactory.getLogger(QueryController.class); | ||
|
||
@Autowired | ||
private OrderRepository orderRepository; | ||
|
||
@GetMapping("/test") | ||
public void getTest() { | ||
orderRepository.deleteAll(); | ||
|
||
log.info("trying to persist entity"); | ||
orderRepository.save(new Order("testId", new ProductInfo("testProduct", "testComment", 100))); | ||
orderRepository.save(new Order("testId2", new ProductInfo("testProduct2", "testComment2", 200))); | ||
|
||
log.info("trying to retrieve data"); | ||
orderRepository.findAll().forEach(System.out::println); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
query-service/src/main/java/org/learn/eventuate/queryservice/model/Order.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,31 @@ | ||
package org.learn.eventuate.queryservice.model; | ||
|
||
import org.learn.eventuate.coreapi.ProductInfo; | ||
import org.springframework.data.annotation.Id; | ||
|
||
public class Order { | ||
|
||
@Id | ||
private String id; | ||
|
||
private String orderId; | ||
private ProductInfo productInfo; | ||
|
||
public Order(String orderId, ProductInfo productInfo) { | ||
this.orderId = orderId; | ||
this.productInfo = productInfo; | ||
} | ||
|
||
public String getOrderId() { | ||
return orderId; | ||
} | ||
|
||
public ProductInfo getProductInfo() { | ||
return productInfo; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("id: %s, product - %s", orderId, productInfo.getProductId()); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
query-service/src/main/java/org/learn/eventuate/queryservice/repository/OrderRepository.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,8 @@ | ||
package org.learn.eventuate.queryservice.repository; | ||
|
||
import org.learn.eventuate.queryservice.model.Order; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
|
||
public interface OrderRepository extends MongoRepository<Order, String> { | ||
|
||
} |
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