From c7f1b477d8ae1a21005a5fe22a688f2ba20250dc Mon Sep 17 00:00:00 2001 From: khs Date: Fri, 13 Oct 2023 17:27:20 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=A6=AC=ED=81=AC=EB=A3=A8=ED=8A=B8=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: 리크루트 목록조회 category null 처리 fix: 리크루트 등록 시 question 빈값 처리 fix: 리크루트 질문 등록 예외처리 로직 수정 fix: 사용자 참여중 리크루트 조회시 로그인 유저는 항상 볼수있도록 수정 fix: 리크루트 참여 목록 조회시 로그인 id적용되도록 수정 fix: 질문이 없는 리크루트 신청 조회를 위한 left join 변경 및 생성자를 이용한 projection 관련 버그 수정 fix: 리크루트 신청 프로젝션 방식 변경 fix: 취소된 리크루트 신청 조회되지 않도록 수정 fix: 내가 참여한 리크루트 조회 쿼리 오류 수정 and절 -> or절로 수정 fix: 리크루트 신청 수락시 current number 수정되도록 오류 수정 --- .../domain/recruit/controller/RecruitController.java | 2 +- .../domain/recruit/dto/PostRecruitReqDto.java | 6 +++++- .../RecruitDynamicQueryRepositoryImpl.java | 10 +++++----- .../domain/recruit/service/RecruitService.java | 3 ++- ...RecruitApplicationComplexQueryRepositoryImpl.java | 7 ++++--- .../service/RecruitApplicationService.java | 12 ++++++++---- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/ssafy/ssafsound/domain/recruit/controller/RecruitController.java b/src/main/java/com/ssafy/ssafsound/domain/recruit/controller/RecruitController.java index d728f44ac..3f1ee7bb9 100644 --- a/src/main/java/com/ssafy/ssafsound/domain/recruit/controller/RecruitController.java +++ b/src/main/java/com/ssafy/ssafsound/domain/recruit/controller/RecruitController.java @@ -81,7 +81,7 @@ public EnvelopeResponse getMemberJoinedRecruits(GetMemberJoi @GetMapping("/applied") public EnvelopeResponse getMemberAppliedRecruits(GetMemberAppliedRecruitsReqDto recruitsReqDto, @Authentication AuthenticatedMember memberInfo) { return EnvelopeResponse.builder() - .data(recruitService.getMemberAppliedRecruits(recruitsReqDto, 1L)) + .data(recruitService.getMemberAppliedRecruits(recruitsReqDto, memberInfo.getMemberId())) .build(); } } diff --git a/src/main/java/com/ssafy/ssafsound/domain/recruit/dto/PostRecruitReqDto.java b/src/main/java/com/ssafy/ssafsound/domain/recruit/dto/PostRecruitReqDto.java index f96a655cb..0d7342eaf 100644 --- a/src/main/java/com/ssafy/ssafsound/domain/recruit/dto/PostRecruitReqDto.java +++ b/src/main/java/com/ssafy/ssafsound/domain/recruit/dto/PostRecruitReqDto.java @@ -18,6 +18,8 @@ import java.util.List; import java.util.stream.Collectors; +import org.springframework.util.StringUtils; + @Getter @NoArgsConstructor @AllArgsConstructor @@ -68,7 +70,9 @@ public Recruit to() { private void setRecruitQuestions (Recruit recruit) { if(questions == null) return; - List recruitQuestions = questions.stream().map((question)-> RecruitQuestion.builder() + List recruitQuestions = questions.stream() + .filter(StringUtils::hasText) + .map((question)-> RecruitQuestion.builder() .recruit(recruit) .content(question) .build() diff --git a/src/main/java/com/ssafy/ssafsound/domain/recruit/repository/RecruitDynamicQueryRepositoryImpl.java b/src/main/java/com/ssafy/ssafsound/domain/recruit/repository/RecruitDynamicQueryRepositoryImpl.java index dd4de2fd5..afdd4ca6e 100644 --- a/src/main/java/com/ssafy/ssafsound/domain/recruit/repository/RecruitDynamicQueryRepositoryImpl.java +++ b/src/main/java/com/ssafy/ssafsound/domain/recruit/repository/RecruitDynamicQueryRepositoryImpl.java @@ -77,7 +77,7 @@ public Slice findRecruitByGetRecruitsReqDto(GetRecruitsReqDto dto, Page // recruit types limitation List recruitTypes = dto.getRecruitTypes(); - if(dto.getCategory().toUpperCase().equals(Category.PROJECT.name()) && recruitTypes!=null && !recruitTypes.isEmpty()) { + if(dto.getCategory() != null && dto.getCategory().toUpperCase().equals(Category.PROJECT.name()) && recruitTypes!=null && !recruitTypes.isEmpty()) { String metaDataType = MetaDataType.RECRUIT_TYPE.name(); List containRecruitTypes = recruitTypes.stream() .map(recruitType->metaDataConsumer.getMetaData(metaDataType, recruitType)) @@ -121,8 +121,7 @@ public Slice findMemberJoinRecruitWithCursorAndPageable(Long memberId, List recruits = jpaQueryFactory.selectFrom(recruit) .innerJoin(recruit.member, member) .where(recruitIdLtThanCursor(cursor), - recruit.id.in(memberJoinRecruitIds), - recruit.member.id.eq(memberId), + recruit.id.in(memberJoinRecruitIds).or(recruit.member.id.eq(memberId)), categoryEq) .limit(pageable.getPageSize()+1) .orderBy(recruit.id.desc()) @@ -153,7 +152,7 @@ public Slice findMemberAppliedRecruits(Long memberId, Long curso BooleanExpression matchStatusEq = (matchStatus == null) ? null : recruitApplication.matchStatus.eq(MatchStatus.valueOf(matchStatus.toUpperCase())); List recruits = jpaQueryFactory.select( - Projections.fields( + Projections.constructor( AppliedRecruit.class, recruit, recruitApplication.matchStatus, @@ -166,7 +165,8 @@ public Slice findMemberAppliedRecruits(Long memberId, Long curso .where(recruitIdLtThanCursor(cursor), recruitApplication.member.id.eq(memberId), categoryEq, - matchStatusEq) + matchStatusEq, + recruitApplication.matchStatus.notIn(MatchStatus.CANCEL)) .limit(pageable.getPageSize() + 1) .orderBy(recruitApplication.id.desc()) .fetch(); diff --git a/src/main/java/com/ssafy/ssafsound/domain/recruit/service/RecruitService.java b/src/main/java/com/ssafy/ssafsound/domain/recruit/service/RecruitService.java index e276bc790..1cb4baa55 100644 --- a/src/main/java/com/ssafy/ssafsound/domain/recruit/service/RecruitService.java +++ b/src/main/java/com/ssafy/ssafsound/domain/recruit/service/RecruitService.java @@ -161,7 +161,8 @@ public void expiredRecruit(Long recruitId, Long memberId) { public GetRecruitsResDto getMemberJoinRecruits(GetMemberJoinRecruitsReqDto recruitsReqDto, Long loginMemberId) { Long memberId = recruitsReqDto.getMemberId(); Member member = memberRepository.findById(memberId).orElseThrow(()->new ResourceNotFoundException(GlobalErrorInfo.NOT_FOUND)); - if(!member.getPublicProfile()) { + + if(!memberId.equals(loginMemberId) && !member.getPublicProfile()) { throw new MemberException(MemberErrorInfo.MEMBER_PROFILE_SECRET); } diff --git a/src/main/java/com/ssafy/ssafsound/domain/recruitapplication/repository/RecruitApplicationComplexQueryRepositoryImpl.java b/src/main/java/com/ssafy/ssafsound/domain/recruitapplication/repository/RecruitApplicationComplexQueryRepositoryImpl.java index 4906d2469..9698a228a 100644 --- a/src/main/java/com/ssafy/ssafsound/domain/recruitapplication/repository/RecruitApplicationComplexQueryRepositoryImpl.java +++ b/src/main/java/com/ssafy/ssafsound/domain/recruitapplication/repository/RecruitApplicationComplexQueryRepositoryImpl.java @@ -27,10 +27,11 @@ public RecruitApplicationElement findTopByRecruitIdAndMemberId(Long recruitId, L try { return jpaQueryFactory.select( Projections - .fields( + .constructor( RecruitApplicationElement.class, recruit.id, recruitApplication.id, + recruitApplication.type, recruitApplication.matchStatus, member, recruitQuestionReply.content, @@ -42,8 +43,8 @@ public RecruitApplicationElement findTopByRecruitIdAndMemberId(Long recruitId, L .from(recruitApplication) .innerJoin(recruitApplication.member, member) .innerJoin(recruitApplication.recruit, recruit) - .join(recruitQuestion).on(recruitQuestion.recruit.id.eq(recruit.id)) - .join(recruitQuestionReply).on(recruitQuestionReply.question.id.eq(recruitQuestion.id)) + .leftJoin(recruitQuestion).on(recruitQuestion.recruit.id.eq(recruit.id)) + .leftJoin(recruitQuestionReply).on(recruitQuestionReply.question.id.eq(recruitQuestion.id)) .where(recruit.id.eq(recruitId), member.id.eq(memberId), recruitApplication.matchStatus.eq(MatchStatus.PENDING)) .orderBy(recruitApplication.id.desc()) .limit(1) diff --git a/src/main/java/com/ssafy/ssafsound/domain/recruitapplication/service/RecruitApplicationService.java b/src/main/java/com/ssafy/ssafsound/domain/recruitapplication/service/RecruitApplicationService.java index 992b6ff59..888249b52 100644 --- a/src/main/java/com/ssafy/ssafsound/domain/recruitapplication/service/RecruitApplicationService.java +++ b/src/main/java/com/ssafy/ssafsound/domain/recruitapplication/service/RecruitApplicationService.java @@ -66,7 +66,10 @@ public PatchRecruitApplicationStatusResDto saveRecruitApplication(Long recruitId metaDataConsumer.getMetaData(MetaDataType.RECRUIT_TYPE.name(), recruitType)); List participantAnswers = makeRecruitQuestionReplies(postRecruitApplicationReqDto, recruit, recruitApplication); recruitApplicationRepository.save(recruitApplication); - recruitQuestionReplyRepository.saveAll(participantAnswers); + + if(participantAnswers.size() != 0) { + recruitQuestionReplyRepository.saveAll(participantAnswers); + } return new PatchRecruitApplicationStatusResDto(recruitApplication.getId(), MatchStatus.PENDING.name()); } @@ -75,7 +78,8 @@ public PatchRecruitApplicationStatusResDto approveRecruitApplicationByRegister(L RecruitApplication recruitApplication = recruitApplicationRepository.findByIdFetchRecruitWriter(recruitApplicationId) .orElseThrow(() -> new ResourceNotFoundException(GlobalErrorInfo.NOT_FOUND)); - getNotFullRecruitLimitation(recruitApplication.getRecruit(), recruitApplication.getType()); + RecruitLimitation recruitLimitation = getNotFullRecruitLimitation(recruitApplication.getRecruit(), recruitApplication.getType()); + recruitLimitation.increaseCurrentNumber(); return changeRecruitApplicationState(recruitApplication, memberId, status, (entity, mid) -> { boolean isNotRegister = !entity.getRecruit().getMember().getId().equals(mid); @@ -211,7 +215,7 @@ private List makeRecruitQuestionReplies(PostRecruitApplic List answers = dto.getContents(); int len = recruitQuestion.size(); - if(answers.size() != len) { + if(len!=0 && answers.size() != len) { throw new RecruitException(RecruitErrorInfo.NOT_SAME_LENGTH_RECRUIT_QUESTION_ANSWER); } @@ -224,7 +228,7 @@ private List makeRecruitQuestionReplies(PostRecruitApplic RecruitQuestionReply.builder() .application(recruitApplication) .question(recruitQuestion.get(i)) - .content(dto.getContents().get(i)) + .content(answers.get(i)) .build() ); }