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 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 service
      searchService - the search service
      userService - the user service
      spotifyService - 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 user
      artistId - the artist's ID - must not be null.
      Returns:
      the artist's response DTO, or a NotFoundException if 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 user
      artistId - 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 NotFoundException if 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 user
      artistId - 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 NotFoundException if 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 NotFoundException if 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 user
      artistId - the artist's ID
      contribution - 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 user
      artistId - the artist's ID
      contribution - 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 user
      artistId - the artist's ID
      contribution - 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 user
      page - 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 user
      artistId - the artist's ID
      page - the pagination options
      Returns:
      a list of events associated with the artist (can be an empty list), or a NotFoundException if 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 user
      query - 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