| 21545 |
ashik.ali |
1 |
package com.spice.profitmandi.dao.entity;
|
|
|
2 |
|
|
|
3 |
import java.io.Serializable;
|
|
|
4 |
import java.time.LocalDateTime;
|
|
|
5 |
import java.util.Set;
|
|
|
6 |
|
|
|
7 |
import javax.persistence.Column;
|
|
|
8 |
import javax.persistence.Entity;
|
|
|
9 |
import javax.persistence.FetchType;
|
|
|
10 |
import javax.persistence.GeneratedValue;
|
|
|
11 |
import javax.persistence.GenerationType;
|
|
|
12 |
import javax.persistence.Id;
|
|
|
13 |
import javax.persistence.JoinColumn;
|
|
|
14 |
import javax.persistence.JoinTable;
|
|
|
15 |
import javax.persistence.NamedQueries;
|
|
|
16 |
import javax.persistence.NamedQuery;
|
|
|
17 |
import javax.persistence.OneToMany;
|
|
|
18 |
import javax.persistence.Table;
|
|
|
19 |
import javax.persistence.UniqueConstraint;
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* This is used to store information of end user.
|
|
|
24 |
* @author ashikali
|
|
|
25 |
*
|
|
|
26 |
*/
|
|
|
27 |
@Entity
|
|
|
28 |
@Table(name="users", schema = "dtr",uniqueConstraints = {@UniqueConstraint(columnNames = {"email","mobile_number"})})
|
|
|
29 |
@NamedQueries({
|
|
|
30 |
@NamedQuery(name = "User.selectCount", query = "select count(u) from User u"),
|
|
|
31 |
@NamedQuery(name = "User.selectAll",query="select u from User u"),
|
|
|
32 |
@NamedQuery(name = "User.selectById",query="select u from User u where u.id= :id"),
|
|
|
33 |
@NamedQuery(name = "User.selectByEmailId", query = "select u from User u where u.emailId= :emailId"),
|
|
|
34 |
@NamedQuery(name = "User.selectByMobileNumber", query = "select u from User u where u.mobileNumber= :mobileNumber"),
|
|
|
35 |
@NamedQuery(name = "User.countByEmailId", query = "select count(u) from User u where u.emailId= :emailId"),
|
|
|
36 |
@NamedQuery(name = "User.countByMobileNumber", query = "select count(u) from User u where u.mobileNumber= :mobileNumber"),
|
|
|
37 |
@NamedQuery(name = "User.selectIdAndSololicUserId", query = "select u.id, ua.account_key, u.createTimestamp, u.updateTimestamp from User u join UserAccounts ua on u.id = ua.user_id where ua.account_type = 'saholic'")
|
|
|
38 |
})
|
|
|
39 |
public class User implements Serializable{
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
private static final long serialVersionUID = 1L;
|
|
|
43 |
|
|
|
44 |
public User(){
|
|
|
45 |
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
@Id
|
|
|
49 |
@Column(name="id",updatable=false, unique=true)
|
|
|
50 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
51 |
private int id;
|
|
|
52 |
|
|
|
53 |
@Column(name = "first_name", length = 64, nullable = false)
|
|
|
54 |
private String firstName;
|
|
|
55 |
|
|
|
56 |
@Column(name = "last_name", length = 64, nullable = false)
|
|
|
57 |
private String lastName;
|
|
|
58 |
|
|
|
59 |
@Column(length=25,name="email",unique=true)
|
|
|
60 |
private String emailId;
|
|
|
61 |
|
|
|
62 |
@Column(length = 10, name = "mobile_number")
|
|
|
63 |
private String mobileNumber;
|
|
|
64 |
|
|
|
65 |
@Column(name = "city", length = 128)
|
|
|
66 |
private String city;
|
|
|
67 |
|
|
|
68 |
@Column(name = "pincode", length = 6)
|
|
|
69 |
private Integer pinCode;
|
|
|
70 |
|
|
|
71 |
@Column(name="created",updatable=false)
|
|
|
72 |
private LocalDateTime createTimestamp;
|
|
|
73 |
|
|
|
74 |
@Column(name="modified")
|
|
|
75 |
private LocalDateTime updateTimestamp;
|
|
|
76 |
|
|
|
77 |
private String username;
|
|
|
78 |
private String password;
|
|
|
79 |
private boolean mobile_verified;
|
|
|
80 |
private String referral_url;
|
|
|
81 |
private String referrer;
|
|
|
82 |
|
|
|
83 |
private int group_id;
|
|
|
84 |
@Column(columnDefinition="tinyint(1) default 0")
|
|
|
85 |
private int status;
|
|
|
86 |
@Column(columnDefinition="tinyint(1) default 0")
|
|
|
87 |
private boolean activated;
|
|
|
88 |
|
|
|
89 |
@OneToMany(fetch = FetchType.EAGER)
|
|
|
90 |
@JoinTable(
|
|
|
91 |
name="user_role",
|
|
|
92 |
joinColumns = @JoinColumn( name="user_id"),
|
|
|
93 |
inverseJoinColumns = @JoinColumn( name="role_id"), schema = "dtr"
|
|
|
94 |
)
|
|
|
95 |
private Set<Role> roles;
|
|
|
96 |
|
|
|
97 |
public int getId() {
|
|
|
98 |
return id;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
public void setId(int id) {
|
|
|
102 |
this.id = id;
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
public String getFirstName() {
|
|
|
106 |
return firstName;
|
|
|
107 |
}
|
|
|
108 |
public void setFirstName(String firstName) {
|
|
|
109 |
this.firstName = firstName;
|
|
|
110 |
}
|
|
|
111 |
public String getLastName() {
|
|
|
112 |
return lastName;
|
|
|
113 |
}
|
|
|
114 |
public void setLastName(String lastName) {
|
|
|
115 |
this.lastName = lastName;
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
public String getEmailId() {
|
|
|
119 |
return emailId;
|
|
|
120 |
}
|
|
|
121 |
public void setEmailId(String emailId) {
|
|
|
122 |
this.emailId = emailId;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
public String getMobileNumber() {
|
|
|
127 |
return mobileNumber;
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
public void setMobileNumber(String mobileNumber) {
|
|
|
131 |
this.mobileNumber = mobileNumber;
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
public String getCity() {
|
|
|
135 |
return city;
|
|
|
136 |
}
|
|
|
137 |
public void setCity(String city) {
|
|
|
138 |
this.city = city;
|
|
|
139 |
}
|
|
|
140 |
public Integer getPinCode() {
|
|
|
141 |
return pinCode;
|
|
|
142 |
}
|
|
|
143 |
public void setPinCode(Integer pinCode) {
|
|
|
144 |
this.pinCode = pinCode;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
public LocalDateTime getCreateTimestamp() {
|
|
|
148 |
return createTimestamp;
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
public void setCreateTimestamp(LocalDateTime createTimestamp) {
|
|
|
152 |
this.createTimestamp = createTimestamp;
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
public LocalDateTime getUpdateTimestamp() {
|
|
|
156 |
return updateTimestamp;
|
|
|
157 |
}
|
|
|
158 |
public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
|
|
|
159 |
this.updateTimestamp = updateTimestamp;
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
public Set<Role> getRoles() {
|
|
|
163 |
return roles;
|
|
|
164 |
}
|
|
|
165 |
public void addRole(Role role){
|
|
|
166 |
roles.add(role);
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
public String getUsername() {
|
|
|
170 |
return username;
|
|
|
171 |
}
|
|
|
172 |
|
|
|
173 |
public void setUsername(String username) {
|
|
|
174 |
this.username = username;
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
public String getPassword() {
|
|
|
178 |
return password;
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
public void setPassword(String password) {
|
|
|
182 |
this.password = password;
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
public boolean isMobile_verified() {
|
|
|
186 |
return mobile_verified;
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
public void setMobile_verified(boolean mobile_verified) {
|
|
|
190 |
this.mobile_verified = mobile_verified;
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
public String getReferral_url() {
|
|
|
194 |
return referral_url;
|
|
|
195 |
}
|
|
|
196 |
|
|
|
197 |
public void setReferral_url(String referral_url) {
|
|
|
198 |
this.referral_url = referral_url;
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
public int getGroup_id() {
|
|
|
202 |
return group_id;
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
public void setGroup_id(int group_id) {
|
|
|
206 |
this.group_id = group_id;
|
|
|
207 |
}
|
|
|
208 |
|
|
|
209 |
public String getReferrer() {
|
|
|
210 |
return referrer;
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
public void setReferrer(String referrer) {
|
|
|
214 |
this.referrer = referrer;
|
|
|
215 |
}
|
|
|
216 |
|
|
|
217 |
public int isStatus() {
|
|
|
218 |
return status;
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
public void setStatus(int status) {
|
|
|
222 |
this.status = status;
|
|
|
223 |
}
|
|
|
224 |
|
|
|
225 |
public boolean isActivated() {
|
|
|
226 |
return activated;
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
public void setActivated(boolean activated) {
|
|
|
230 |
this.activated = activated;
|
|
|
231 |
}
|
|
|
232 |
|
|
|
233 |
@Override
|
|
|
234 |
public String toString() {
|
|
|
235 |
return "User [id=" + id + ", emailId=" + emailId + ", createTimestamp=" + createTimestamp + ", mobileNumber="
|
|
|
236 |
+ mobileNumber + "]";
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
@Override
|
|
|
240 |
public int hashCode() {
|
|
|
241 |
final int prime = 31;
|
|
|
242 |
int result = 1;
|
|
|
243 |
result = prime * result + ((city == null) ? 0 : city.hashCode());
|
|
|
244 |
result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
|
|
|
245 |
result = prime * result + ((emailId == null) ? 0 : emailId.hashCode());
|
|
|
246 |
result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
|
|
|
247 |
result = prime * result + (int) (id ^ (id >>> 32));
|
|
|
248 |
result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
|
|
|
249 |
result = prime * result + ((mobileNumber == null) ? 0 : mobileNumber.hashCode());
|
|
|
250 |
result = prime * result + ((pinCode == null) ? 0 : pinCode.hashCode());
|
|
|
251 |
result = prime * result + ((roles == null) ? 0 : roles.hashCode());
|
|
|
252 |
result = prime * result + ((updateTimestamp == null) ? 0 : updateTimestamp.hashCode());
|
|
|
253 |
return result;
|
|
|
254 |
}
|
|
|
255 |
|
|
|
256 |
@Override
|
|
|
257 |
public boolean equals(Object obj) {
|
|
|
258 |
if (this == obj)
|
|
|
259 |
return true;
|
|
|
260 |
if (obj == null)
|
|
|
261 |
return false;
|
|
|
262 |
if (getClass() != obj.getClass())
|
|
|
263 |
return false;
|
|
|
264 |
User other = (User) obj;
|
|
|
265 |
if (city == null) {
|
|
|
266 |
if (other.city != null)
|
|
|
267 |
return false;
|
|
|
268 |
} else if (!city.equals(other.city))
|
|
|
269 |
return false;
|
|
|
270 |
if (createTimestamp == null) {
|
|
|
271 |
if (other.createTimestamp != null)
|
|
|
272 |
return false;
|
|
|
273 |
} else if (!createTimestamp.equals(other.createTimestamp))
|
|
|
274 |
return false;
|
|
|
275 |
if (emailId == null) {
|
|
|
276 |
if (other.emailId != null)
|
|
|
277 |
return false;
|
|
|
278 |
} else if (!emailId.equals(other.emailId))
|
|
|
279 |
return false;
|
|
|
280 |
if (firstName == null) {
|
|
|
281 |
if (other.firstName != null)
|
|
|
282 |
return false;
|
|
|
283 |
} else if (!firstName.equals(other.firstName))
|
|
|
284 |
return false;
|
|
|
285 |
if (id != other.id)
|
|
|
286 |
return false;
|
|
|
287 |
if (lastName == null) {
|
|
|
288 |
if (other.lastName != null)
|
|
|
289 |
return false;
|
|
|
290 |
} else if (!lastName.equals(other.lastName))
|
|
|
291 |
return false;
|
|
|
292 |
if (mobileNumber == null) {
|
|
|
293 |
if (other.mobileNumber != null)
|
|
|
294 |
return false;
|
|
|
295 |
} else if (!mobileNumber.equals(other.mobileNumber))
|
|
|
296 |
return false;
|
|
|
297 |
if (pinCode == null) {
|
|
|
298 |
if (other.pinCode != null)
|
|
|
299 |
return false;
|
|
|
300 |
} else if (!pinCode.equals(other.pinCode))
|
|
|
301 |
return false;
|
|
|
302 |
if (roles == null) {
|
|
|
303 |
if (other.roles != null)
|
|
|
304 |
return false;
|
|
|
305 |
} else if (!roles.equals(other.roles))
|
|
|
306 |
return false;
|
|
|
307 |
if (updateTimestamp == null) {
|
|
|
308 |
if (other.updateTimestamp != null)
|
|
|
309 |
return false;
|
|
|
310 |
} else if (!updateTimestamp.equals(other.updateTimestamp))
|
|
|
311 |
return false;
|
|
|
312 |
return true;
|
|
|
313 |
}
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
}
|