-
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
Showing
55 changed files
with
274 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dependencies { | ||
compile project(":common") | ||
compile project(":customer-api") | ||
compile project(":common-swagger") | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
FROM java:openjdk-8u111-alpine | ||
CMD java ${JAVA_OPTS} -jar customer-service-*.jar | ||
COPY build/libs/customer-service-*.jar . |
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,4 @@ | ||
dependencies { | ||
compile project(":common-swagger") | ||
compile project(":customer-backend") | ||
} |
26 changes: 26 additions & 0 deletions
26
...eventuate/examples/tram/sagas/ordersandcustomers/customers/web/CreateCustomerRequest.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,26 @@ | ||
package io.eventuate.examples.tram.sagas.ordersandcustomers.customers.web; | ||
|
||
import io.eventuate.examples.tram.sagas.ordersandcustomers.commondomain.Money; | ||
|
||
public class CreateCustomerRequest { | ||
private String name; | ||
private Money creditLimit; | ||
|
||
public CreateCustomerRequest() { | ||
} | ||
|
||
public CreateCustomerRequest(String name, Money creditLimit) { | ||
|
||
this.name = name; | ||
this.creditLimit = creditLimit; | ||
} | ||
|
||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Money getCreditLimit() { | ||
return creditLimit; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ventuate/examples/tram/sagas/ordersandcustomers/customers/web/CreateCustomerResponse.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,21 @@ | ||
package io.eventuate.examples.tram.sagas.ordersandcustomers.customers.web; | ||
|
||
|
||
public class CreateCustomerResponse { | ||
private Long customerId; | ||
|
||
public CreateCustomerResponse() { | ||
} | ||
|
||
public CreateCustomerResponse(Long customerId) { | ||
this.customerId = customerId; | ||
} | ||
|
||
public Long getCustomerId() { | ||
return customerId; | ||
} | ||
|
||
public void setCustomerId(Long customerId) { | ||
this.customerId = customerId; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...io/eventuate/examples/tram/sagas/ordersandcustomers/customers/web/CustomerController.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,23 @@ | ||
package io.eventuate.examples.tram.sagas.ordersandcustomers.customers.web; | ||
|
||
import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.domain.Customer; | ||
import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.service.CustomerService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
public class CustomerController { | ||
|
||
private CustomerService customerService; | ||
|
||
@Autowired | ||
public CustomerController(CustomerService customerService) { | ||
this.customerService = customerService; | ||
} | ||
|
||
@RequestMapping(value = "/customers", method = RequestMethod.POST) | ||
public CreateCustomerResponse createCustomer(@RequestBody CreateCustomerRequest createCustomerRequest) { | ||
Customer customer = customerService.createCustomer(createCustomerRequest.getName(), createCustomerRequest.getCreditLimit()); | ||
return new CreateCustomerResponse(customer.getId()); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ntuate/examples/tram/sagas/ordersandcustomers/customers/web/CustomerWebConfiguration.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,22 @@ | ||
package io.eventuate.examples.tram.sagas.ordersandcustomers.customers.web; | ||
|
||
import io.eventuate.examples.tram.sagas.ordersandcustomers.commonswagger.CommonSwaggerConfiguration; | ||
import org.springframework.boot.autoconfigure.web.HttpMessageConverters; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.http.converter.HttpMessageConverter; | ||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | ||
|
||
@Configuration | ||
@ComponentScan | ||
@Import(CommonSwaggerConfiguration.class) | ||
public class CustomerWebConfiguration { | ||
|
||
@Bean | ||
public HttpMessageConverters customConverters() { | ||
HttpMessageConverter<?> additional = new MappingJackson2HttpMessageConverter(); | ||
return new HttpMessageConverters(additional); | ||
} | ||
} |
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,8 +1,7 @@ | ||
dependencies { | ||
compile project(":customer-common") | ||
compile project(":order-common") | ||
compile project(":customer-web") | ||
compile project(":order-web") | ||
|
||
testCompile "io.eventuate.tram.core:eventuate-tram-in-memory:$eventuateTramVersion" | ||
testCompile "org.springframework.boot:spring-boot-starter-test:${springBootVersion}" | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dependencies { | ||
compile project(":customer-api") | ||
compile project(":common-swagger") | ||
} | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
FROM java:openjdk-8u111-alpine | ||
CMD java ${JAVA_OPTS} -jar order-service-*.jar | ||
COPY build/libs/order-service-*.jar . |
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,6 @@ | ||
dependencies { | ||
compile project(":common-swagger") | ||
compile project(":order-backend") | ||
} | ||
|
||
|
25 changes: 25 additions & 0 deletions
25
...va/io/eventuate/examples/tram/sagas/ordersandcustomers/orders/web/CreateOrderRequest.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,25 @@ | ||
package io.eventuate.examples.tram.sagas.ordersandcustomers.orders.web; | ||
|
||
|
||
import io.eventuate.examples.tram.sagas.ordersandcustomers.commondomain.Money; | ||
|
||
public class CreateOrderRequest { | ||
private Money orderTotal; | ||
private Long customerId; | ||
|
||
public CreateOrderRequest() { | ||
} | ||
|
||
public CreateOrderRequest(Long customerId, Money orderTotal) { | ||
this.customerId = customerId; | ||
this.orderTotal = orderTotal; | ||
} | ||
|
||
public Money getOrderTotal() { | ||
return orderTotal; | ||
} | ||
|
||
public Long getCustomerId() { | ||
return customerId; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...a/io/eventuate/examples/tram/sagas/ordersandcustomers/orders/web/CreateOrderResponse.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,17 @@ | ||
package io.eventuate.examples.tram.sagas.ordersandcustomers.orders.web; | ||
|
||
|
||
public class CreateOrderResponse { | ||
private Long orderId; | ||
|
||
public CreateOrderResponse() { | ||
} | ||
|
||
public CreateOrderResponse(Long orderId) { | ||
this.orderId = orderId; | ||
} | ||
|
||
public Long getOrderId() { | ||
return orderId; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...java/io/eventuate/examples/tram/sagas/ordersandcustomers/orders/web/GetOrderResponse.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,33 @@ | ||
package io.eventuate.examples.tram.sagas.ordersandcustomers.orders.web; | ||
|
||
|
||
import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.domain.OrderState; | ||
|
||
public class GetOrderResponse { | ||
private Long orderId; | ||
private OrderState orderState; | ||
|
||
public GetOrderResponse() { | ||
} | ||
|
||
public GetOrderResponse(Long orderId, OrderState orderState) { | ||
this.orderId = orderId; | ||
this.orderState = orderState; | ||
} | ||
|
||
public Long getOrderId() { | ||
return orderId; | ||
} | ||
|
||
public void setOrderId(Long orderId) { | ||
this.orderId = orderId; | ||
} | ||
|
||
public OrderState getOrderState() { | ||
return orderState; | ||
} | ||
|
||
public void setOrderState(OrderState orderState) { | ||
this.orderState = orderState; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
.../java/io/eventuate/examples/tram/sagas/ordersandcustomers/orders/web/OrderController.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,41 @@ | ||
package io.eventuate.examples.tram.sagas.ordersandcustomers.orders.web; | ||
|
||
import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.common.OrderDetails; | ||
import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.domain.Order; | ||
import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.domain.OrderRepository; | ||
import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.service.OrderService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
public class OrderController { | ||
|
||
private OrderService orderService; | ||
private OrderRepository orderRepository; | ||
|
||
@Autowired | ||
public OrderController(OrderService orderService, OrderRepository orderRepository) { | ||
this.orderService = orderService; | ||
this.orderRepository = orderRepository; | ||
} | ||
|
||
@RequestMapping(value = "/orders", method = RequestMethod.POST) | ||
public CreateOrderResponse createOrder(@RequestBody CreateOrderRequest createOrderRequest) { | ||
Order order = orderService.createOrder(new OrderDetails(createOrderRequest.getCustomerId(), createOrderRequest.getOrderTotal())); | ||
return new CreateOrderResponse(order.getId()); | ||
} | ||
|
||
@RequestMapping(value="/orders/{orderId}", method= RequestMethod.GET) | ||
public ResponseEntity<GetOrderResponse> getOrder(@PathVariable Long orderId) { | ||
|
||
Order order = orderRepository.findOne(orderId); | ||
|
||
if (order == null) { | ||
return new ResponseEntity<>(HttpStatus.NOT_FOUND); | ||
} else { | ||
return new ResponseEntity<>(new GetOrderResponse(order.getId(), order.getState()), HttpStatus.OK); | ||
} | ||
} | ||
} |
Oops, something went wrong.