forked from NeilAlishev/SpringCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.java
More file actions
92 lines (73 loc) · 2.14 KB
/
Person.java
File metadata and controls
92 lines (73 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package ru.alishev.springcourse.FirstSecurityApp.models;
import javax.persistence.*;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
/**
* @author Neil Alishev
*/
@Entity
@Table(name = "Person")
public class Person {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@NotEmpty(message = "Имя не должно быть пустым")
@Size(min = 2, max = 100, message = "Имя должно быть от 2 до 100 символов длиной")
@Column(name = "username")
private String username;
@Min(value = 1900, message = "Год рождения должен быть больше, чем 1900")
@Column(name = "year_of_birth")
private int yearOfBirth;
@Column(name = "password")
private String password;
@Column(name = "role")
private String role;
// Конструктор по умолчанию нужен для Spring
public Person() {
}
public Person(String username, int yearOfBirth) {
this.username = username;
this.yearOfBirth = yearOfBirth;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getYearOfBirth() {
return yearOfBirth;
}
public void setYearOfBirth(int yearOfBirth) {
this.yearOfBirth = yearOfBirth;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
@Override
public String toString() {
return "Person{" +
"id=" + id +
", username='" + username + '\'' +
", yearOfBirth=" + yearOfBirth +
", password='" + password + '\'' +
'}';
}
}