Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UserRecord.java #21

Open
wants to merge 1 commit into
base: flow
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 37 additions & 17 deletions src/main/java/com/jpmc/midascore/entity/UserRecord.java
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;
}
}