diff --git a/backend/src/main/java/shook/shook/song/ui/SearchController.java b/backend/src/main/java/shook/shook/song/ui/SearchController.java index 7fb5b537..86951f12 100644 --- a/backend/src/main/java/shook/shook/song/ui/SearchController.java +++ b/backend/src/main/java/shook/shook/song/ui/SearchController.java @@ -8,8 +8,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import shook.shook.song.application.ArtistSearchService; -import shook.shook.song.application.dto.ArtistResponse; -import shook.shook.song.application.dto.ArtistWithSongSearchResponse; import shook.shook.song.ui.openapi.SearchApi; @RequiredArgsConstructor @@ -19,18 +17,13 @@ public class SearchController implements SearchApi { private final ArtistSearchService artistSearchService; - @GetMapping(params = {"keyword", "type=singer,song"}) - public ResponseEntity> searchArtistWithSongByKeyword( - @RequestParam(name = "type") final List types, - @RequestParam(name = "keyword") final String keyword) { - return ResponseEntity.ok(artistSearchService.searchArtistsAndTopSongsByKeyword(keyword)); - } - - @GetMapping(params = {"keyword", "type=singer"}) - public ResponseEntity> searchArtistByKeyword( - @RequestParam(name = "type") final String type, - @RequestParam(name = "keyword") final String keyword) { + @GetMapping + public ResponseEntity> search(@RequestParam(name = "type") final List types, + @RequestParam(name = "keyword") final String keyword) { + if (types.containsAll(List.of("song", "singer"))) { + return ResponseEntity.ok(artistSearchService.searchArtistsAndTopSongsByKeyword(keyword)); + } return ResponseEntity.ok(artistSearchService.searchArtistsByKeyword(keyword)); } - + // TODO: 2023-10-19 리팩터링: 검색 타입 enum 생성 } diff --git a/backend/src/main/java/shook/shook/song/ui/openapi/SearchApi.java b/backend/src/main/java/shook/shook/song/ui/openapi/SearchApi.java index 8456ddee..b558075c 100644 --- a/backend/src/main/java/shook/shook/song/ui/openapi/SearchApi.java +++ b/backend/src/main/java/shook/shook/song/ui/openapi/SearchApi.java @@ -2,58 +2,37 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; -import shook.shook.song.application.dto.ArtistResponse; -import shook.shook.song.application.dto.ArtistWithSongSearchResponse; -@Tag(name = "Singer Search", description = "가수 이름 검색 API") +@Tag(name = "Search", description = "검색 API") public interface SearchApi { @Operation( - summary = "검색어 입력 시 자동 완성되는 가수의 정보 검색", - description = "검색어 입력 시, 검색어로 시작하는 가수의 정보를 검색한다." + summary = "가수, 또는 가수와 노래 조회", + description = "가수를 가나다 순으로 조회한다." ) @ApiResponse( responseCode = "200", - description = "가수 검색 성공" + description = "가수 정보, (노래 목록) 검색 성공" ) - @GetMapping(value = "?type=singer", params = {"keyword"}) - ResponseEntity> searchArtistByKeyword( - @Parameter(name = "type", description = "검색 타입", - schema = @Schema(enumAsRef = true, allowableValues = {"singer"})) - @RequestParam(name = "type") final String type, - @Parameter( - name = "keyword", - description = "검색할 가수 키워드", - required = true - ) - @RequestParam(name = "keyword") final String keyword - ); - - @Operation( - summary = "검색 시, 검색 결과 조회", - description = "검색 시, 검색어로 시작하거나 끝나는 가수와 해당 가수의 TOP3 노래가 조회된다." + @Parameter( + name = "type", + description = "검색 타입, singer&song OR singer", + required = true ) - @ApiResponse( - responseCode = "200", - description = "가수, TOP3 노래 검색 성공" + @Parameter( + name = "keyword", + description = "검색 키워드", + required = true ) - @GetMapping(value = "?type=singer,song", params = {"keyword"}) - ResponseEntity> searchArtistWithSongByKeyword( - @Parameter(name = "type", description = "검색 타입", - schema = @Schema(enumAsRef = true, allowableValues = {"singer", "song"})) + @GetMapping("") + ResponseEntity> search( @RequestParam(name = "type") final List types, - @Parameter( - name = "keyword", - description = "검색할 가수 키워드", - required = true - ) @RequestParam(name = "keyword") final String keyword ); }