-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added endpoints to get artist and artist setlists
fix: return JSON when error happens
- Loading branch information
1 parent
32135f4
commit b0b026c
Showing
47 changed files
with
808 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
api/src/main/java/xyz/arnau/setlisttoplaylist/config/BasicErrorController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package xyz.arnau.setlisttoplaylist.config; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController; | ||
import org.springframework.boot.web.servlet.error.ErrorAttributes; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import java.util.Map; | ||
|
||
import static org.springframework.boot.web.error.ErrorAttributeOptions.Include.MESSAGE; | ||
import static org.springframework.boot.web.error.ErrorAttributeOptions.of; | ||
|
||
@Controller | ||
@RequestMapping("${server.error.path:${error.path:/error}}") | ||
public class BasicErrorController extends AbstractErrorController { | ||
public BasicErrorController(ErrorAttributes errorAttributes) { | ||
super(errorAttributes); | ||
} | ||
|
||
@RequestMapping | ||
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) { | ||
Map<String, Object> body = getErrorAttributes(request, of(MESSAGE)); | ||
HttpStatus status = getStatus(request); | ||
return new ResponseEntity<>(body, status); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...oplaylist/infrastructure/CacheConfig.java → ...setlisttoplaylist/config/CacheConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
@Builder | ||
public record Artist( | ||
String id, | ||
String musicPlatformId, | ||
String name, | ||
String imageUrl | ||
|
13 changes: 13 additions & 0 deletions
13
api/src/main/java/xyz/arnau/setlisttoplaylist/domain/entities/BasicSetlist.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package xyz.arnau.setlisttoplaylist.domain.entities; | ||
|
||
import lombok.Builder; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Builder | ||
public record BasicSetlist( | ||
String id, | ||
LocalDate date, | ||
Venue venue, | ||
int numSongs | ||
) {} |
13 changes: 13 additions & 0 deletions
13
api/src/main/java/xyz/arnau/setlisttoplaylist/domain/entities/PagedList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package xyz.arnau.setlisttoplaylist.domain.entities; | ||
|
||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
@Builder | ||
public record PagedList<T>( | ||
List<T> items, | ||
int page, | ||
int totalItems, | ||
int itemsPerPage | ||
) {} |
9 changes: 9 additions & 0 deletions
9
api/src/main/java/xyz/arnau/setlisttoplaylist/domain/exceptions/ArtistNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package xyz.arnau.setlisttoplaylist.domain.exceptions; | ||
|
||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
import static org.springframework.http.HttpStatus.NOT_FOUND; | ||
|
||
@ResponseStatus(value = NOT_FOUND, reason = "Artist not found") | ||
public class ArtistNotFoundException extends RuntimeException { | ||
} |
11 changes: 11 additions & 0 deletions
11
...n/java/xyz/arnau/setlisttoplaylist/domain/exceptions/ArtistSetlistsNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package xyz.arnau.setlisttoplaylist.domain.exceptions; | ||
|
||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
import static org.springframework.http.HttpStatus.NOT_FOUND; | ||
|
||
@ResponseStatus(value = NOT_FOUND, reason = "Artist setlists not found") | ||
@ResponseBody | ||
public class ArtistSetlistsNotFoundException extends RuntimeException { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
api/src/main/java/xyz/arnau/setlisttoplaylist/domain/ports/SetlistRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
package xyz.arnau.setlisttoplaylist.domain.ports; | ||
|
||
import xyz.arnau.setlisttoplaylist.domain.entities.BasicSetlist; | ||
import xyz.arnau.setlisttoplaylist.domain.entities.PagedList; | ||
import xyz.arnau.setlisttoplaylist.domain.entities.Setlist; | ||
|
||
import java.util.Optional; | ||
|
||
public interface SetlistRepository { | ||
Optional<Setlist> getSetlist(String setlistId); | ||
|
||
Optional<PagedList<BasicSetlist>> getArtistSetlists(String artistId, int page); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...yz/arnau/setlisttoplaylist/infrastructure/controller/response/ArtistSetlistsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package xyz.arnau.setlisttoplaylist.infrastructure.controller.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
@Schema(requiredProperties = {"setlists", "page", "totalItems", "itemsPerPage"}) | ||
@Builder | ||
public record ArtistSetlistsResponse( | ||
@Schema(description = "Artist setlists") | ||
List<BasicSetlistResponse> setlists, | ||
@Schema(description = "Page number", example = "1") | ||
int page, | ||
@Schema(description = "Total number of setlists for the artist", example = "56") | ||
int totalItems, | ||
@Schema(description = "Number of items per page", example = "20") | ||
int itemsPerPage | ||
) { | ||
} |
17 changes: 17 additions & 0 deletions
17
.../xyz/arnau/setlisttoplaylist/infrastructure/controller/response/BasicSetlistResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package xyz.arnau.setlisttoplaylist.infrastructure.controller.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Schema(requiredProperties = {"id", "date", "venue", "numSongs"}) | ||
public record BasicSetlistResponse( | ||
@Schema(description = "Setlist ID", example = "6bbf4e1e") | ||
String id, | ||
@Schema(description = "Setlist date") | ||
LocalDate date, | ||
VenueResponse venue, | ||
@Schema(description = "Number of songs", example = "23") | ||
int numSongs | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.