Merge commit '40e03dd8e6d805a6f322c25861b3bebda306a947' into wip-customer
* commit '40e03dd8e6d805a6f322c25861b3bebda306a947':
- updated swagger schema
- added GET /accounts/{accountId}/history endpoint to get transactions history by accountId - updated swagger schema
- added GET /accounts/{accountId}/history endpoint to get transactions history by accountId - updated swagger schema
This commit is contained in:
@@ -13,4 +13,36 @@ public class AccountTransactionInfo {
|
||||
this.toAccountId = toAccountId;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public void setTransactionId(String transactionId) {
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
|
||||
public String getFromAccountId() {
|
||||
return fromAccountId;
|
||||
}
|
||||
|
||||
public void setFromAccountId(String fromAccountId) {
|
||||
this.fromAccountId = fromAccountId;
|
||||
}
|
||||
|
||||
public String getToAccountId() {
|
||||
return toAccountId;
|
||||
}
|
||||
|
||||
public void setToAccountId(String toAccountId) {
|
||||
this.toAccountId = toAccountId;
|
||||
}
|
||||
|
||||
public long getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(long amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
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.backend.queryside.accounts.AccountTransactionInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -22,7 +24,7 @@ public class AccountQueryController {
|
||||
this.accountInfoQueryService = accountInfoQueryService;
|
||||
}
|
||||
|
||||
@RequestMapping(value="/accounts/{accountId}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/accounts/{accountId}", method = RequestMethod.GET)
|
||||
public Observable<GetAccountResponse> get(@PathVariable String accountId) {
|
||||
return accountInfoQueryService.findByAccountId(new EntityIdentifier(accountId))
|
||||
.map(accountInfo -> new GetAccountResponse(accountInfo.getId(), new BigDecimal(accountInfo.getBalance()), accountInfo.getTitle(), accountInfo.getDescription()));
|
||||
@@ -34,6 +36,12 @@ public class AccountQueryController {
|
||||
.map(accountInfoList -> accountInfoList.stream().map(accountInfo -> new GetAccountResponse(accountInfo.getId(), new BigDecimal(accountInfo.getBalance()), accountInfo.getTitle(), accountInfo.getDescription())).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/accounts/{accountId}/history", method = RequestMethod.GET)
|
||||
public Observable<List<AccountTransactionInfo>> getTransactionsHistory(@PathVariable String accountId) {
|
||||
return accountInfoQueryService.findByAccountId(new EntityIdentifier(accountId))
|
||||
.map(AccountInfo::getTransactions);
|
||||
}
|
||||
|
||||
@ResponseStatus(value= HttpStatus.NOT_FOUND, reason="account not found")
|
||||
@ExceptionHandler(AccountNotFoundException.class)
|
||||
public void accountNotFound() {
|
||||
|
||||
@@ -43,6 +43,39 @@
|
||||
],
|
||||
"paths": {
|
||||
"/accounts": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"account-query-controller"
|
||||
],
|
||||
"summary": "getAccountsForCustomer",
|
||||
"operationId": "getAccountsForCustomerUsingGET",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"*/*"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "customerId",
|
||||
"in": "query",
|
||||
"description": "customerId",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/GetAccountResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"tags": [
|
||||
"account-controller"
|
||||
@@ -108,6 +141,41 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/accounts/{accountId}/history": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"account-query-controller"
|
||||
],
|
||||
"summary": "getTransactionsHistory",
|
||||
"operationId": "getTransactionsHistoryUsingGET",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"*/*"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "accountId",
|
||||
"in": "path",
|
||||
"description": "accountId",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/AccountTransactionInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/customers": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -312,6 +380,29 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"auth-controller"
|
||||
],
|
||||
"summary": "getCurrentUser",
|
||||
"operationId": "getCurrentUserUsingGET",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"*/*"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/QuerySideCustomer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
@@ -385,6 +476,9 @@
|
||||
},
|
||||
"ToAccountInfo": {
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -414,6 +508,12 @@
|
||||
"balance": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -422,6 +522,9 @@
|
||||
"customerId": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"initialBalance": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
@@ -441,6 +544,29 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"AccountTransactionInfo": {
|
||||
"properties": {
|
||||
"amount": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"fromAccountId": {
|
||||
"type": "string"
|
||||
},
|
||||
"toAccountId": {
|
||||
"type": "string"
|
||||
},
|
||||
"transactionId": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Map«string,ToAccountInfo»": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/ToAccountInfo"
|
||||
}
|
||||
},
|
||||
"CreateMoneyTransferRequest": {
|
||||
"properties": {
|
||||
"amount": {
|
||||
|
||||
Reference in New Issue
Block a user