From c7b130d0b5df0a898b10f28316f7ba11de42a425 Mon Sep 17 00:00:00 2001 From: seheonnn Date: Fri, 16 Aug 2024 23:05:06 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B2=80=EC=83=89=20api=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95=20(#373)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 검색 api 버그 수정 * ci: ci/cd 파일 변경 * ci: ci/cd 파일 변경 --- .github/workflows/ci_gradle.yml | 2 +- .../controller/OrganizationController.java | 2 +- .../service/OrganizationQueryService.java | 19 ++++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci_gradle.yml b/.github/workflows/ci_gradle.yml index 74b9485..cb18480 100644 --- a/.github/workflows/ci_gradle.yml +++ b/.github/workflows/ci_gradle.yml @@ -31,7 +31,7 @@ jobs: shell: bash - name: Start Docker Compose - run: docker-compose -f docker-compose-test.yml up -d + run: docker compose up -d - name: Grant execute permission for gradlew run: chmod +x gradlew diff --git a/api/src/main/java/com/sponus/sponusbe/domain/organization/controller/OrganizationController.java b/api/src/main/java/com/sponus/sponusbe/domain/organization/controller/OrganizationController.java index fedb578..b63260b 100644 --- a/api/src/main/java/com/sponus/sponusbe/domain/organization/controller/OrganizationController.java +++ b/api/src/main/java/com/sponus/sponusbe/domain/organization/controller/OrganizationController.java @@ -93,7 +93,7 @@ public ApiResponse> searchOrganization( @AuthOrganization Organization organization ) { return ApiResponse.onSuccess( - organizationQueryService.searchOrganizations(pageCondition, keyword, organization)); + organizationQueryService.searchOrganizationsV2(pageCondition, keyword, organization)); } @DeleteMapping("/search") diff --git a/api/src/main/java/com/sponus/sponusbe/domain/organization/service/OrganizationQueryService.java b/api/src/main/java/com/sponus/sponusbe/domain/organization/service/OrganizationQueryService.java index 9ba6ff4..a16d22a 100644 --- a/api/src/main/java/com/sponus/sponusbe/domain/organization/service/OrganizationQueryService.java +++ b/api/src/main/java/com/sponus/sponusbe/domain/organization/service/OrganizationQueryService.java @@ -13,6 +13,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.sponus.coredomain.domain.bookmark.repository.BookmarkRepository; import com.sponus.coredomain.domain.organization.Organization; import com.sponus.coredomain.domain.organization.enums.OrganizationType; import com.sponus.coredomain.domain.organization.enums.ProfileStatus; @@ -36,6 +37,7 @@ public class OrganizationQueryService { private final OrganizationRepository organizationRepository; private final SearchHistoryRepository searchHistoryRepository; + private final BookmarkRepository bookmarkRepository; public Boolean verifyName(String name) { return organizationRepository.existsByName(name); @@ -46,10 +48,10 @@ public PageResponse getOrganizations( PageCondition pageCondition, OrganizationType organizationType) { // TODO: FETCH JOIN으로 변경 - Set bookmarkedOrganizationIds = authOrganization.getBookmarks() - .stream() - .map(bookmark -> bookmark.getTarget().getId()) + Set bookmarkedOrganizationIds = bookmarkRepository.findByOrganization(authOrganization).stream() + .map((bookmark) -> bookmark.getTarget().getId()) .collect(Collectors.toSet()); + Pageable pageable = PageRequest.of(pageCondition.getPage() - 1, pageCondition.getSize()); List organizations = organizationRepository.findOrganizations( organizationType, pageable, authOrganization.getId()) @@ -66,10 +68,10 @@ public PageResponse getOrganizations( public PageResponse searchOrganizations(PageCondition pageCondition, String keyword, Organization authOrganization) { - Set bookmarkedOrganizationIds = authOrganization.getBookmarks() - .stream() - .map(bookmark -> bookmark.getTarget().getId()) + Set bookmarkedOrganizationIds = bookmarkRepository.findByOrganization(authOrganization).stream() + .map((bookmark) -> bookmark.getTarget().getId()) .collect(Collectors.toSet()); + Pageable pageable = PageRequest.of(pageCondition.getPage() - 1, pageCondition.getSize()); List organizations = organizationRepository.findByNameContains( @@ -95,9 +97,8 @@ public PageResponse searchOrganizationsV2( Page organizations = organizationRepository.searchOrganizationV2(condition, pageable); - Set bookmarkedOrganizationIds = authOrganization.getBookmarks() - .stream() - .map(bookmark -> bookmark.getTarget().getId()) + Set bookmarkedOrganizationIds = bookmarkRepository.findByOrganization(authOrganization).stream() + .map((bookmark) -> bookmark.getTarget().getId()) .collect(Collectors.toSet()); return PageResponse.of(organizations.map(organization ->