#75 Added transaction base classes
This commit is contained in:
28
src/main/java/de/rwu/easydrop/api/dto/TransactionDTO.java
Normal file
28
src/main/java/de/rwu/easydrop/api/dto/TransactionDTO.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package de.rwu.easydrop.api.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transaction data transfer object.
|
||||||
|
*
|
||||||
|
* @since 0.3.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TransactionDTO {
|
||||||
|
/**
|
||||||
|
* Offer ID.
|
||||||
|
*/
|
||||||
|
private String offerId;
|
||||||
|
/**
|
||||||
|
* Sales volume.
|
||||||
|
*/
|
||||||
|
private double volume;
|
||||||
|
/**
|
||||||
|
* Earnings (volume - cost).
|
||||||
|
*/
|
||||||
|
private double earnings;
|
||||||
|
/**
|
||||||
|
* Transaction timestamp.
|
||||||
|
*/
|
||||||
|
private String transactionTime;
|
||||||
|
}
|
||||||
30
src/main/java/de/rwu/easydrop/model/Transaction.java
Normal file
30
src/main/java/de/rwu/easydrop/model/Transaction.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package de.rwu.easydrop.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A transaction.
|
||||||
|
*
|
||||||
|
* @since 0.3.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Transaction {
|
||||||
|
/**
|
||||||
|
* Offer ID.
|
||||||
|
*
|
||||||
|
* @see Offer
|
||||||
|
*/
|
||||||
|
private String offerId;
|
||||||
|
/**
|
||||||
|
* Sales volume.
|
||||||
|
*/
|
||||||
|
private double volume;
|
||||||
|
/**
|
||||||
|
* Earnings (volume - cost).
|
||||||
|
*/
|
||||||
|
private double earnings;
|
||||||
|
/**
|
||||||
|
* Transaction timestamp.
|
||||||
|
*/
|
||||||
|
private String transactionTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package de.rwu.easydrop.service.mapping;
|
||||||
|
|
||||||
|
import de.rwu.easydrop.api.dto.TransactionDTO;
|
||||||
|
import de.rwu.easydrop.model.Transaction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps transaction DTOs and objects.
|
||||||
|
*
|
||||||
|
* @since 0.3.0
|
||||||
|
*/
|
||||||
|
public final class TransactionMapper {
|
||||||
|
/**
|
||||||
|
* Private constructor to prevent unwanted instantiation.
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always
|
||||||
|
*/
|
||||||
|
private TransactionMapper() throws UnsupportedOperationException {
|
||||||
|
throw new UnsupportedOperationException("This is a mapping class, don't instantiate it.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Transaction object from a corresponding DTO.
|
||||||
|
*
|
||||||
|
* @param dto Transaction Data Transfer Object
|
||||||
|
* @return Product
|
||||||
|
*/
|
||||||
|
public static Transaction mapTXFromDTO(final TransactionDTO dto) {
|
||||||
|
Transaction tx = new Transaction();
|
||||||
|
|
||||||
|
tx.setOfferId(dto.getOfferId());
|
||||||
|
tx.setVolume(dto.getVolume());
|
||||||
|
tx.setEarnings(dto.getEarnings());
|
||||||
|
tx.setTransactionTime(dto.getTransactionTime());
|
||||||
|
|
||||||
|
return tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a ProductDTO object from a corresponding Product.
|
||||||
|
*
|
||||||
|
* @param tx Transaction
|
||||||
|
* @return TransactionDTO
|
||||||
|
*/
|
||||||
|
public static TransactionDTO mapTXToDTO(final Transaction tx) {
|
||||||
|
TransactionDTO dto = new TransactionDTO();
|
||||||
|
|
||||||
|
dto.setOfferId(tx.getOfferId());
|
||||||
|
dto.setVolume(tx.getVolume());
|
||||||
|
dto.setEarnings(tx.getEarnings());
|
||||||
|
dto.setTransactionTime(tx.getTransactionTime());
|
||||||
|
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user