save user
This commit is contained in:
parent
34c5e79cbb
commit
2149dfd32f
@ -1,5 +1,6 @@
|
|||||||
package ru.ulstu.user.controller;
|
package ru.ulstu.user.controller;
|
||||||
|
|
||||||
|
import ru.ulstu.core.navigation.Page;
|
||||||
import ru.ulstu.core.util.FacesUtil;
|
import ru.ulstu.core.util.FacesUtil;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.service.UserService;
|
||||||
@ -36,4 +37,10 @@ public class UserView implements Serializable {
|
|||||||
public List<User.UserDegree> getDegrees() {
|
public List<User.UserDegree> getDegrees() {
|
||||||
return Arrays.asList(User.UserDegree.values());
|
return Arrays.asList(User.UserDegree.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String save() {
|
||||||
|
userService.updateUserInformation(user);
|
||||||
|
FacesUtil.showInfoMessage("Данные пользователя сохранены", user.getUserAbbreviate());
|
||||||
|
return Page.USER_LIST + "?faces-redirect=true";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,12 +237,16 @@ public class UserService implements UserDetailsService {
|
|||||||
return userMapper.userEntityToUserDto(user);
|
return userMapper.userEntityToUserDto(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public User updateUserInformation(User user) {
|
||||||
|
return userRepository.save(user);
|
||||||
|
}
|
||||||
|
|
||||||
public UserDto updateUserInformation(User user, UserDto updateUser) {
|
public UserDto updateUserInformation(User user, UserDto updateUser) {
|
||||||
user.setFirstName(updateUser.getFirstName());
|
user.setFirstName(updateUser.getFirstName());
|
||||||
user.setLastName(updateUser.getLastName());
|
user.setLastName(updateUser.getLastName());
|
||||||
user.setEmail(updateUser.getEmail());
|
user.setEmail(updateUser.getEmail());
|
||||||
user.setLogin(updateUser.getLogin());
|
user.setLogin(updateUser.getLogin());
|
||||||
user = userRepository.save(user);
|
user = updateUserInformation(user);
|
||||||
log.debug("Updated Information for User: {}", user.getLogin());
|
log.debug("Updated Information for User: {}", user.getLogin());
|
||||||
return userMapper.userEntityToUserDto(user);
|
return userMapper.userEntityToUserDto(user);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
|
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
|
||||||
<ui:composition template="/basicTemplate.xhtml">
|
<ui:composition template="/basicTemplate.xhtml">
|
||||||
<ui:define name="header">
|
<ui:define name="header">
|
||||||
Редактирование статьи
|
Редактирование пользователя
|
||||||
</ui:define>
|
</ui:define>
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
<style>
|
<style>
|
||||||
@ -94,7 +94,7 @@
|
|||||||
</p:row>
|
</p:row>
|
||||||
<p:row>
|
<p:row>
|
||||||
<p:column>
|
<p:column>
|
||||||
<p:commandButton action="#{paperView.save}" value="Сохранить" ajax="true" process="@form"
|
<p:commandButton action="#{userView.save}" value="Сохранить" ajax="true" process="@form"
|
||||||
update="messages @form"/>
|
update="messages @form"/>
|
||||||
</p:column>
|
</p:column>
|
||||||
</p:row>
|
</p:row>
|
||||||
|
Loading…
Reference in New Issue
Block a user