-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,66 @@ | ||
package com.jpmc.midascore.entity; | ||
|
||
import jakarta.persistence.*; | ||
import java.math.BigDecimal; | ||
|
||
@Entity | ||
public class UserRecord { | ||
public class TransactionRecord { | ||
|
||
@Id | ||
@GeneratedValue() | ||
private long id; | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
@ManyToOne | ||
@JoinColumn(name = "sender_id", nullable = false) | ||
private User sender; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "recipient_id", nullable = false) | ||
private User recipient; | ||
|
||
@Column(nullable = false) | ||
private float balance; | ||
private BigDecimal amount; | ||
|
||
protected UserRecord() { | ||
protected TransactionRecord() { | ||
} | ||
|
||
public UserRecord(String name, float balance) { | ||
this.name = name; | ||
this.balance = balance; | ||
public TransactionRecord(User sender, User recipient, BigDecimal amount) { | ||
this.sender = sender; | ||
this.recipient = recipient; | ||
this.amount = amount; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("User[id=%d, name='%s', balance='%f'", id, name, balance); | ||
return String.format("Transaction[id=%d, sender='%s', recipient='%s', amount='%s']", | ||
id, sender.getName(), recipient.getName(), amount); | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
public User getSender() { | ||
return sender; | ||
} | ||
|
||
public User getRecipient() { | ||
return recipient; | ||
} | ||
|
||
public BigDecimal getAmount() { | ||
return amount; | ||
} | ||
|
||
public void setSender(User sender) { | ||
this.sender = sender; | ||
} | ||
|
||
public float getBalance() { | ||
return balance; | ||
public void setRecipient(User recipient) { | ||
this.recipient = recipient; | ||
} | ||
|
||
public void setBalance(float balance) { | ||
this.balance = balance; | ||
public void setAmount(BigDecimal amount) { | ||
this.amount = amount; | ||
} | ||
} |