From 2149dfd32fddaaa660e23b9fd5e04f268a4234f4 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Sat, 22 Feb 2020 10:20:59 +0400 Subject: [PATCH] save user --- src/main/java/ru/ulstu/user/controller/UserView.java | 7 +++++++ src/main/java/ru/ulstu/user/service/UserService.java | 6 +++++- src/main/resources/META-INF/resources/admin/user.xhtml | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/ru/ulstu/user/controller/UserView.java b/src/main/java/ru/ulstu/user/controller/UserView.java index 4a07346..2a9bf31 100644 --- a/src/main/java/ru/ulstu/user/controller/UserView.java +++ b/src/main/java/ru/ulstu/user/controller/UserView.java @@ -1,5 +1,6 @@ package ru.ulstu.user.controller; +import ru.ulstu.core.navigation.Page; import ru.ulstu.core.util.FacesUtil; import ru.ulstu.user.model.User; import ru.ulstu.user.service.UserService; @@ -36,4 +37,10 @@ public class UserView implements Serializable { public List getDegrees() { return Arrays.asList(User.UserDegree.values()); } + + public String save() { + userService.updateUserInformation(user); + FacesUtil.showInfoMessage("Данные пользователя сохранены", user.getUserAbbreviate()); + return Page.USER_LIST + "?faces-redirect=true"; + } } diff --git a/src/main/java/ru/ulstu/user/service/UserService.java b/src/main/java/ru/ulstu/user/service/UserService.java index 0285ca0..c032332 100644 --- a/src/main/java/ru/ulstu/user/service/UserService.java +++ b/src/main/java/ru/ulstu/user/service/UserService.java @@ -237,12 +237,16 @@ public class UserService implements UserDetailsService { return userMapper.userEntityToUserDto(user); } + public User updateUserInformation(User user) { + return userRepository.save(user); + } + public UserDto updateUserInformation(User user, UserDto updateUser) { user.setFirstName(updateUser.getFirstName()); user.setLastName(updateUser.getLastName()); user.setEmail(updateUser.getEmail()); user.setLogin(updateUser.getLogin()); - user = userRepository.save(user); + user = updateUserInformation(user); log.debug("Updated Information for User: {}", user.getLogin()); return userMapper.userEntityToUserDto(user); } diff --git a/src/main/resources/META-INF/resources/admin/user.xhtml b/src/main/resources/META-INF/resources/admin/user.xhtml index d145ea9..5addc0e 100644 --- a/src/main/resources/META-INF/resources/admin/user.xhtml +++ b/src/main/resources/META-INF/resources/admin/user.xhtml @@ -5,7 +5,7 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> - Редактирование статьи + Редактирование пользователя