Skip to content

Commit

Permalink
refactor: 반환형식 통일
Browse files Browse the repository at this point in the history
  • Loading branch information
hong-sile committed Sep 29, 2024
1 parent 69c4cf6 commit 550e347
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/main/java/play/pluv/feed/application/FeedReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class FeedReader {
public List<Feed> findAll() {
return feedRepository.findAll().stream()
.sorted(comparing(Feed::getCreatedAt).reversed())
.sorted(comparing(feed -> feed.getId() <= 116))
.sorted(comparing(feed -> feed.getId() > 116))
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import play.pluv.base.BaseResponse;
import play.pluv.feed.application.FeedService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ public class PlayListController {
private final PlayListService playListService;

@PostMapping("/spotify/read")
public ResponseEntity<List<PlayListOverViewResponse>> readSpotifyPlayLists(
public BaseResponse<List<PlayListOverViewResponse>> readSpotifyPlayLists(
@Valid @RequestBody final PlayListReadRequest request
) {
final var playLists = playListService.getPlayLists(request.accessToken(), SPOTIFY);
final List<PlayListOverViewResponse> response = PlayListOverViewResponse.createList(playLists);
return ResponseEntity.ok(response);
return BaseResponse.ok(response);
}

@PostMapping("/youtube/read")
public ResponseEntity<List<PlayListOverViewResponse>> readYoutubePlayLists(
public BaseResponse<List<PlayListOverViewResponse>> readYoutubePlayLists(
@Valid @RequestBody final PlayListReadRequest request
) {
final var playLists = playListService.getPlayLists(request.accessToken(), YOUTUBE);
final List<PlayListOverViewResponse> response = PlayListOverViewResponse.createList(playLists);
return ResponseEntity.ok(response);
return BaseResponse.ok(response);
}

@PostMapping("/ocr/read")
Expand Down Expand Up @@ -74,12 +74,12 @@ public BaseResponse<List<PlayListMusicResponse>> readYoutubeMusics(
}

@PostMapping("/apple/read")
public ResponseEntity<List<PlayListOverViewResponse>> readApplePlayLists(
public BaseResponse<List<PlayListOverViewResponse>> readApplePlayLists(
@Valid @RequestBody final ApplePlayListReadRequest request
) {
final var playLists = playListService.getPlayLists(request.musicUserToken(), APPLE);
final List<PlayListOverViewResponse> response = PlayListOverViewResponse.createList(playLists);
return ResponseEntity.ok(response);
return BaseResponse.ok(response);
}

@PostMapping("/apple/{id}/read")
Expand Down
14 changes: 8 additions & 6 deletions src/test/java/play/pluv/api/PlayListApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
public class PlayListApiTest extends ApiTest {

private static final FieldDescriptor[] PLAY_LIST_RESPONSE = {
fieldWithPath("[]").type(ARRAY).description("플레이리스트 전체"),
fieldWithPath("[].thumbNailUrl").type(STRING).description("플레이리스트 섬네일 url"),
fieldWithPath("[].songCount").type(NUMBER).description("플레이리스트 안에 있는 곡 수").optional(),
fieldWithPath("[].name").type(STRING).description("플레이리스트 이름"),
fieldWithPath("[].source").type(STRING).description("플레이리스트 출처"),
fieldWithPath("[].id").type(STRING).description("플레이리스트 식별자")};
fieldWithPath("code").type(NUMBER).description("상태 코드"),
fieldWithPath("msg").type(STRING).description("상태 코드에 해당하는 메시지"),
fieldWithPath("data[]").type(ARRAY).description("플레이리스트 전체"),
fieldWithPath("data[].thumbNailUrl").type(STRING).description("플레이리스트 섬네일 url"),
fieldWithPath("data[].songCount").type(NUMBER).description("플레이리스트 안에 있는 곡 수").optional(),
fieldWithPath("data[].name").type(STRING).description("플레이리스트 이름"),
fieldWithPath("data[].source").type(STRING).description("플레이리스트 출처"),
fieldWithPath("data[].id").type(STRING).description("플레이리스트 식별자")};

private static final FieldDescriptor[] MUSIC_RESPONSE = {
fieldWithPath("code").type(NUMBER).description("상태 코드"),
Expand Down

0 comments on commit 550e347

Please sign in to comment.