feat: added userId to entities

This commit is contained in:
effe 2024-09-14 10:46:31 -04:00
parent 52ec376e4d
commit 73d1811d04
4 changed files with 8 additions and 1 deletions

View file

@ -21,4 +21,7 @@ public class Category {
@Column(name = "Description")
private String description;
@Column(name = "userId", nullable = false, unique = true)
private Long userId;
}

View file

@ -64,4 +64,7 @@ public class Expense {
@Enumerated(EnumType.STRING)
@Column(name = "expenseType", nullable = false)
private ExpenseType expenseType;
@Column(name = "userId", nullable = false, unique = true)
private Long userId;
}

View file

@ -49,7 +49,7 @@ public class Person {
@Column(name = "Username", unique = true)
private String username; // This field will link to the User entity
@Column(name = "UserId", unique = true)
@Column(name = "UserId", unique = true, nullable = false)
private Long userId; // Reference to the User entity
@Override

View file

@ -146,6 +146,7 @@ public class ExpenseService {
*/
public void update(Expense entity) {
if (Boolean.TRUE.equals(entity.getIsPaid())) entity.setPaymentDate(LocalDate.now());
else entity.setPaymentDate(null);
this.setExpenseType(entity);
expenseRepository.save(entity);
}