#42 add columns 'birth_date'&'degree' to User
This commit is contained in:
parent
99a8550696
commit
7465803162
@ -7,6 +7,8 @@ import ru.ulstu.core.model.BaseEntity;
|
|||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
@ -83,6 +85,28 @@ public class User extends BaseEntity {
|
|||||||
@BatchSize(size = 20)
|
@BatchSize(size = 20)
|
||||||
private Set<UserRole> roles;
|
private Set<UserRole> roles;
|
||||||
|
|
||||||
|
@Size(max = 4)
|
||||||
|
@Column(name = "birth_year", length = 4)
|
||||||
|
private Integer birthYear;
|
||||||
|
|
||||||
|
public enum UserDegree {
|
||||||
|
CANDIDATE("Кандидат технических наук"),
|
||||||
|
DOCTOR("Доктор технических наук");
|
||||||
|
|
||||||
|
private String degreeName;
|
||||||
|
|
||||||
|
UserDegree(String degreeName) {
|
||||||
|
this.degreeName = degreeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDegreeName() {
|
||||||
|
return degreeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
private UserDegree degree;
|
||||||
|
|
||||||
public User() {
|
public User() {
|
||||||
roles = new HashSet<>();
|
roles = new HashSet<>();
|
||||||
activated = false;
|
activated = false;
|
||||||
@ -186,4 +210,20 @@ public class User extends BaseEntity {
|
|||||||
public void setPatronymic(String patronymic) {
|
public void setPatronymic(String patronymic) {
|
||||||
this.patronymic = patronymic;
|
this.patronymic = patronymic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getBirthYear() {
|
||||||
|
return birthYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBirthYear(Integer birthYear) {
|
||||||
|
this.birthYear = birthYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserDegree getDegree() {
|
||||||
|
return degree;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDegree(UserDegree degree) {
|
||||||
|
this.degree = degree;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,13 @@ public class UserDto implements OdinDto {
|
|||||||
@Size(min = Constants.MIN_PASSWORD_LENGTH, max = 50)
|
@Size(min = Constants.MIN_PASSWORD_LENGTH, max = 50)
|
||||||
private String passwordConfirm;
|
private String passwordConfirm;
|
||||||
|
|
||||||
|
@OdinCaption("Год рождения")
|
||||||
|
@Size(max = 4)
|
||||||
|
private Integer birthYear;
|
||||||
|
|
||||||
|
@OdinCaption("Ученая степень")
|
||||||
|
private User.UserDegree degree;
|
||||||
|
|
||||||
public UserDto() {
|
public UserDto() {
|
||||||
activated = false;
|
activated = false;
|
||||||
roles = new LinkedHashSet<>();
|
roles = new LinkedHashSet<>();
|
||||||
@ -86,6 +93,8 @@ public class UserDto implements OdinDto {
|
|||||||
this.roles.addAll(user.getRoles().stream()
|
this.roles.addAll(user.getRoles().stream()
|
||||||
.map(UserRoleDto::new)
|
.map(UserRoleDto::new)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
this.birthYear = user.getBirthYear();
|
||||||
|
this.degree = user.getDegree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
@ -163,6 +172,22 @@ public class UserDto implements OdinDto {
|
|||||||
return passwordConfirm;
|
return passwordConfirm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getBirthYear() {
|
||||||
|
return birthYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBirthYear(Integer birthYear) {
|
||||||
|
this.birthYear = birthYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User.UserDegree getDegree() {
|
||||||
|
return degree;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDegree(User.UserDegree degree) {
|
||||||
|
this.degree = degree;
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public boolean isPasswordsValid() {
|
public boolean isPasswordsValid() {
|
||||||
if (StringUtils.isEmpty(password) || StringUtils.isEmpty(passwordConfirm)) {
|
if (StringUtils.isEmpty(password) || StringUtils.isEmpty(passwordConfirm)) {
|
||||||
@ -188,6 +213,8 @@ public class UserDto implements OdinDto {
|
|||||||
", roles=" + roles +
|
", roles=" + roles +
|
||||||
", password='" + password + '\'' +
|
", password='" + password + '\'' +
|
||||||
", passwordConfirm='" + passwordConfirm + '\'' +
|
", passwordConfirm='" + passwordConfirm + '\'' +
|
||||||
|
", birthYear='" + birthYear + '\'' +
|
||||||
|
", degree='" + degree + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
src/main/resources/db/changelog-20190404_000000-schema.xml
Normal file
13
src/main/resources/db/changelog-20190404_000000-schema.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="tanya" id="20190404_000000-1">
|
||||||
|
<addColumn tableName="users">
|
||||||
|
<column name="birth_year" type="integer"></column>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="users">
|
||||||
|
<column name="degree" type="varchar(255)"></column>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
Loading…
Reference in New Issue
Block a user