From 4e2aa37c5fcfc2f945e462eea6daf45912067c46 Mon Sep 17 00:00:00 2001 From: joonghyun Date: Sun, 24 Mar 2024 03:36:45 +0900 Subject: [PATCH] =?UTF-8?q?#15=20fix:=20=EB=A6=AC=EB=8D=94=EB=8A=94=20?= =?UTF-8?q?=EB=9D=B1=EC=9D=84=20=EB=82=98=EA=B0=88=20=EC=88=98=20=EC=97=86?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hatcher/haemo/common/enums/BaseResponseStatus.java | 1 + .../recruitment/application/RecruitmentService.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hatcher/haemo/common/enums/BaseResponseStatus.java b/src/main/java/com/hatcher/haemo/common/enums/BaseResponseStatus.java index 869f450..d73ec82 100644 --- a/src/main/java/com/hatcher/haemo/common/enums/BaseResponseStatus.java +++ b/src/main/java/com/hatcher/haemo/common/enums/BaseResponseStatus.java @@ -49,6 +49,7 @@ public enum BaseResponseStatus { LEADER_ROLE(false, HttpStatus.BAD_REQUEST, "리더는 띱 참여가 불가능합니다."), NOT_LEADER_ROLE(false, HttpStatus.BAD_REQUEST, "해당 띱의 리더가 아닙니다."), NOT_MEMBER_ROLE(false, HttpStatus.BAD_REQUEST, "해당 띱의 멤버가 아닙니다."), + LEADER_CANNOT_WITHDRAW(false, HttpStatus.BAD_REQUEST, "띱의 리더는 나갈 수 없습니다."), // comment(2200-2299) INVALID_COMMENT_IDX(false, HttpStatus.NOT_FOUND, "해당 comment idx로 comment를 찾을 수 없습니다."), diff --git a/src/main/java/com/hatcher/haemo/recruitment/application/RecruitmentService.java b/src/main/java/com/hatcher/haemo/recruitment/application/RecruitmentService.java index 90d2206..f081641 100644 --- a/src/main/java/com/hatcher/haemo/recruitment/application/RecruitmentService.java +++ b/src/main/java/com/hatcher/haemo/recruitment/application/RecruitmentService.java @@ -80,7 +80,10 @@ public BaseResponse getRecruitmentList(String type, boo .sorted(Comparator.comparing(Recruitment::getCreatedDate).reversed()) .map(recruitment -> new RecruitmentDto(recruitment.getRecruitmentIdx(), recruitment.getType().getDescription(), recruitment.getName(), recruitment.getLeader().getNickname(), (int) getActiveParticipantCount(recruitment)+1, recruitment.getParticipantLimit(), recruitment.getDescription(), - recruitment.getLeader().equals(user), recruitment.getStatus().equals(DONE))).toList(); + recruitment.getLeader().equals(user), recruitment.getStatus().equals(DONE) + //, + //recruitment.getParticipants().contains(participantRepository.findByParticipantAndRecruitmentAndStatusEquals(user, recruitment, RECRUITING)) + )).toList(); recruitmentList.addAll(sortedRecruitmentList); } else { // 비회원 recruitmentList = null; @@ -117,7 +120,9 @@ private List getRecruitmentList(List recruitmentRep } return new RecruitmentDto(recruitment.getRecruitmentIdx(), recruitment.getType().getDescription(), recruitment.getName(), recruitment.getLeader().getNickname(), (int) getActiveParticipantCount(recruitment)+1, recruitment.getParticipantLimit(), recruitment.getDescription(), - isLeader, false); + isLeader, false + //, recruitment.getParticipants().contains(participantRepository.findByParticipantAndRecruitmentAndStatusEquals(finalUser, recruitment, RECRUITING)) + ); }).toList(); return recruitmentList; } @@ -284,6 +289,7 @@ public BaseResponse withdrawRecruitment(Long recruitmentIdx) throws Base try { User user = userRepository.findById(userService.getUserIdxWithValidation()).orElseThrow(() -> new BaseException(INVALID_USER_IDX)); Recruitment recruitment = recruitmentRepository.findById(recruitmentIdx).orElseThrow(() -> new BaseException(INVALID_RECRUITMENT_IDX)); + if (recruitment.getLeader().equals(user)) throw new BaseException(LEADER_CANNOT_WITHDRAW); boolean isParticipant = recruitment.getParticipants().stream().anyMatch(participant -> participant.getParticipant().equals(user)); if (!isParticipant) throw new BaseException(NOT_MEMBER_ROLE); validateRecruitmentStatus(recruitment.getStatus().equals(DONE), ALREADY_DONE_RECRUITMENT);