Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static ProposalDirection fromWhoProposed(Role whoProposed) {
return switch (whoProposed) {
case BRAND -> BRAND_TO_CREATOR;
case CREATOR -> CREATOR_TO_BRAND;
case ADMIN, GUEST -> throw new IllegalArgumentException(
case ADMIN, GUEST, WITHDRAWN -> throw new IllegalArgumentException(
"Proposal direction is only for BRAND or CREATOR, got: " + whoProposed);
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.example.RealMatch.user.application.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.RealMatch.global.exception.CustomException;
import com.example.RealMatch.global.presentation.code.GeneralErrorCode;
import com.example.RealMatch.user.domain.entity.User;
import com.example.RealMatch.user.domain.repository.UserRepository;

import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
@Transactional
public class UserWithdrawService {

private final UserRepository userRepository;

public void withdraw(Long userId) {
User user = userRepository.findById(userId)
.orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND));

user.withdraw(userId);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ public void updateInfo(String nickname, String address, String detailAddress) {
this.detailAddress = detailAddress;
}

public void softDelete(Long deletedBy) {
public void withdraw(Long deletedBy) {
this.isDeleted = true;
this.deletedAt = LocalDateTime.now();
this.deletedBy = deletedBy;
this.role = Role.WITHDRAWN;
}

public void completeSignup(String nickname, LocalDate birth, Gender gender, Role role) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public enum Role {
ADMIN,
GUEST,
BRAND,
CREATOR;
CREATOR,
WITHDRAWN;

// !!! customDetails에서 role을 string에서 Role로 바꾸면 이거 없앨거임
public static Role from(String value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.example.RealMatch.user.presentation.controller;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -14,6 +15,7 @@
import com.example.RealMatch.match.presentation.dto.request.MatchRequestDto;
import com.example.RealMatch.user.application.service.UserFeatureService;
import com.example.RealMatch.user.application.service.UserService;
import com.example.RealMatch.user.application.service.UserWithdrawService;
import com.example.RealMatch.user.presentation.dto.request.MyEditInfoRequestDto;
import com.example.RealMatch.user.presentation.dto.response.MyEditInfoResponseDto;
import com.example.RealMatch.user.presentation.dto.response.MyFeatureResponseDto;
Expand All @@ -36,6 +38,7 @@ public class UserController implements UserSwagger {

private final UserService userService;
private final UserFeatureService userFeatureService;
private final UserWithdrawService userWithdrawService;

@Override
@GetMapping("/me")
Expand Down Expand Up @@ -117,4 +120,13 @@ public CustomResponse<NicknameAvailableResponseDto> checkNicknameAvailable(
boolean available = userService.isNicknameAvailable(nickname);
return CustomResponse.ok(new NicknameAvailableResponseDto(available));
}

@Override
@DeleteMapping("/me")
public CustomResponse<Void> withdraw(
@AuthenticationPrincipal CustomUserDetails userDetails
) {
userWithdrawService.withdraw(userDetails.getUserId());
return CustomResponse.ok(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,9 @@ CustomResponse<NicknameAvailableResponseDto> checkNicknameAvailable(
)
@RequestParam String nickname
);

@Operation(summary = "회원 탈퇴", description = "회원 탈퇴(Soft Delete) 처리 후 role을 WITHDRAWN으로 변경합니다.")
CustomResponse<Void> withdraw(
@Parameter(hidden = true) @AuthenticationPrincipal CustomUserDetails userDetails
);
}
Loading