|
@@ -3,6 +3,7 @@ package com.dbs.realworld.controller;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
|
import com.dbs.realworld.common.Views;
|
|
|
import com.dbs.realworld.dto.FollowDTO;
|
|
@@ -48,7 +49,7 @@ public class UserController {
|
|
|
|
|
|
// 회원가입 요청
|
|
|
@PostMapping("/signup")
|
|
|
- public String processSignupForm(HttpServletRequest request, @ModelAttribute("userDTO") UserDTO userDTO, ModelMap model) {
|
|
|
+ public String processSignupForm(HttpServletRequest request, @Valid @ModelAttribute("userDTO") UserDTO userDTO, ModelMap model) {
|
|
|
try {
|
|
|
this.userService.register(userDTO);
|
|
|
} catch (RuntimeException e) {
|
|
@@ -112,7 +113,7 @@ public class UserController {
|
|
|
|
|
|
// 사용자 팔로우
|
|
|
@PostMapping("/follow")
|
|
|
- public ResponseEntity follow(HttpServletRequest request, @RequestBody FollowDTO followDTO) {
|
|
|
+ public ResponseEntity follow(HttpServletRequest request, @RequestBody @Valid FollowDTO followDTO) {
|
|
|
final int userId = (int) request.getSession().getAttribute("ssId");
|
|
|
if (userId != followDTO.getFromUser()) {
|
|
|
return ResponseEntity.status(HttpStatus.FORBIDDEN).body("권한이 없습니다");
|
|
@@ -124,7 +125,7 @@ public class UserController {
|
|
|
|
|
|
// 사용자 언팔로우
|
|
|
@DeleteMapping("/unfollow")
|
|
|
- public ResponseEntity unfollow(HttpServletRequest request, @RequestBody FollowDTO followDTO) {
|
|
|
+ public ResponseEntity unfollow(HttpServletRequest request, @RequestBody @Valid FollowDTO followDTO) {
|
|
|
final int userId = (int) request.getSession().getAttribute("ssId");
|
|
|
if (userId != followDTO.getFromUser()) {
|
|
|
return ResponseEntity.status(HttpStatus.FORBIDDEN).body("권한이 없습니다");
|