-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4af4b54
commit 1ee3df5
Showing
10 changed files
with
80 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...main/java/idorm/idormServer/calendar/adapter/out/persistence/DeleteTeamMemberAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package idorm.idormServer.calendar.adapter.out.persistence; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import idorm.idormServer.calendar.application.port.out.DeleteSleepoverCalendarPort; | ||
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; | ||
|
||
@Component | ||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class DeleteTeamMemberAdapter implements DeleteTeamMemberPort { | ||
|
||
private final LoadMemberPort loadMemberPort; | ||
private final LoadTeamPort loadTeamPort; | ||
private final LoadTeamCalendarPort loadTeamCalendarPort; | ||
private final DeleteSleepoverCalendarPort deleteSleepoverCalendarPort; | ||
private final DeleteTeamPort deleteTeamPort; | ||
|
||
@Override | ||
public void deleteTeamMember(Long memberId) { | ||
final Member member = loadMemberPort.loadMember(memberId); | ||
final Team team = loadTeamPort.findByMemberId(member.getId()); | ||
final List<TeamCalendar> teamCalendars = loadTeamCalendarPort.findByMemberId(member.getId()); | ||
|
||
deleteSleepoverCalendarPort.deleteByMemberId(memberId); | ||
teamCalendars | ||
.forEach(teamCalendar -> teamCalendar.deletePariticipant(member.getId())); | ||
team.deleteMember(member); | ||
if (team.getMembers().isEmpty()) { | ||
deleteTeamPort.delete(team); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/idorm/idormServer/calendar/application/port/out/DeleteTeamMemberPort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package idorm.idormServer.calendar.application.port.out; | ||
|
||
public interface DeleteTeamMemberPort { | ||
void deleteTeamMember(final Long memberId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters