diff --git a/.github/workflows/auto-close-issue.yml b/.github/workflows/auto-close-issue.yml new file mode 100644 index 000000000..45ef3aa66 --- /dev/null +++ b/.github/workflows/auto-close-issue.yml @@ -0,0 +1,20 @@ +name: Auto Close Issues on Merge + +on: + pull_request: + types: [opened] # closed로 바꾸기 + +jobs: + close-related-issue: + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true && github.base.ref != 'main' + steps: + - name: Extract and Close Issue + run: | + PR_BODY="${{ github.event.pull_request.body }}" + ISSUE_NUMBERS=$(echo $PR_BODY | grep -oP 'close #\d+' | awk '{print substr($2, 2)}') + for ISSUE_NUMBER in $ISSUE_NUMBERS; do + gh api -X PATCH /repos/${{ github.repository }}/issues/$ISSUE_NUMBER --field state=closed + done + env: + GITHUB_TOKEN: ${{ secrets.AUTO_CLOSE_GITHUB_TOKEN }} diff --git a/backend/http/offering.http b/backend/http/offering.http index d10292837..19cd5fadd 100644 --- a/backend/http/offering.http +++ b/backend/http/offering.http @@ -2,7 +2,7 @@ GET {{base-url}}/offerings/1 ### 공모 목록 조회 API -GET {{base-url}}/offerings?filter=RECENT&search=&last-id=99&page-size=2 +GET {{base-url}}/offerings ### 공모 필터 목록 조회 API GET {{base-url}}/offerings/filters diff --git a/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java b/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java index 5cbaaf7d7..edb224b62 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java @@ -22,7 +22,8 @@ public interface OfferingRepository extends JpaRepository @Query(""" SELECT o FROM OfferingEntity o - WHERE o.id < :lastId AND (o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) + WHERE o.id < :lastId + AND (:keyword IS NULL OR o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) ORDER BY o.id DESC """) List findRecentOfferingsWithKeyword(Long lastId, String keyword, Pageable pageable); @@ -31,7 +32,7 @@ public interface OfferingRepository extends JpaRepository SELECT o FROM OfferingEntity o WHERE (o.deadline > :lastDeadline OR (o.deadline = :lastDeadline AND o.id < :lastId)) - AND (o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) + AND (:keyword IS NULL OR o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) ORDER BY o.deadline ASC, o.id DESC """) List findImminentOfferingsWithKeyword( @@ -42,7 +43,7 @@ List findImminentOfferingsWithKeyword( FROM OfferingEntity o WHERE ((o.eachPrice - (o.totalPrice * 1.0 / o.totalCount)) / o.eachPrice < :discountRate OR ((o.eachPrice - (o.totalPrice * 1.0 / o.totalCount)) / o.eachPrice = :discountRate AND o.id < :lastId)) - AND (o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) + AND (:keyword IS NULL OR o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) ORDER BY (o.eachPrice - (o.totalPrice * 1.0 / o.totalCount)) / o.eachPrice DESC, o.id DESC """) List findHighDiscountOfferingsWithKeyword( diff --git a/backend/src/test/java/com/zzang/chongdae/offering/integration/OfferingIntegrationTest.java b/backend/src/test/java/com/zzang/chongdae/offering/integration/OfferingIntegrationTest.java index 876543154..e30a611c7 100644 --- a/backend/src/test/java/com/zzang/chongdae/offering/integration/OfferingIntegrationTest.java +++ b/backend/src/test/java/com/zzang/chongdae/offering/integration/OfferingIntegrationTest.java @@ -119,10 +119,10 @@ class GetAllOffering { List queryParameterDescriptors = List.of( parameterWithName("filter").description("필터 이름 (기본값: RECENT)" - + getEnumValuesAsString(OfferingFilter.class)), - parameterWithName("search").description("검색어"), - parameterWithName("last-id").description("마지막 공모 id"), - parameterWithName("page-size").description("페이지 크기 (기본값: 10)") + + getEnumValuesAsString(OfferingFilter.class)).optional(), + parameterWithName("search").description("검색어").optional(), + parameterWithName("last-id").description("마지막 공모 id").optional(), + parameterWithName("page-size").description("페이지 크기 (기본값: 10)").optional() ); List successResponseDescriptors = List.of( fieldWithPath("offerings[].id").description("공모 id"),