|
@@ -1,22 +1,21 @@
|
|
|
package pl.dmss.vmaneliuk.database.model;
|
|
package pl.dmss.vmaneliuk.database.model;
|
|
|
|
|
|
|
|
import jakarta.persistence.*;
|
|
import jakarta.persistence.*;
|
|
|
-
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
@Entity
|
|
@Entity
|
|
|
@Table(name = "users")
|
|
@Table(name = "users")
|
|
|
public class User {
|
|
public class User {
|
|
|
|
|
+
|
|
|
@Id
|
|
@Id
|
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
private Long userId;
|
|
private Long userId;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@Column(nullable = false)
|
|
@Column(nullable = false)
|
|
|
private String fullName;
|
|
private String fullName;
|
|
|
|
|
|
|
|
- @Column(nullable = false)
|
|
|
|
|
|
|
+ @Column(nullable = false, unique = true)
|
|
|
private String email;
|
|
private String email;
|
|
|
|
|
|
|
|
@Column(nullable = false)
|
|
@Column(nullable = false)
|
|
@@ -27,15 +26,47 @@ public class User {
|
|
|
private BigDecimal walletBalance;
|
|
private BigDecimal walletBalance;
|
|
|
private BigDecimal totalSpent;
|
|
private BigDecimal totalSpent;
|
|
|
|
|
|
|
|
- @OneToOne(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY )
|
|
|
|
|
|
|
+ @OneToOne(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
|
|
private Library library;
|
|
private Library library;
|
|
|
|
|
|
|
|
- public void setMemberSince(LocalDateTime now) { memberSince = now;}
|
|
|
|
|
- public void setAccountStatus(String status) {accountStatus = status;}
|
|
|
|
|
- public void setWalletBalance(BigDecimal newWalletBalance) {walletBalance = newWalletBalance;}
|
|
|
|
|
- public void setTotalSpent(BigDecimal spent) { totalSpent = spent;}
|
|
|
|
|
|
|
+ // Default constructor (required by JPA)
|
|
|
|
|
+ public User() {}
|
|
|
|
|
+
|
|
|
|
|
+ // Getters and Setters
|
|
|
|
|
+
|
|
|
|
|
+ public Long getUserId() {return userId;}
|
|
|
|
|
+
|
|
|
|
|
+ public void setUserId(Long userId) {this.userId = userId;}
|
|
|
|
|
+
|
|
|
|
|
+ public String getFullName() {return fullName;}
|
|
|
|
|
+
|
|
|
|
|
+ public void setFullName(String fullName) {this.fullName = fullName;}
|
|
|
|
|
+
|
|
|
|
|
+ public String getEmail() {return email;}
|
|
|
|
|
+
|
|
|
|
|
+ public void setEmail(String email) {this.email = email;}
|
|
|
|
|
+
|
|
|
|
|
+ public String getPasswordHash() {return passwordHash;}
|
|
|
|
|
+
|
|
|
|
|
+ public void setPasswordHash(String passwordHash) {this.passwordHash = passwordHash;}
|
|
|
|
|
+
|
|
|
|
|
+ public String getAccountStatus() {return accountStatus;}
|
|
|
|
|
+
|
|
|
|
|
+ public void setAccountStatus(String accountStatus) {this.accountStatus = accountStatus;}
|
|
|
|
|
+
|
|
|
|
|
+ public LocalDateTime getMemberSince() {return memberSince;}
|
|
|
|
|
+
|
|
|
|
|
+ public void setMemberSince(LocalDateTime memberSince) {this.memberSince = memberSince;}
|
|
|
|
|
+
|
|
|
|
|
+ public BigDecimal getWalletBalance() {return walletBalance;}
|
|
|
|
|
+
|
|
|
|
|
+ public void setWalletBalance(BigDecimal walletBalance) {this.walletBalance = walletBalance;}
|
|
|
|
|
+
|
|
|
|
|
+ public BigDecimal getTotalSpent() {return totalSpent;}
|
|
|
|
|
+
|
|
|
|
|
+ public void setTotalSpent(BigDecimal totalSpent) {this.totalSpent = totalSpent;}
|
|
|
|
|
|
|
|
- public void setLibrary(Library library) {
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ public Library getLibrary() {return library;}
|
|
|
|
|
|
|
|
|
|
+ public void setLibrary(Library library) {this.library = library;}
|
|
|
|
|
+}
|