fix issue #13,

fix issue #14,
fix issue #15,
fix issue #17
This commit is contained in:
dartpopikyardo
2016-09-02 01:24:28 +03:00
parent 625ea6007e
commit f76912a6cf
12 changed files with 102 additions and 50 deletions

View File

@@ -1,19 +1,31 @@
package net.chrisrichardson.eventstore.javaexamples.banking.common.accounts;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import java.util.Date;
/**
* Created by popikyardo on 9/1/16.
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS,
include = JsonTypeInfo.As.PROPERTY,
property = "entryType")
@JsonSubTypes({
@JsonSubTypes.Type(value = AccountTransactionInfo.class, name = "transaction"),
@JsonSubTypes.Type(value = AccountOpenInfo.class, name = "account")
})
public class AccountHistoryEntry {
protected Date date;
protected EntryType entryType;
public AccountHistoryEntry() {
}
public AccountHistoryEntry(Date date) {
public AccountHistoryEntry(Date date, EntryType entryType) {
this.date = date;
this.entryType = entryType;
}
public Date getDate() {
@@ -23,4 +35,16 @@ public class AccountHistoryEntry {
public void setDate(Date date) {
this.date = date;
}
public EntryType getEntryType() {
return entryType;
}
public void setEntryType(EntryType entryType) {
this.entryType = entryType;
}
public enum EntryType {
transaction, account
}
}

View File

@@ -6,40 +6,21 @@ import java.util.List;
* Created by popikyardo on 9/1/16.
*/
public class AccountHistoryResponse {
private AccountHistoryEntry accountOpened;
private List<AccountTransactionInfo> transactionsHistory;
private List<AccountChangeInfo> accountChangesHistory;
private List<AccountHistoryEntry> transactionsHistory;
public AccountHistoryResponse() {
}
public AccountHistoryResponse(AccountHistoryEntry accountOpened, List<AccountTransactionInfo> transactionsHistory, List<AccountChangeInfo> accountChangesHistory) {
this.accountOpened = accountOpened;
public AccountHistoryResponse(List<AccountHistoryEntry> transactionsHistory) {
this.transactionsHistory = transactionsHistory;
this.accountChangesHistory = accountChangesHistory;
}
public AccountHistoryEntry getAccountOpened() {
return accountOpened;
}
public void setAccountOpened(AccountHistoryEntry accountOpened) {
this.accountOpened = accountOpened;
}
public List<AccountTransactionInfo> getTransactionsHistory() {
public List<AccountHistoryEntry> getTransactionsHistory() {
return transactionsHistory;
}
public void setTransactionsHistory(List<AccountTransactionInfo> transactionsHistory) {
public void setTransactionsHistory(List<AccountHistoryEntry> transactionsHistory) {
this.transactionsHistory = transactionsHistory;
}
public List<AccountChangeInfo> getAccountChangesHistory() {
return accountChangesHistory;
}
public void setAccountChangesHistory(List<AccountChangeInfo> accountChangesHistory) {
this.accountChangesHistory = accountChangesHistory;
}
}

View File

@@ -0,0 +1,16 @@
package net.chrisrichardson.eventstore.javaexamples.banking.common.accounts;
import java.util.Date;
/**
* Created by popikyardo on 9/1/16.
*/
public class AccountOpenInfo extends AccountHistoryEntry {
public AccountOpenInfo() {
}
public AccountOpenInfo(Date date, EntryType entryType) {
super(date, entryType);
}
}

View File

@@ -1,19 +1,20 @@
package net.chrisrichardson.eventstore.javaexamples.banking.common.accounts;
import net.chrisrichardson.eventstore.javaexamples.banking.common.transactions.TransferState;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import java.util.Date;
public class AccountTransactionInfo {
public class AccountTransactionInfo extends AccountHistoryEntry{
private String transactionId;
private String fromAccountId;
private String toAccountId;
private long amount;
private Date date;
private String description;
private TransferState status = TransferState.INITIAL;
public AccountTransactionInfo() {
}
@@ -35,6 +36,7 @@ public class AccountTransactionInfo {
this.amount = amount;
this.date = date;
this.description = description;
this.entryType = EntryType.transaction;
}
public String getTransactionId() {
@@ -69,14 +71,6 @@ public class AccountTransactionInfo {
this.amount = amount;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getDescription() {
return description;
}
@@ -85,6 +79,14 @@ public class AccountTransactionInfo {
this.description = description;
}
public TransferState getStatus() {
return status;
}
public void setStatus(TransferState status) {
this.status = status;
}
@Override
public boolean equals(Object o) {
return EqualsBuilder.reflectionEquals(this, o);

View File

@@ -0,0 +1,5 @@
package net.chrisrichardson.eventstore.javaexamples.banking.common.transactions;
public enum TransferState {
NEW, INITIAL, DEBITED, COMPLETED, FAILED_DUE_TO_INSUFFICIENT_FUNDS
}