1 | package mk.ukim.finki.wp.bankappfinal.model;
|
---|
2 |
|
---|
3 | import jakarta.persistence.*;
|
---|
4 |
|
---|
5 | import org.springframework.security.core.GrantedAuthority;
|
---|
6 | import org.springframework.security.core.userdetails.UserDetails;
|
---|
7 |
|
---|
8 | import java.math.BigDecimal;
|
---|
9 | import java.util.Collection;
|
---|
10 | import java.util.List;
|
---|
11 |
|
---|
12 |
|
---|
13 | @Entity
|
---|
14 | public class Account implements UserDetails{
|
---|
15 |
|
---|
16 | @Id
|
---|
17 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
18 | private Long id;
|
---|
19 | private String username;
|
---|
20 | private String email;
|
---|
21 | private String password;
|
---|
22 | private BigDecimal balance;
|
---|
23 |
|
---|
24 | @OneToMany(mappedBy = "account")
|
---|
25 | private List<Transaction> transactions;
|
---|
26 |
|
---|
27 | @Transient
|
---|
28 | private Collection<? extends GrantedAuthority> authorities;
|
---|
29 |
|
---|
30 | public Account() {}
|
---|
31 |
|
---|
32 | public Account(String username, String email, String password, BigDecimal balance, List<Transaction> transactions, Collection<? extends GrantedAuthority> authorities) {
|
---|
33 | this.username = username;
|
---|
34 | this.email = email;
|
---|
35 | this.password = password;
|
---|
36 | this.balance = balance;
|
---|
37 | this.transactions = transactions;
|
---|
38 | this.authorities = authorities;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public Long getId() {
|
---|
42 | return id;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public void setId(Long id) {
|
---|
46 | this.id = id;
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | public String getUsername() {
|
---|
51 | return username;
|
---|
52 | }
|
---|
53 |
|
---|
54 | public void setUsername(String username) {
|
---|
55 | this.username = username;
|
---|
56 | }
|
---|
57 |
|
---|
58 | @Override
|
---|
59 | public String getPassword() {
|
---|
60 | return password;
|
---|
61 | }
|
---|
62 |
|
---|
63 | public void setPassword(String password) {
|
---|
64 | this.password = password;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public BigDecimal getBalance() {
|
---|
68 | return balance;
|
---|
69 | }
|
---|
70 |
|
---|
71 | public void setBalance(BigDecimal balance) {
|
---|
72 | this.balance = balance;
|
---|
73 | }
|
---|
74 |
|
---|
75 | public List<Transaction> getTransactions() {
|
---|
76 | return transactions;
|
---|
77 | }
|
---|
78 |
|
---|
79 | public void setTransactions(List<Transaction> transactions) {
|
---|
80 | this.transactions = transactions;
|
---|
81 | }
|
---|
82 |
|
---|
83 | @Override
|
---|
84 | public Collection<? extends GrantedAuthority> getAuthorities() {
|
---|
85 | return authorities;
|
---|
86 | }
|
---|
87 |
|
---|
88 | public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
|
---|
89 | this.authorities = authorities;
|
---|
90 | }
|
---|
91 |
|
---|
92 | public String getEmail() {
|
---|
93 | return email;
|
---|
94 | }
|
---|
95 |
|
---|
96 | public void setEmail(String email) {
|
---|
97 | this.email = email;
|
---|
98 | }
|
---|
99 | }
|
---|