fixed lk page
This commit is contained in:
parent
ed8855272f
commit
9c53257729
@ -133,8 +133,8 @@ public class UserController extends OdinController<UserListDto, UserDto> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add page for user edit (user-profile)
|
// TODO: add page for user edit (user-profile)
|
||||||
@PostMapping("/change-information")
|
@PostMapping(value = "/change-information", params = "save")
|
||||||
public Response<UserDto> changeInformation(@Valid @RequestBody UserDto userDto) {
|
public Response<UserDto> changeInformation(@Valid UserDto userDto) {
|
||||||
log.debug("REST: UserController.changeInformation( {} )", userDto.getLogin());
|
log.debug("REST: UserController.changeInformation( {} )", userDto.getLogin());
|
||||||
return new Response<>(userService.updateUserInformation(userDto));
|
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 org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
import ru.ulstu.user.model.UserDto;
|
||||||
import ru.ulstu.user.service.UserSessionService;
|
import ru.ulstu.user.service.UserSessionService;
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ public class UserProfileController {
|
|||||||
public void getUserProfile(ModelMap modelMap, HttpServletRequest request) {
|
public void getUserProfile(ModelMap modelMap, HttpServletRequest request) {
|
||||||
HttpSession session = request.getSession(false);
|
HttpSession session = request.getSession(false);
|
||||||
final String sessionId = session.getAttribute(Constants.SESSION_ID_ATTR).toString();
|
final String sessionId = session.getAttribute(Constants.SESSION_ID_ATTR).toString();
|
||||||
User user = userSessionService.getUserBySessionId(sessionId);
|
UserDto userDto = userSessionService.getUserBySessionId(sessionId);
|
||||||
modelMap.addAttribute("user", user);
|
modelMap.addAttribute("userDto", userDto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import ru.ulstu.core.jpa.OffsetablePageRequest;
|
|||||||
import ru.ulstu.core.model.response.PageableItems;
|
import ru.ulstu.core.model.response.PageableItems;
|
||||||
import ru.ulstu.user.error.UserNotFoundException;
|
import ru.ulstu.user.error.UserNotFoundException;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
import ru.ulstu.user.model.UserDto;
|
||||||
import ru.ulstu.user.model.UserSession;
|
import ru.ulstu.user.model.UserSession;
|
||||||
import ru.ulstu.user.model.UserSessionListDto;
|
import ru.ulstu.user.model.UserSessionListDto;
|
||||||
import ru.ulstu.user.repository.UserSessionRepository;
|
import ru.ulstu.user.repository.UserSessionRepository;
|
||||||
@ -24,10 +25,12 @@ public class UserSessionService {
|
|||||||
private final Logger log = LoggerFactory.getLogger(UserSessionService.class);
|
private final Logger log = LoggerFactory.getLogger(UserSessionService.class);
|
||||||
private final UserSessionRepository userSessionRepository;
|
private final UserSessionRepository userSessionRepository;
|
||||||
private final UserService userService;
|
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.userSessionRepository = userSessionRepository;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
|
this.userMapper = userMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@ -57,7 +60,8 @@ public class UserSessionService {
|
|||||||
log.debug("User session {} closed", sessionId);
|
log.debug("User session {} closed", sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUserBySessionId(String sessionId) {
|
public UserDto getUserBySessionId(String sessionId) {
|
||||||
return userSessionRepository.findOneBySessionId(sessionId).getUser();
|
User user = userSessionRepository.findOneBySessionId(sessionId).getUser();
|
||||||
|
return new UserDto(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,15 +15,15 @@
|
|||||||
<hr/>
|
<hr/>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<form id="profile-form" method="post" th:action="@{'/profile/profile'}"
|
<form id="profile-form" method="post" th:action="@{'/api/1.0/users/change-information'}"
|
||||||
th:object="${user}">
|
th:object="${userDto}">
|
||||||
<input type="hidden" name="id" th:field="*{id}"/>
|
<input type="hidden" name="id" th:field="*{id}"/>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="firstName">Имя:</label>
|
<label for="firstName">Имя:</label>
|
||||||
<input class="form-control" id="firstName" type="text"
|
<input class="form-control" id="firstName" type="text"
|
||||||
placeholder="Имя"
|
placeholder="Имя"
|
||||||
th:field="*{firstName}"/>
|
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>
|
class="alert alert-danger">Incorrect firstName</p>
|
||||||
<p class="help-block text-danger"></p>
|
<p class="help-block text-danger"></p>
|
||||||
</div>
|
</div>
|
||||||
@ -32,19 +32,35 @@
|
|||||||
<input class="form-control" id="lastName" type="text"
|
<input class="form-control" id="lastName" type="text"
|
||||||
placeholder="lastName"
|
placeholder="lastName"
|
||||||
th:field="*{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>
|
class="alert alert-danger">Incorrect lastName</p>
|
||||||
<p class="help-block text-danger"></p>
|
<p class="help-block text-danger"></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="patronymic">Отчество:</label>
|
<label for="email">Email:</label>
|
||||||
<input class="form-control" id="patronymic" type="text"
|
<input class="form-control" id="email" type="text"
|
||||||
placeholder="Имя"
|
placeholder="Email"
|
||||||
th:field="*{patronymic}"/>
|
th:field="*{email}"/>
|
||||||
<p th:if="${#fields.hasErrors('patronymic')}" th:errors="*{title}"
|
<p th:if="${#fields.hasErrors('email')}" th:errors="*{email}"
|
||||||
class="alert alert-danger">Incorrect patronymic</p>
|
class="alert alert-danger">Incorrect email</p>
|
||||||
<p class="help-block text-danger"></p>
|
<p class="help-block text-danger"></p>
|
||||||
</div>
|
</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>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user