From 90bb94d86402006e14f835fac1fd781bf90f20af Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 12 Mar 2019 14:44:11 +0400 Subject: [PATCH] add patronymic --- .../ulstu/core/controller/AdviceController.java | 8 +++++--- src/main/java/ru/ulstu/user/model/User.java | 12 ++++++++++++ src/main/resources/db/changelog-master.xml | 1 + .../common/changelog-20190312_130000-schema.xml | 16 ++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/db/common/changelog-20190312_130000-schema.xml diff --git a/src/main/java/ru/ulstu/core/controller/AdviceController.java b/src/main/java/ru/ulstu/core/controller/AdviceController.java index 8fadd03..1c71df1 100644 --- a/src/main/java/ru/ulstu/core/controller/AdviceController.java +++ b/src/main/java/ru/ulstu/core/controller/AdviceController.java @@ -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 handleException(ErrorConstants error) { diff --git a/src/main/java/ru/ulstu/user/model/User.java b/src/main/java/ru/ulstu/user/model/User.java index 16a873b..de9f028 100644 --- a/src/main/java/ru/ulstu/user/model/User.java +++ b/src/main/java/ru/ulstu/user/model/User.java @@ -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; + } } diff --git a/src/main/resources/db/changelog-master.xml b/src/main/resources/db/changelog-master.xml index c07b1df..b8654ae 100644 --- a/src/main/resources/db/changelog-master.xml +++ b/src/main/resources/db/changelog-master.xml @@ -18,4 +18,5 @@ + \ No newline at end of file diff --git a/src/main/resources/db/common/changelog-20190312_130000-schema.xml b/src/main/resources/db/common/changelog-20190312_130000-schema.xml new file mode 100644 index 0000000..4078ccb --- /dev/null +++ b/src/main/resources/db/common/changelog-20190312_130000-schema.xml @@ -0,0 +1,16 @@ + + + + + + + + + + update users + set first_name = 'Антон', patronymic = 'Алексеевич', last_name = 'Романов' where id = 1; + + + \ No newline at end of file