From 9a9511b2c4f02da5cf23d7b66f742b8326f0572c Mon Sep 17 00:00:00 2001 From: dartpopikyardo Date: Thu, 24 Mar 2016 21:37:54 +0300 Subject: [PATCH] changed POST /customers/{id}/toaccounts endpoint result format --- .../customers/AddToAccountResponse.java | 24 +++++++++++++++++++ .../customers/CustomerController.java | 5 ++-- .../CustomersCommandSideWebConfiguration.java | 12 ---------- 3 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 java-spring/common-customers/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/common/customers/AddToAccountResponse.java diff --git a/java-spring/common-customers/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/common/customers/AddToAccountResponse.java b/java-spring/common-customers/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/common/customers/AddToAccountResponse.java new file mode 100644 index 0000000..296699e --- /dev/null +++ b/java-spring/common-customers/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/common/customers/AddToAccountResponse.java @@ -0,0 +1,24 @@ +package net.chrisrichardson.eventstore.javaexamples.banking.common.customers; + +/** + * Created by popikyardo on 24.03.16. + */ +public class AddToAccountResponse { + + private String version; + + public AddToAccountResponse() { + } + + public AddToAccountResponse(String version) { + this.version = version; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } +} diff --git a/java-spring/customers-command-side-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/commandside/customers/CustomerController.java b/java-spring/customers-command-side-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/commandside/customers/CustomerController.java index 1901f12..9407da3 100644 --- a/java-spring/customers-command-side-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/commandside/customers/CustomerController.java +++ b/java-spring/customers-command-side-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/commandside/customers/CustomerController.java @@ -1,6 +1,7 @@ package net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.customers; import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.customers.CustomerService; +import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.AddToAccountResponse; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerInfo; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerResponse; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.ToAccountInfo; @@ -30,9 +31,9 @@ public class CustomerController { } @RequestMapping(value = "/{id}/toaccounts", method = RequestMethod.POST) - public Observable addToAccount(@PathVariable String id, @Validated @RequestBody ToAccountInfo request) { + public Observable addToAccount(@PathVariable String id, @Validated @RequestBody ToAccountInfo request) { return customerService.addToAccount(id, request) - .map(entityAndEventInfo -> entityAndEventInfo.entityVersion().asString()); + .map(entityAndEventInfo -> new AddToAccountResponse(entityAndEventInfo.entityVersion().asString())); } } diff --git a/java-spring/customers-command-side-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/commandside/customers/CustomersCommandSideWebConfiguration.java b/java-spring/customers-command-side-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/commandside/customers/CustomersCommandSideWebConfiguration.java index 17e889d..d2024e0 100644 --- a/java-spring/customers-command-side-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/commandside/customers/CustomersCommandSideWebConfiguration.java +++ b/java-spring/customers-command-side-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/commandside/customers/CustomersCommandSideWebConfiguration.java @@ -6,9 +6,6 @@ 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.StringHttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.method.support.HandlerMethodReturnValueHandler; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; @@ -34,13 +31,4 @@ public class CustomersCommandSideWebConfiguration extends WebMvcConfigurerAdapte adapter.setReturnValueHandlers(handlers); return new FakeThing(); } - - @Override - public void configureMessageConverters(List> converters) { - // put the jackson converter to the front of the list so that application/json content-type strings will be treated as JSON - converters.add(new MappingJackson2HttpMessageConverter()); - // and probably needs a string converter too for text/plain content-type strings to be properly handled - converters.add(new StringHttpMessageConverter()); - } - } \ No newline at end of file