Skip to content

Commit

Permalink
Update UserRecord.java
Browse files Browse the repository at this point in the history
  • Loading branch information
ather1234 authored Jan 5, 2025
1 parent baa4898 commit 0d8e1ab
Showing 1 changed file with 37 additions and 17 deletions.
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;
}
}

0 comments on commit 0d8e1ab

Please sign in to comment.