|
|
@ -3,14 +3,15 @@ package ru.ulstu.user.controller;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import ru.ulstu.configuration.Constants;
|
|
|
|
import ru.ulstu.configuration.Constants;
|
|
|
|
import ru.ulstu.odin.controller.OdinController;
|
|
|
|
import ru.ulstu.odin.controller.OdinController;
|
|
|
|
import ru.ulstu.user.error.UserSendingMailException;
|
|
|
|
|
|
|
|
import ru.ulstu.user.model.UserDto;
|
|
|
|
import ru.ulstu.user.model.UserDto;
|
|
|
|
import ru.ulstu.user.model.User;
|
|
|
|
import ru.ulstu.user.model.User;
|
|
|
|
import ru.ulstu.user.model.UserListDto;
|
|
|
|
import ru.ulstu.user.model.UserListDto;
|
|
|
@ -22,20 +23,26 @@ import javax.servlet.http.HttpSession;
|
|
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
@Controller
|
|
|
|
@RequestMapping(value = "/users")
|
|
|
|
@RequestMapping(value = "/users")
|
|
|
|
public class UserControllerV2 extends OdinController<UserListDto, UserDto> {
|
|
|
|
public class UserMvcController extends OdinController<UserListDto, UserDto> {
|
|
|
|
|
|
|
|
|
|
|
|
private final Logger log = LoggerFactory.getLogger(UserControllerV2.class);
|
|
|
|
private final Logger log = LoggerFactory.getLogger(UserMvcController.class);
|
|
|
|
|
|
|
|
|
|
|
|
private final UserService userService;
|
|
|
|
private final UserService userService;
|
|
|
|
private final UserSessionService userSessionService;
|
|
|
|
private final UserSessionService userSessionService;
|
|
|
|
|
|
|
|
|
|
|
|
public UserControllerV2(UserService userService,
|
|
|
|
public UserMvcController(UserService userService,
|
|
|
|
UserSessionService userSessionService) {
|
|
|
|
UserSessionService userSessionService) {
|
|
|
|
super(UserListDto.class, UserDto.class);
|
|
|
|
super(UserListDto.class, UserDto.class);
|
|
|
|
this.userService = userService;
|
|
|
|
this.userService = userService;
|
|
|
|
this.userSessionService = userSessionService;
|
|
|
|
this.userSessionService = userSessionService;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ExceptionHandler(Exception.class)
|
|
|
|
|
|
|
|
public String errorHandler(Model model, Exception exception) {
|
|
|
|
|
|
|
|
model.addAttribute("error", exception.getMessage());
|
|
|
|
|
|
|
|
return "/error/error";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/profile")
|
|
|
|
@GetMapping("/profile")
|
|
|
|
public void getUserProfile(ModelMap modelMap, HttpServletRequest request) {
|
|
|
|
public void getUserProfile(ModelMap modelMap, HttpServletRequest request) {
|
|
|
|
HttpSession session = request.getSession(false);
|
|
|
|
HttpSession session = request.getSession(false);
|
|
|
@ -52,7 +59,7 @@ public class UserControllerV2 extends OdinController<UserListDto, UserDto> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/invite")
|
|
|
|
@PostMapping("/invite")
|
|
|
|
public String inviteUser(@RequestParam(value = "email") String email) throws UserSendingMailException {
|
|
|
|
public String inviteUser(@RequestParam(value = "email") String email, ModelMap modelMap) {
|
|
|
|
userService.inviteUser(email);
|
|
|
|
userService.inviteUser(email);
|
|
|
|
return "redirect:/";
|
|
|
|
return "redirect:/";
|
|
|
|
}
|
|
|
|
}
|