Improved module name <functional-area>-<Command|Query>....

Standalone services now use the Event Store Server (many tests still use the embedded server)
This commit is contained in:
Chris Richardson
2015-04-14 19:08:07 -07:00
parent d166c9b852
commit 2e31853ad2
150 changed files with 1237 additions and 109 deletions

View File

@@ -0,0 +1,11 @@
dependencies {
compile project(":accounts-query-side-backend")
compile project(":common-web")
compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
compile "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
}

View File

@@ -0,0 +1,12 @@
package net.chrisrichardson.eventstore.javaexamples.banking.web.queryside;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.accounts.QuerySideAccountConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@Configuration
@Import({QuerySideAccountConfiguration.class})
@ComponentScan
public class QuerySideWebConfiguration {
}

View File

@@ -0,0 +1,43 @@
package net.chrisrichardson.eventstore.javaexamples.banking.web.queryside.accounts;
import net.chrisrichardson.eventstore.EntityIdentifier;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.accounts.AccountInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.accounts.AccountNotFoundException;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.accounts.AccountQueryService;
import net.chrisrichardson.eventstore.javaexamples.banking.web.util.DeferredUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import rx.functions.Func1;
import java.math.BigDecimal;
@RestController
public class AccountQueryController {
private AccountQueryService accountInfoQueryService;
@Autowired
public AccountQueryController(AccountQueryService accountInfoQueryService) {
this.accountInfoQueryService = accountInfoQueryService;
}
@RequestMapping(value="/accounts/{accountId}", method = RequestMethod.GET)
public DeferredResult<GetAccountResponse> get(@PathVariable String accountId) {
return DeferredUtils.toDeferredResult(accountInfoQueryService.findByAccountId(new EntityIdentifier(accountId)).map(new Func1<AccountInfo, GetAccountResponse>() {
@Override
public GetAccountResponse call(AccountInfo accountInfo) {
return new GetAccountResponse(accountInfo.getId(), new BigDecimal(accountInfo.getBalance()));
}
}));
}
@ResponseStatus(value= HttpStatus.NOT_FOUND, reason="account not found")
@ExceptionHandler(AccountNotFoundException.class)
public void accountNotFound() {
}
}

View File

@@ -0,0 +1,33 @@
package net.chrisrichardson.eventstore.javaexamples.banking.web.queryside.accounts;
import java.math.BigDecimal;
public class GetAccountResponse {
private String accountId;
private BigDecimal balance;
public GetAccountResponse() {
}
public GetAccountResponse(String accountId, BigDecimal balance) {
this.accountId = accountId;
this.balance = balance;
}
public void setBalance(BigDecimal balance) {
this.balance = balance;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccountId() {
return accountId;
}
public BigDecimal getBalance() {
return balance;
}
}