|
@@ -16,6 +16,8 @@ import org.springframework.ui.ModelMap;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
+import org.springframework.web.bind.annotation.PatchMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
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.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -106,6 +108,7 @@ public class UserController {
|
|
return "redirect:/";
|
|
return "redirect:/";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
// 사용자 팔로우
|
|
// 사용자 팔로우
|
|
@PostMapping("/follow")
|
|
@PostMapping("/follow")
|
|
public ResponseEntity follow(HttpServletRequest request, @RequestBody FollowDTO followDTO) {
|
|
public ResponseEntity follow(HttpServletRequest request, @RequestBody FollowDTO followDTO) {
|
|
@@ -117,6 +120,7 @@ public class UserController {
|
|
return ResponseEntity.status(HttpStatus.CREATED).build();
|
|
return ResponseEntity.status(HttpStatus.CREATED).build();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
// 사용자 언팔로우
|
|
// 사용자 언팔로우
|
|
@DeleteMapping("/unfollow")
|
|
@DeleteMapping("/unfollow")
|
|
public ResponseEntity unfollow(HttpServletRequest request, @RequestBody FollowDTO followDTO) {
|
|
public ResponseEntity unfollow(HttpServletRequest request, @RequestBody FollowDTO followDTO) {
|
|
@@ -127,4 +131,44 @@ public class UserController {
|
|
this.userService.unfollow(followDTO);
|
|
this.userService.unfollow(followDTO);
|
|
return ResponseEntity.ok().build();
|
|
return ResponseEntity.ok().build();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 사용자 프로필 페이지
|
|
|
|
+ @GetMapping("/settings/{userId}")
|
|
|
|
+ public String initUserSettingForm(HttpServletRequest request, ModelMap model) {
|
|
|
|
+ String email = (String) request.getSession().getAttribute("ssEmail");
|
|
|
|
+ UserDTO userDTO = this.userMapper.selectUserByEmail(email);
|
|
|
|
+ userDTO.setPassword("");
|
|
|
|
+ model.addAttribute("user", userDTO);
|
|
|
|
+ return Views.USER_SETTING_FORM;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 사용자 프로필 업데이트 API
|
|
|
|
+ @PatchMapping("/settings/{userId}")
|
|
|
|
+ public ResponseEntity updateUserSetting(HttpServletRequest request, @PathVariable("userId") int userId, @RequestBody UserDTO userDTO, ModelMap model) {
|
|
|
|
+ userDTO.setId(userId);
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 변경하려는 사용자의 이메일이 중복되지는 않는지? 체크해야 함
|
|
|
|
+ */
|
|
|
|
+ // UserDTO findedByEmail = this.userMapper.selectUserByEmail(userDTO.getEmail());
|
|
|
|
+ // if (findedByEmail != null && userId != findedByEmail.getId()) {
|
|
|
|
+ // 변경하려는 이메일이 이미 있는 경우 처리
|
|
|
|
+ // TODO 이메일이 중복되었다고 알려줘야 함
|
|
|
|
+ // return Views.USER_SETTING_FORM;
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ this.userService.update(userDTO);
|
|
|
|
+
|
|
|
|
+ HttpSession session = request.getSession();
|
|
|
|
+ if (userDTO.getEmail() != null) {
|
|
|
|
+ session.setAttribute("ssEmail", userDTO.getEmail());
|
|
|
|
+ }
|
|
|
|
+ if (userDTO.getUsername() != null) {
|
|
|
|
+ session.setAttribute("ssUsername", userDTO.getUsername());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ResponseEntity.ok().build();
|
|
|
|
+ }
|
|
}
|
|
}
|