add patronymic

This commit is contained in:
Anton Romanov 2019-03-12 14:44:11 +04:00
parent 48894b2176
commit 90bb94d864
4 changed files with 34 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import ru.ulstu.user.error.UserNotActivatedException;
import ru.ulstu.user.error.UserNotFoundException;
import ru.ulstu.user.error.UserPasswordsNotValidOrNotMatchException;
import ru.ulstu.user.error.UserResetKeyError;
import ru.ulstu.user.model.User;
import ru.ulstu.user.service.UserService;
import java.util.Set;
@ -37,10 +38,11 @@ public class AdviceController {
@ModelAttribute("currentUser")
public String getCurrentUser() {
User user = userService.getCurrentUser();
return String.format(USER_NAME_TEMPLATE,
userService.getCurrentUser().getLastName(),
userService.getCurrentUser().getFirstName().substring(0, 1),
userService.getCurrentUser().getFirstName().substring(0, 1));
user.getLastName(),
user.getFirstName().substring(0, 1),
user.getPatronymic().substring(0, 1));
}
private Response<Void> handleException(ErrorConstants error) {

View File

@ -45,6 +45,10 @@ public class User extends BaseEntity {
@Column(name = "last_name", length = 50, nullable = false)
private String lastName;
@Size(max = 50)
@Column(name = "patronymic", length = 50)
private String patronymic;
@NotNull
@Email
@Size(min = 5, max = 100)
@ -174,4 +178,12 @@ public class User extends BaseEntity {
this.roles.clear();
this.roles.addAll(roles);
}
public String getPatronymic() {
return patronymic;
}
public void setPatronymic(String patronymic) {
this.patronymic = patronymic;
}
}

View File

@ -18,4 +18,5 @@
<include file="db/changelog-20181111_000000-schema.xml"/>
<include file="db/changelog-20181208_000000-schema.xml"/>
<include file="db/changelog-20181224_000000-schema.xml"/>
<include file="db/common/changelog-20190312_130000-schema.xml"/>
</databaseChangeLog>

View File

@ -0,0 +1,16 @@
<?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="orion" id="20190312_130000-1">
<addColumn tableName="users">
<column name="patronymic" type="varchar(255)"/>
</addColumn>
</changeSet>
<changeSet author="orion" id="20190312_130000-2">
<sql>
update users
set first_name = 'Антон', patronymic = 'Алексеевич', last_name = 'Романов' where id = 1;
</sql>
</changeSet>
</databaseChangeLog>