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] 회원 탈퇴 구현 #74

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -5,13 +5,13 @@
import org.springframework.stereotype.Component;

import idorm.idormServer.calendar.application.port.out.DeleteSleepoverCalendarPort;
import idorm.idormServer.calendar.application.port.out.DeleteTeamCalendarPort;
import idorm.idormServer.calendar.application.port.out.DeleteTeamMemberPort;
import idorm.idormServer.calendar.application.port.out.DeleteTeamPort;
import idorm.idormServer.calendar.application.port.out.LoadTeamCalendarPort;
import idorm.idormServer.calendar.application.port.out.LoadTeamPort;
import idorm.idormServer.calendar.entity.Team;
import idorm.idormServer.calendar.entity.TeamCalendar;
import idorm.idormServer.member.application.port.out.LoadMemberPort;
import idorm.idormServer.member.entity.Member;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
Expand All @@ -23,25 +23,27 @@ public class DeleteTeamMemberAdapter implements DeleteTeamMemberPort {
private final LoadTeamPort loadTeamPort;
private final DeleteTeamPort deleteTeamPort;

private final LoadMemberPort loadMemberPort;

private final LoadTeamCalendarPort loadTeamCalendarPort;
private final DeleteTeamCalendarPort deleteTeamCalendarPort;

private final DeleteSleepoverCalendarPort deleteSleepoverCalendarPort;

@Override
public void deleteTeamMember(Long memberId) {
final Member member = loadMemberPort.loadMember(memberId);
public void deleteTeamMember(Member member) {
final Team team = loadTeamPort.findByMemberId(member.getId());
final List<TeamCalendar> teamCalendars = loadTeamCalendarPort.findByMemberId(member.getId());

team.deleteMember(member);
if (team.getMembers().isEmpty()) {
deleteTeamPort.delete(team);
} else {
deleteSleepoverCalendarPort.deleteByMemberId(memberId);
deleteSleepoverCalendarPort.deleteByMemberId(member.getId());
teamCalendars
.forEach(teamCalendar -> teamCalendar.deletePariticipant(member.getId()));
.forEach(teamCalendar -> {
teamCalendar.deletePariticipant(member.getId());
if (teamCalendar.getParticipants().isEmpty())
deleteTeamCalendarPort.delete(teamCalendar);
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

팀에 회원이 한 명 남았을 때 teamStatus가 변경되어야 합니다.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

팀 도메인의 deleteMember() 내에 처리되어 있습니다!

}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 메서드에서 NOT_FOUND_MEMBER 에러가 터집니다. 로그 속 제거되는 회원은 팀이 있는 상태입니다.

스크린샷 2024-05-12 오후 4 58 19

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 부분은 제 쪽에서는 예외가 터지지 않아 문제 원인을 제대로 파악하지 못 하고 있습니다..

그러나 해당 부분의 예외는 teamCalendar의 participant에 memberId가 없을 경우에 예외가 발생할 수 있는데, 팀캘린더를 participant와 조인하여 조회하기 때문에 예외가 발생할 가능성이 거의 없다고 생각됩니다..

그렇지만 예외가 발생한 원인을 명확하게 파악하기위해 계속해서 분석하겠습니다! 혹시 원인 파악에 도움이 될만한 정보가 있다면 공유 해주시면 감사하겠습니다!

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import idorm.idormServer.calendar.entity.Team;
import idorm.idormServer.member.application.port.out.LoadMemberPort;
import idorm.idormServer.member.entity.Member;
import idorm.idormServer.member.entity.MemberStatus;
import lombok.RequiredArgsConstructor;

@Service
Expand Down Expand Up @@ -64,9 +63,10 @@ public void addTeamMember(final AuthResponse authResponse, final Long registerMe

@Override
@Transactional
public void deleteMember(final Long targetId) {
public void deleteMember(final Long memberId) {
final Member member = loadMemberPort.loadMember(memberId);

deleteTeamMemberPort.deleteTeamMember(targetId);
deleteTeamMemberPort.deleteTeamMember(member);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package idorm.idormServer.calendar.application.port.out;

import idorm.idormServer.member.entity.Member;

public interface DeleteTeamMemberPort {
void deleteTeamMember(final Long memberId);
void deleteTeamMember(final Member member);
}