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 @@ -43,7 +43,7 @@ public class CrewController implements CrewApi {

@GetMapping("/profile/{crewId}")
public SingleResponse<CrewProfileResponse> inquiryCrewProfile(@HereWeUser User user,
@PathVariable Long crewId) {
@PathVariable Long crewId) {
CrewProfileResponse crewProfileResponse = crewFacade.inquiryCrewProfile(user.getId(), crewId);
return new SingleResponse<>(HttpStatus.OK, crewProfileResponse);
}
Expand Down Expand Up @@ -126,4 +126,11 @@ public CommonResponse expelCrew(

return CommonResponse.ok();
}

@DeleteMapping("/{crewId}/members/me")
public CommonResponse quitCrew(@HereWeUser User user,
@PathVariable Long crewId) {
crewFacade.quitCrew(user.getId(), crewId);
return CommonResponse.ok();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public interface CrewFacade {
void deleteCrew(Long crewId);

void expelCrew(Long userId, CrewExpelRequest expelRequest);

void quitCrew(Long userId, Long crewId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,19 @@ public void expelCrew(Long userId, CrewExpelRequest expelRequest) {
crewMemberService.delete(crewMember);
crew.updateParticipantCount(-1);
}

@Override
@Transactional
public void quitCrew(Long userId, Long crewId) {
User user = userService.findById(userId);
Crew crew = crewService.findById(crewId);

CrewMember crewMember = crewMemberService.find(userId, crewId);
if (crewMember.getRole() == CrewRole.LEADER) {
throw new BusinessException(LEADER_CANNOT_EXPEL);
}

crewMemberService.delete(crewMember);
crew.updateParticipantCount(-1);
}
}