changed POST /customers/{id}/toaccounts endpoint result format
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<String> addToAccount(@PathVariable String id, @Validated @RequestBody ToAccountInfo request) {
|
||||
public Observable<AddToAccountResponse> 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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<HttpMessageConverter<?>> 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());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user