Skip to content

Commit

Permalink
✨Feat: 회원 탈퇴 API
Browse files Browse the repository at this point in the history
  • Loading branch information
jiinkyung committed Feb 21, 2024
1 parent 18c7123 commit 760cc3f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,12 @@ public ApiResponse<MyPageResponse.getMyPageDTO> updateName(@RequestBody UpdateNa
return ApiResponse.success(SuccessStatus.OK, myPageDTO);

}

@PostMapping
@Operation(summary = "회원 탈퇴 API")
public ApiResponse<?> userOutService(HttpServletRequest request) {
Long userId = tokenProvider.getUserId(request);
myPageService.deleteUser(userId);
return ApiResponse.success(SuccessStatus.DELETE_USER_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.trendithon.timetris.domain.member.dto.MyPageResponse;
import com.trendithon.timetris.domain.member.dto.UpdateNameRequest;
import com.trendithon.timetris.domain.member.repository.UserRepository;
import com.trendithon.timetris.global.exception.CustomException;
import com.trendithon.timetris.global.exception.enums.ErrorStatus;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -41,5 +39,10 @@ public MyPageResponse.getMyPageDTO updateName(Long userId, UpdateNameRequest nam
.build();

}
@Transactional
public void deleteUser(Long userId) {
userRepository.deleteById(userId);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.util.UriComponentsBuilder;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public enum SuccessStatus {
/**
* 200 OK
*/
OK(HttpStatus.OK, "COMMON200", "성공입니다.");
OK(HttpStatus.OK, "COMMON200", "성공입니다."),
DELETE_USER_SUCCESS(HttpStatus.OK, "USER200", "유저 탈퇴 성공입니다.");

private final HttpStatus httpStatus;
private final String code;
Expand Down

0 comments on commit 760cc3f

Please sign in to comment.