diff --git a/src/main/java/ru/ulstu/user/controller/UserController.java b/src/main/java/ru/ulstu/user/controller/UserController.java index 05b5e9c..f88b8fa 100644 --- a/src/main/java/ru/ulstu/user/controller/UserController.java +++ b/src/main/java/ru/ulstu/user/controller/UserController.java @@ -133,8 +133,8 @@ public class UserController extends OdinController { } // TODO: add page for user edit (user-profile) - @PostMapping("/change-information") - public Response changeInformation(@Valid @RequestBody UserDto userDto) { + @PostMapping(value = "/change-information", params = "save") + public Response changeInformation(@Valid UserDto userDto) { log.debug("REST: UserController.changeInformation( {} )", userDto.getLogin()); return new Response<>(userService.updateUserInformation(userDto)); } diff --git a/src/main/java/ru/ulstu/user/controller/UserProfileController.java b/src/main/java/ru/ulstu/user/controller/UserProfileController.java index a5e00c5..db53dec 100644 --- a/src/main/java/ru/ulstu/user/controller/UserProfileController.java +++ b/src/main/java/ru/ulstu/user/controller/UserProfileController.java @@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import ru.ulstu.configuration.Constants; import ru.ulstu.user.model.User; +import ru.ulstu.user.model.UserDto; import ru.ulstu.user.service.UserSessionService; import springfox.documentation.annotations.ApiIgnore; @@ -28,7 +29,7 @@ public class UserProfileController { public void getUserProfile(ModelMap modelMap, HttpServletRequest request) { HttpSession session = request.getSession(false); final String sessionId = session.getAttribute(Constants.SESSION_ID_ATTR).toString(); - User user = userSessionService.getUserBySessionId(sessionId); - modelMap.addAttribute("user", user); + UserDto userDto = userSessionService.getUserBySessionId(sessionId); + modelMap.addAttribute("userDto", userDto); } } diff --git a/src/main/java/ru/ulstu/user/service/UserSessionService.java b/src/main/java/ru/ulstu/user/service/UserSessionService.java index 13b18be..f3130f7 100644 --- a/src/main/java/ru/ulstu/user/service/UserSessionService.java +++ b/src/main/java/ru/ulstu/user/service/UserSessionService.java @@ -10,6 +10,7 @@ import ru.ulstu.core.jpa.OffsetablePageRequest; import ru.ulstu.core.model.response.PageableItems; import ru.ulstu.user.error.UserNotFoundException; import ru.ulstu.user.model.User; +import ru.ulstu.user.model.UserDto; import ru.ulstu.user.model.UserSession; import ru.ulstu.user.model.UserSessionListDto; import ru.ulstu.user.repository.UserSessionRepository; @@ -24,10 +25,12 @@ public class UserSessionService { private final Logger log = LoggerFactory.getLogger(UserSessionService.class); private final UserSessionRepository userSessionRepository; private final UserService userService; + private final UserMapper userMapper; - public UserSessionService(UserSessionRepository userSessionRepository, UserService userService) { + public UserSessionService(UserSessionRepository userSessionRepository, UserService userService, UserMapper userMapper) { this.userSessionRepository = userSessionRepository; this.userService = userService; + this.userMapper = userMapper; } @Transactional(readOnly = true) @@ -57,7 +60,8 @@ public class UserSessionService { log.debug("User session {} closed", sessionId); } - public User getUserBySessionId(String sessionId) { - return userSessionRepository.findOneBySessionId(sessionId).getUser(); + public UserDto getUserBySessionId(String sessionId) { + User user = userSessionRepository.findOneBySessionId(sessionId).getUser(); + return new UserDto(user); } } diff --git a/src/main/resources/templates/profile/profile.html b/src/main/resources/templates/profile/profile.html index b74e3db..eb5eea1 100644 --- a/src/main/resources/templates/profile/profile.html +++ b/src/main/resources/templates/profile/profile.html @@ -15,15 +15,15 @@
-
+
-

Incorrect firstName

@@ -32,19 +32,35 @@ -

Incorrect lastName

- - -

Incorrect patronymic

+ + +

Incorrect email

+
+ + +

Incorrect login

+

+
+
+ +