Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 여행생성자는 탈퇴 불가능하도록 조건 추가 #170

Merged
merged 1 commit into from
Oct 19, 2023
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 @@ -12,6 +12,7 @@
import com.tago.domain.member.domain.vo.Role;
import com.tago.domain.member.service.MemberCreateService;
import com.tago.domain.member.handler.MemberQueryService;
import com.tago.domain.trip.repository.TripRepository;
import com.tago.domain.tripmember.repository.TripMemberRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -26,6 +27,7 @@ public class AuthService {
private final JwtTokenPublisher jwtTokenPublisher;
private final AuthEventProducer authEventProducer;
private final TripMemberRepository tripMemberRepository;
private final TripRepository tripRepository;

@Transactional
public LoginResponse login(LoginRequest request){
Expand All @@ -49,6 +51,11 @@ public SignUpResponse signUp(SignUpRequest request) {

@Transactional
public void withdraw(Long memberId) {

if(tripRepository.existsByMemberId(memberId)) {
throw new IllegalStateException("멤버가 여행에 참여 중이므로 탈퇴할 수 없습니다.");
}

Member member = memberQueryService.findById(memberId);
tripMemberRepository.deleteByMemberId(memberId);
memberQueryService.delete(member);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

public interface TripRepository extends JpaRepository<Trip, Long>, TripCustomRepository {
List<Trip> findByName(String name);
Boolean existsByMemberId(Long memberId);
}