added new fields to TransferDetails

This commit is contained in:
dartpopikyardo
2016-03-22 14:46:03 +03:00
parent bdcdae862d
commit 7c6328aa5e
5 changed files with 36 additions and 4 deletions

View File

@@ -15,13 +15,16 @@ public class CreateMoneyTransferRequest {
@DecimalMin("0.01")
private BigDecimal amount;
private String description;
public CreateMoneyTransferRequest() {
}
public CreateMoneyTransferRequest(String fromAccountId, String toAccountId, BigDecimal amount) {
public CreateMoneyTransferRequest(String fromAccountId, String toAccountId, BigDecimal amount, String description) {
this.fromAccountId = fromAccountId;
this.toAccountId = toAccountId;
this.amount = amount;
this.description = description;
}
public void setFromAccountId(String fromAccountId) {
@@ -36,6 +39,10 @@ public class CreateMoneyTransferRequest {
this.amount = amount;
}
public void setDescription(String description) {
this.description = description;
}
public String getFromAccountId() {
return fromAccountId;
}
@@ -47,4 +54,8 @@ public class CreateMoneyTransferRequest {
public BigDecimal getAmount() {
return amount;
}
public String getDescription() {
return description;
}
}

View File

@@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import rx.Observable;
import java.util.Date;
@RestController
@RequestMapping("/transfers")
public class MoneyTransferController {
@@ -27,7 +29,9 @@ public class MoneyTransferController {
TransferDetails transferDetails = new TransferDetails(
new EntityIdentifier(request.getFromAccountId()),
new EntityIdentifier(request.getToAccountId()),
request.getAmount());
request.getAmount(),
new Date(),
request.getDescription());
return moneyTransferService.transferMoney(transferDetails)
.map(entityAndEventInfo -> new CreateMoneyTransferResponse(entityAndEventInfo.getEntityIdentifier().getId()));
}