From 399b1dd4d2fd8c99c46a8cd9f3dfc8c9204736b6 Mon Sep 17 00:00:00 2001 From: elyudwo Date: Sun, 18 Feb 2024 17:56:51 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[Refactor]=20:=20=EB=82=B4=EA=B0=80=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=ED=95=9C=20=EC=8A=A4=ED=84=B0=EB=94=94=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ACCEPT 된 스터디 반환하지 않도록 수정 --- .../studyhubserver/apply/repository/ApplyRepositoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/kr/co/studyhubinu/studyhubserver/apply/repository/ApplyRepositoryImpl.java b/src/main/java/kr/co/studyhubinu/studyhubserver/apply/repository/ApplyRepositoryImpl.java index 4d39bce1..b05550cb 100644 --- a/src/main/java/kr/co/studyhubinu/studyhubserver/apply/repository/ApplyRepositoryImpl.java +++ b/src/main/java/kr/co/studyhubinu/studyhubserver/apply/repository/ApplyRepositoryImpl.java @@ -82,7 +82,7 @@ public List findApplyByUserId(Long userId, Pageable pageable) .from(applyEntity) .innerJoin(studyEntity).on(applyEntity.studyId.eq(studyEntity.id)) .innerJoin(studyPostEntity).on(studyPostEntity.studyId.eq(studyEntity.id)) - .where(applyEntity.userId.eq(userId)) + .where(applyEntity.userId.eq(userId), applyEntity.inspection.in(Inspection.STANDBY, Inspection.REJECT)) .orderBy(applyEntity.createdDate.desc()) .offset(pageable.getOffset()) .limit(pageable.getPageSize() + 1) From 7a753107597a301250d9f0dd5dcb50070d15b6ba Mon Sep 17 00:00:00 2001 From: elyudwo Date: Sun, 18 Feb 2024 17:57:14 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[Test]=20:=20=EB=82=B4=EA=B0=80=20=EC=8B=A0?= =?UTF-8?q?=EC=B2=AD=ED=95=9C=20=EC=8A=A4=ED=84=B0=EB=94=94=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EB=8B=A8=EC=9C=84=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply/repository/ApplyRepositoryTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/test/java/kr/co/studyhubinu/studyhubserver/apply/repository/ApplyRepositoryTest.java b/src/test/java/kr/co/studyhubinu/studyhubserver/apply/repository/ApplyRepositoryTest.java index a289babf..f4454591 100644 --- a/src/test/java/kr/co/studyhubinu/studyhubserver/apply/repository/ApplyRepositoryTest.java +++ b/src/test/java/kr/co/studyhubinu/studyhubserver/apply/repository/ApplyRepositoryTest.java @@ -2,11 +2,14 @@ import kr.co.studyhubinu.studyhubserver.apply.domain.ApplyEntity; import kr.co.studyhubinu.studyhubserver.apply.dto.data.ApplyUserData; +import kr.co.studyhubinu.studyhubserver.apply.dto.data.RequestApplyData; import kr.co.studyhubinu.studyhubserver.apply.dto.request.UpdateApplyRequest; import kr.co.studyhubinu.studyhubserver.apply.enums.Inspection; import kr.co.studyhubinu.studyhubserver.exception.apply.ApplyNotFoundException; import kr.co.studyhubinu.studyhubserver.study.repository.StudyRepository; import kr.co.studyhubinu.studyhubserver.study.domain.StudyEntity; +import kr.co.studyhubinu.studyhubserver.studypost.domain.StudyPostEntity; +import kr.co.studyhubinu.studyhubserver.studypost.repository.StudyPostRepository; import kr.co.studyhubinu.studyhubserver.support.fixture.StudyEntityFixture; import kr.co.studyhubinu.studyhubserver.support.fixture.UserEntityFixture; import kr.co.studyhubinu.studyhubserver.support.repository.RepositoryTest; @@ -26,6 +29,7 @@ import java.util.Optional; import static kr.co.studyhubinu.studyhubserver.apply.enums.Inspection.ACCEPT; +import static kr.co.studyhubinu.studyhubserver.apply.enums.Inspection.REJECT; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -43,6 +47,9 @@ class ApplyRepositoryTest { @Autowired UserRepository userRepository; + @Autowired + StudyPostRepository studyPostRepository; + @PersistenceContext private EntityManager entityManager; @@ -168,4 +175,25 @@ class ApplyRepositoryTest { // then assertThat(apply).isEmpty(); } + + @Test + void 내가_신청한_스터디_조회_시_Apply된_스터디를_제외하고_조회() { + UserEntity userEntity = userRepository.save(UserEntityFixture.DONGWOO.UserEntity_생성()); + StudyEntity studyEntity = studyRepository.save(StudyEntityFixture.INU.studyEntity_생성()); + StudyPostEntity studyPostEntity = StudyPostEntity.builder() + .studyId(studyEntity.getId()) + .postedUserId(userEntity.getId()) + .build(); + studyPostRepository.save(studyPostEntity); + + ApplyEntity apply = ApplyEntity.builder() + .userId(userEntity.getId()) + .studyId(studyEntity.getId()) + .inspection(ACCEPT) + .build(); + applyRepository.save(apply); + + List applyData = applyRepository.findApplyByUserId(userEntity.getId(), PageRequest.of(0,3)); + assertThat(applyData.size()).isEqualTo(0); + } } \ No newline at end of file