Merge branch 'lk' into gl_88
This commit is contained in:
commit
9abcf7792e
@ -133,8 +133,8 @@ public class UserController extends OdinController<UserListDto, UserDto> {
|
||||
}
|
||||
|
||||
// TODO: add page for user edit (user-profile)
|
||||
@PostMapping("/change-information")
|
||||
public Response<UserDto> changeInformation(@Valid @RequestBody UserDto userDto) {
|
||||
@PostMapping(value = "/change-information", params = "save")
|
||||
public Response<UserDto> changeInformation(@Valid UserDto userDto) {
|
||||
log.debug("REST: UserController.changeInformation( {} )", userDto.getLogin());
|
||||
return new Response<>(userService.updateUserInformation(userDto));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -15,15 +15,15 @@
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<form id="profile-form" method="post" th:action="@{'/profile/profile'}"
|
||||
th:object="${user}">
|
||||
<form id="profile-form" method="post" th:action="@{'/api/1.0/users/change-information'}"
|
||||
th:object="${userDto}">
|
||||
<input type="hidden" name="id" th:field="*{id}"/>
|
||||
<div class="form-group">
|
||||
<label for="firstName">Имя:</label>
|
||||
<input class="form-control" id="firstName" type="text"
|
||||
placeholder="Имя"
|
||||
th:field="*{firstName}"/>
|
||||
<p th:if="${#fields.hasErrors('firstName')}" th:errors="*{title}"
|
||||
<p th:if="${#fields.hasErrors('firstName')}" th:errors="*{firstName}"
|
||||
class="alert alert-danger">Incorrect firstName</p>
|
||||
<p class="help-block text-danger"></p>
|
||||
</div>
|
||||
@ -32,19 +32,35 @@
|
||||
<input class="form-control" id="lastName" type="text"
|
||||
placeholder="lastName"
|
||||
th:field="*{lastName}"/>
|
||||
<p th:if="${#fields.hasErrors('lastName')}" th:errors="*{title}"
|
||||
<p th:if="${#fields.hasErrors('lastName')}" th:errors="*{lastName}"
|
||||
class="alert alert-danger">Incorrect lastName</p>
|
||||
<p class="help-block text-danger"></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="patronymic">Отчество:</label>
|
||||
<input class="form-control" id="patronymic" type="text"
|
||||
placeholder="Имя"
|
||||
th:field="*{patronymic}"/>
|
||||
<p th:if="${#fields.hasErrors('patronymic')}" th:errors="*{title}"
|
||||
class="alert alert-danger">Incorrect patronymic</p>
|
||||
<label for="email">Email:</label>
|
||||
<input class="form-control" id="email" type="text"
|
||||
placeholder="Email"
|
||||
th:field="*{email}"/>
|
||||
<p th:if="${#fields.hasErrors('email')}" th:errors="*{email}"
|
||||
class="alert alert-danger">Incorrect email</p>
|
||||
<p class="help-block text-danger"></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="login">login:</label>
|
||||
<input class="form-control" id="login" type="text"
|
||||
placeholder="login"
|
||||
th:field="*{login}"/>
|
||||
<p th:if="${#fields.hasErrors('login')}" th:errors="*{login}"
|
||||
class="alert alert-danger">Incorrect login</p>
|
||||
<p class="help-block text-danger"></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button id="sendMessageButton" name="save"
|
||||
class="btn btn-success text-uppercase"
|
||||
type="submit">
|
||||
Сохранить
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user