Package org.localify.artist
Class ArtistController
java.lang.Object
org.localify.artist.ArtistController
@RestController
@RequestMapping("/v1/artists")
@ConditionalOnWebApplication
public class ArtistController
extends Object
Controller for handling artist-related requests.
This class defines the REST API endpoints for managing artists.
-
Constructor Summary
ConstructorsConstructorDescriptionArtistController(ArtistService artistService, SearchService searchService, UserService userService, SpotifyService spotifyService) Constructs a new ArtistController with the given services. -
Method Summary
Modifier and TypeMethodDescriptionvoidapproveArtistCityContribution(UserDetailsImpl user, UUID artistId, @Valid ArtistCityContribution contribution) Approves a city contribution for an artist.artistSearch(UserDetailsImpl user, @Valid SearchQuery query) Searches for artists.voidcontributeArtistCity(UserDetailsImpl user, UUID artistId, @Valid ArtistCityContribution contribution) Contributes a city to an artist.createArtistFromSpotify(String spotifyId) Creates an artist from a Spotify ID.createArtistFromSpotify(List<String> spotifyIds) Creates multiple artists from a list of Spotify IDs.voiddeleteArtist(UserDetailsImpl user, UUID artistId) Deletes an artist by ID.voiddenyArtistCityContribution(UserDetailsImpl user, UUID artistId, @Valid ArtistCityContribution contribution) Denies a city contribution for an artist.getApproveableArtistCityContributions(UserDetailsImpl user, @Valid PageOptions page) Gets the list of artist city contributions that can be approved.getArtistById(UserDetailsImpl user, UUID artistId) Gets an artist by ID.getArtistCities(UUID artistId) Gets the cities associated with an artist.getArtistEvents(UserDetailsImpl user, UUID artistId, @Valid PageOptions page) Gets the events associated with an artist.getArtistFestivals(UUID artistId) Gets the festivals associated with an artist.patchArtistById(UserDetailsImpl user, @NotNull UUID artistId, @Valid ArtistPatchRequest request) Patches an artist by ID.popularArtistsForGenres(List<String> genres) Gets the popular artists for the specified genres.
-
Constructor Details
-
ArtistController
@Autowired public ArtistController(ArtistService artistService, SearchService searchService, UserService userService, SpotifyService spotifyService) Constructs a new ArtistController with the given services.- Parameters:
artistService- the artist servicesearchService- the search serviceuserService- the user servicespotifyService- the spotify service
-
-
Method Details
-
getArtistById
@GetMapping(value="/{artistId}", produces="application/json") @ResponseBody public ExtendedArtistResponse getArtistById(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID artistId) Gets an artist by ID.- Parameters:
user- the authenticated userartistId- the artist's ID - must not be null.- Returns:
- the artist's response DTO, or a
NotFoundExceptionif no such id exists.
-
patchArtistById
@PatchMapping(value="/{artistId}", produces="application/json") @ResponseBody public BasicArtistResponse patchArtistById(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable @NotNull @NotNull UUID artistId, @RequestBody @Valid @Valid ArtistPatchRequest request) Patches an artist by ID. Requires admin permissions.- Parameters:
user- the authenticated userartistId- the artist's ID - must not be null.request- the request body containing the fields to patch- Returns:
- the artist's response DTO, or a
NotFoundExceptionif no such id exists.
-
deleteArtist
@DeleteMapping("/{artistId}") @ResponseStatus(NO_CONTENT) public void deleteArtist(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID artistId) Deletes an artist by ID. Requires admin permissions.- Parameters:
user- the authenticated userartistId- the artist ID
-
getArtistCities
@GetMapping(value="/{artistId}/cities", produces="application/json") @ResponseBody public List<ArtistCityResponse> getArtistCities(@PathVariable UUID artistId) Gets the cities associated with an artist.- Parameters:
artistId- the artist's ID- Returns:
- a list of cities associated with the artist (can be an empty list), or a
NotFoundExceptionif no such artist ID exists.
-
getArtistFestivals
@GetMapping(value="/{artistId}/festivals", produces="application/json") @ResponseBody public List<FestivalBasicResponse> getArtistFestivals(@PathVariable UUID artistId) Gets the festivals associated with an artist.- Parameters:
artistId- the artist's ID- Returns:
- a list of festivals associated with the artist (can be an empty list), or a
NotFoundExceptionif no such artist ID exists.
-
contributeArtistCity
@PostMapping(value="/{artistId}/cities", produces="application/json") @ResponseStatus(NO_CONTENT) public void contributeArtistCity(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID artistId, @RequestBody @Valid @Valid ArtistCityContribution contribution) Contributes a city to an artist. Requires user permissions.- Parameters:
user- the authenticated userartistId- the artist's IDcontribution- the contribution data
-
approveArtistCityContribution
@PostMapping(value="/{artistId}/cities/approve", produces="application/json") @ResponseStatus(NO_CONTENT) public void approveArtistCityContribution(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID artistId, @RequestBody @Valid @Valid ArtistCityContribution contribution) Approves a city contribution for an artist. Requires admin permissions.- Parameters:
user- the authenticated userartistId- the artist's IDcontribution- the contribution data
-
denyArtistCityContribution
@PostMapping(value="/{artistId}/cities/deny", produces="application/json") @ResponseStatus(NO_CONTENT) public void denyArtistCityContribution(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID artistId, @RequestBody @Valid @Valid ArtistCityContribution contribution) Denies a city contribution for an artist. Requires admin permissions.- Parameters:
user- the authenticated userartistId- the artist's IDcontribution- the contribution data
-
getApproveableArtistCityContributions
@GetMapping(value="/city-contributions", produces="application/json") @ResponseBody public List<ApproveableArtistCity> getApproveableArtistCityContributions(@AuthenticationPrincipal UserDetailsImpl user, @Valid @Valid PageOptions page) Gets the list of artist city contributions that can be approved. Requires admin permissions.- Parameters:
user- the authenticated userpage- the pagination options- Returns:
- a list of artist city contributions that can be approved
-
getArtistEvents
@GetMapping(value="/{artistId}/events", produces="application/json") @ResponseBody public ArtistEventListResponse getArtistEvents(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID artistId, @Valid @Valid PageOptions page) Gets the events associated with an artist.- Parameters:
user- the authenticated userartistId- the artist's IDpage- the pagination options- Returns:
- a list of events associated with the artist (can be an empty list), or a
NotFoundExceptionif no such artist ID exists.
-
artistSearch
@GetMapping(value="/search", produces="application/json") @ResponseBody public List<BasicArtistResponse> artistSearch(@AuthenticationPrincipal UserDetailsImpl user, @Valid @Valid SearchQuery query) Searches for artists. Requires user permissions.- Parameters:
user- the authenticated userquery- the search query- Returns:
- a list of artists that match the search query
-
popularArtistsForGenres
@GetMapping(value="/popular", produces="application/json") @ResponseBody public List<BasicArtistResponse> popularArtistsForGenres(@RequestParam("genres") List<String> genres) Gets the popular artists for the specified genres. Requires user permissions.- Parameters:
genres- a list of genre IDs- Returns:
- a list of popular artists for the specified genres
-
createArtistFromSpotify
@PostMapping(value="/add-spotify/{spotifyId}", produces="application/json") @ResponseBody public BasicArtistResponse createArtistFromSpotify(@PathVariable String spotifyId) Creates an artist from a Spotify ID. Requires admin permissions.- Parameters:
spotifyId- the Spotify ID of the artist to create- Returns:
- the created artist
-
createArtistFromSpotify
@PostMapping(value="/add-spotify", produces="application/json") @ResponseBody public List<BasicArtistResponse> createArtistFromSpotify(@RequestBody List<String> spotifyIds) Creates multiple artists from a list of Spotify IDs. Requires admin permissions.- Parameters:
spotifyIds- a list of Spotify IDs of the artists to create- Returns:
- a list of the created artists
-