Chatto/chatto/src/main/java/org/ros/chatto/controller/RegisterController.java

35 lines
1.2 KiB
Java
Raw Normal View History

2019-09-27 06:37:55 +00:00
package org.ros.chatto.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
2019-10-02 16:25:46 +00:00
import org.ros.chatto.dto.UserRegistrationDTO;
2019-09-27 06:37:55 +00:00
import org.ros.chatto.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class RegisterController {
@Autowired
private UserService userService;
@GetMapping("/registration")
public ModelAndView registrationForm()
{
ModelAndView modelAndView = new ModelAndView("registration");
2019-10-02 16:25:46 +00:00
modelAndView.addObject("userDTO",new UserRegistrationDTO());
2019-09-27 06:37:55 +00:00
return modelAndView;
}
@PostMapping("/perform_registration")
2019-10-02 16:25:46 +00:00
public ModelAndView performRegistration(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, @ModelAttribute("userDTO") UserRegistrationDTO userRegistrationDTO)
2019-09-27 06:37:55 +00:00
{
ModelAndView modelAndView = new ModelAndView("user/home");
2019-10-02 16:25:46 +00:00
userService.registerUser(userRegistrationDTO);
2019-09-27 06:37:55 +00:00
return modelAndView;
}
}