#42 add columns 'birth_date'&'degree' to User

pull/171/head
T-Midnight 5 years ago
parent 99a8550696
commit 7465803162

@ -7,6 +7,8 @@ import ru.ulstu.core.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
@ -83,6 +85,28 @@ public class User extends BaseEntity {
@BatchSize(size = 20)
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() {
roles = new HashSet<>();
activated = false;
@ -186,4 +210,20 @@ public class User extends BaseEntity {
public void setPatronymic(String 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)
private String passwordConfirm;
@OdinCaption("Год рождения")
@Size(max = 4)
private Integer birthYear;
@OdinCaption("Ученая степень")
private User.UserDegree degree;
public UserDto() {
activated = false;
roles = new LinkedHashSet<>();
@ -86,6 +93,8 @@ public class UserDto implements OdinDto {
this.roles.addAll(user.getRoles().stream()
.map(UserRoleDto::new)
.collect(Collectors.toList()));
this.birthYear = user.getBirthYear();
this.degree = user.getDegree();
}
public Integer getId() {
@ -163,6 +172,22 @@ public class UserDto implements OdinDto {
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
public boolean isPasswordsValid() {
if (StringUtils.isEmpty(password) || StringUtils.isEmpty(passwordConfirm)) {
@ -188,6 +213,8 @@ public class UserDto implements OdinDto {
", roles=" + roles +
", password='" + password + '\'' +
", passwordConfirm='" + passwordConfirm + '\'' +
", birthYear='" + birthYear + '\'' +
", degree='" + degree + '\'' +
'}';
}
}

@ -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…
Cancel
Save