Skip to content

Commit a712952

Browse files
Merge pull request #90 from prgrms-web-devcourse-final-project/feat/#79
[Concert] 공연 제목 검색 기능 추가
2 parents a99e4c0 + 9fe97c0 commit a712952

3 files changed

Lines changed: 44 additions & 7 deletions

File tree

src/main/java/com/back/web7_9_codecrete_be/domain/concerts/controller/ConcertController.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import io.swagger.v3.oas.annotations.media.Schema;
1717
import io.swagger.v3.oas.annotations.tags.Tag;
1818
import lombok.RequiredArgsConstructor;
19+
import lombok.extern.slf4j.Slf4j;
1920
import org.springdoc.core.converters.models.PageableAsQueryParam;
2021
import org.springframework.data.domain.Page;
2122
import org.springframework.data.domain.PageRequest;
@@ -27,6 +28,7 @@
2728
import javax.swing.*;
2829
import java.util.List;
2930

31+
@Slf4j
3032
@RestController
3133
@RequestMapping("api/v1/concerts/")
3234
@RequiredArgsConstructor
@@ -122,17 +124,17 @@ public RsData<ConcertLikeResponse> isLikeConcert(
122124
return RsData.success(concertService.isLikeConcert(concertId, user));
123125
}
124126

125-
// todo : 내용 구현 필요
126-
@Operation(summary = "공연 검색(구현 전)", description = "공연 정보를 검색합니다.")
127+
// todo : 제목으로 만 검색 기능 구현 -> 추후 아티스트 정보랑 연동 <- 중요 / 정렬 기준? 최신등록순 정렬
128+
@Operation(summary = "공연 검색", description = "제목에 키워드를 포함하고 있는 공연 정보를 검색합니다.")
127129
@GetMapping("search")
128130
public RsData<List<ConcertItem>> searchConcert(
129131
@Schema(description = "공연 정보 검색 키워드입니다.")
130-
@RequestParam String keyword
132+
@RequestParam String keyword,
133+
@Schema(description = "페이징 처리 또는 무한 스크롤 구현에 쓸 Pageable 객체입니다.")
134+
Pageable pageable
135+
131136
){
132-
return null;
137+
return RsData.success(concertService.getConcertListByKeyword(keyword,pageable));
133138
}
134139

135-
136-
137-
138140
}

src/main/java/com/back/web7_9_codecrete_be/domain/concerts/repository/ConcertRepository.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,33 @@ List<ConcertItem> getNoTicketTimeConcertList(
124124
)
125125
List<ConcertItem> getLikedConcertsList(Pageable pageable,
126126
@Param("userId") Long userId);
127+
@Query("""
128+
SELECT
129+
new com.back.web7_9_codecrete_be.domain.concerts.dto.concert.ConcertItem(
130+
c.concertId as id,
131+
c.name as name,
132+
c.concertPlace.placeName as placeName,
133+
c.ticketTime as ticketTime,
134+
c.startDate as startDate,
135+
c.endDate as endDate,
136+
c.posterUrl as posterUrl,
137+
c.maxPrice as maxPrice,
138+
c.minPrice as minPrice,
139+
c.viewCount as viewCount,
140+
c.likeCount as likeCount
141+
)
142+
FROM
143+
Concert c
144+
WHERE
145+
c.name LIKE %:keyword%
146+
ORDER BY
147+
c.concertId
148+
DESC
149+
""")
150+
List<ConcertItem> getConcertItemsByKeyword(
151+
@Param("keyword")
152+
String keyword,
153+
Pageable pageable);
127154

128155
@Query("""
129156
SELECT

src/main/java/com/back/web7_9_codecrete_be/domain/concerts/service/ConcertService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ public List<ConcertItem> getNoTicketTimeConcertsList(Pageable pageable) {
4949
return concertRepository.getNoTicketTimeConcertList(pageable);
5050
}
5151

52+
public List<ConcertItem> getConcertListByKeyword(String keyword, Pageable pageable) {
53+
if(keyword == null || keyword.isEmpty()){
54+
55+
}
56+
57+
return concertRepository.getConcertItemsByKeyword(keyword, pageable);
58+
}
59+
5260
public ConcertDetailResponse getConcertDetail(long concertId) {
5361
ConcertDetailResponse concertDetailResponse = concertRepository.getConcertDetailById(concertId);
5462
List<ConcertImage> concertImages = concertImageRepository.getConcertImagesByConcert_ConcertId(concertId);

0 commit comments

Comments
 (0)