|
| 1 | +package com.back.domain.user.controller; |
| 2 | + |
| 3 | +import com.back.domain.user.service.UserService; |
| 4 | +import com.back.domain.user.service.UserAuthService; |
| 5 | +import com.back.global.rsData.RsData; |
| 6 | +import io.swagger.v3.oas.annotations.Operation; |
| 7 | +import jakarta.servlet.http.HttpServletRequest; |
| 8 | +import jakarta.servlet.http.HttpServletResponse; |
| 9 | +import lombok.RequiredArgsConstructor; |
| 10 | +import org.springframework.security.core.annotation.AuthenticationPrincipal; |
| 11 | +import org.springframework.web.bind.annotation.DeleteMapping; |
| 12 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 13 | +import org.springframework.web.bind.annotation.RestController; |
| 14 | + |
| 15 | +@RestController |
| 16 | +@RequestMapping("/me/account") |
| 17 | +@RequiredArgsConstructor |
| 18 | +public class UserAccountController { |
| 19 | + |
| 20 | + private final UserService userService; |
| 21 | + private final UserAuthService userAuthService; |
| 22 | + |
| 23 | + @DeleteMapping |
| 24 | + @Operation(summary = "계정 비활성화(Soft Delete)", description = "DELETE /me/account: 사용자 상태를 DELETED로 전환하고 세션/토큰을 정리합니다.") |
| 25 | + public RsData<Void> deactivate( |
| 26 | + @AuthenticationPrincipal(expression = "id") Long userId, |
| 27 | + HttpServletRequest request, |
| 28 | + HttpServletResponse response |
| 29 | + ) { |
| 30 | + userService.deactivateAccount(userId); |
| 31 | + |
| 32 | + // 현재 세션 쿠키 및 리프레시토큰 제거 |
| 33 | + userAuthService.logout(request, response); |
| 34 | + |
| 35 | + return RsData.of(200, "계정 비활성화(탈퇴)가 완료되었습니다."); |
| 36 | + } |
| 37 | +} |
0 commit comments