1 | package com.example.demo.model;
|
---|
2 |
|
---|
3 |
|
---|
4 | import lombok.Data;
|
---|
5 | import org.springframework.security.core.GrantedAuthority;
|
---|
6 | import org.springframework.security.core.userdetails.UserDetails;
|
---|
7 |
|
---|
8 | import javax.persistence.*;
|
---|
9 | import java.util.Collection;
|
---|
10 | import java.util.Collections;
|
---|
11 |
|
---|
12 | @Data
|
---|
13 | @Entity
|
---|
14 | @Table(name="users")
|
---|
15 | public class User implements UserDetails {
|
---|
16 | @Id
|
---|
17 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
18 | private Integer user_id;
|
---|
19 |
|
---|
20 |
|
---|
21 | private String user_username;
|
---|
22 |
|
---|
23 | private String user_password;
|
---|
24 |
|
---|
25 | private String user_phone_number;
|
---|
26 | private String user_name;
|
---|
27 | private String user_surname;
|
---|
28 | private String user_email;
|
---|
29 |
|
---|
30 | @Enumerated(value= EnumType.STRING)
|
---|
31 | public Role user_role;
|
---|
32 |
|
---|
33 | public User(String user_username, String user_password, String user_name, String user_surname) {
|
---|
34 | }
|
---|
35 |
|
---|
36 |
|
---|
37 | public User(String user_username, String user_password, String user_phone_number, String user_name, String user_surname, String user_email, Role user_role) {
|
---|
38 | this.user_username = user_username;
|
---|
39 | this.user_password = user_password;
|
---|
40 | this.user_phone_number = user_phone_number;
|
---|
41 | this.user_name = user_name;
|
---|
42 | this.user_surname = user_surname;
|
---|
43 | this.user_email = user_email;
|
---|
44 | this.user_role = user_role;
|
---|
45 | }
|
---|
46 |
|
---|
47 | public User() {
|
---|
48 |
|
---|
49 | }
|
---|
50 |
|
---|
51 | public Integer getUser_id() {
|
---|
52 | return user_id;
|
---|
53 | }
|
---|
54 |
|
---|
55 | public void setUser_id(Integer user_id) {
|
---|
56 | this.user_id = user_id;
|
---|
57 | }
|
---|
58 |
|
---|
59 | public String getUser_username() {
|
---|
60 | return user_username;
|
---|
61 | }
|
---|
62 |
|
---|
63 | public void setUser_username(String user_username) {
|
---|
64 | this.user_username = user_username;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public String getUser_password() {
|
---|
68 | return user_password;
|
---|
69 | }
|
---|
70 |
|
---|
71 | public void setUser_password(String user_password) {
|
---|
72 | this.user_password = user_password;
|
---|
73 | }
|
---|
74 |
|
---|
75 | public String getUser_phone_number() {
|
---|
76 | return user_phone_number;
|
---|
77 | }
|
---|
78 |
|
---|
79 | public void setUser_phone_number(String user_phone_number) {
|
---|
80 | this.user_phone_number = user_phone_number;
|
---|
81 | }
|
---|
82 |
|
---|
83 | public String getUser_name() {
|
---|
84 | return user_name;
|
---|
85 | }
|
---|
86 |
|
---|
87 | public void setUser_name(String user_name) {
|
---|
88 | this.user_name = user_name;
|
---|
89 | }
|
---|
90 |
|
---|
91 | public String getUser_surname() {
|
---|
92 | return user_surname;
|
---|
93 | }
|
---|
94 |
|
---|
95 | public void setUser_surname(String user_surname) {
|
---|
96 | this.user_surname = user_surname;
|
---|
97 | }
|
---|
98 |
|
---|
99 | public String getUser_email() {
|
---|
100 | return user_email;
|
---|
101 | }
|
---|
102 |
|
---|
103 | public void setUser_email(String user_email) {
|
---|
104 | this.user_email = user_email;
|
---|
105 | }
|
---|
106 |
|
---|
107 | public Role getUser_role() {
|
---|
108 | return user_role;
|
---|
109 | }
|
---|
110 |
|
---|
111 | public void setUser_role(Role role) {
|
---|
112 | this.user_role = role;
|
---|
113 | }
|
---|
114 |
|
---|
115 | @Override
|
---|
116 | public Collection<? extends GrantedAuthority> getAuthorities() {
|
---|
117 | return Collections.singletonList(user_role);
|
---|
118 | }
|
---|
119 |
|
---|
120 | @Override
|
---|
121 | public String getPassword() {
|
---|
122 | return user_password;
|
---|
123 | }
|
---|
124 |
|
---|
125 | @Override
|
---|
126 | public String getUsername() {
|
---|
127 | return user_username;
|
---|
128 | }
|
---|
129 |
|
---|
130 | @Override
|
---|
131 | public boolean isAccountNonExpired() {
|
---|
132 | return false;
|
---|
133 | }
|
---|
134 |
|
---|
135 | @Override
|
---|
136 | public boolean isAccountNonLocked() {
|
---|
137 | return false;
|
---|
138 | }
|
---|
139 |
|
---|
140 | @Override
|
---|
141 | public boolean isCredentialsNonExpired() {
|
---|
142 | return false;
|
---|
143 | }
|
---|
144 |
|
---|
145 | @Override
|
---|
146 | public boolean isEnabled() {
|
---|
147 | return false;
|
---|
148 | }
|
---|
149 | }
|
---|