Package org.localify.city
Class CityController
java.lang.Object
org.localify.city.CityController
@RestController
@RequestMapping("/v1/cities")
@ConditionalOnWebApplication
public class CityController
extends Object
Controller for handling city-related requests.
-
Constructor Summary
ConstructorsConstructorDescriptionCityController(CityService cityService, SearchService searchService, UserService userService) Constructs a new CityController. -
Method Summary
Modifier and TypeMethodDescriptioncitySearch(UserDetailsImpl user, @Valid SearchQuery query) Searches for a city by name and returns a list of cities that match.voiddeleteCity(@NotNull UUID cityId) Deletes a city by ID.org.springframework.data.domain.Page<City.CityArtistApiResponse>getArtistsForCity(@NotNull UUID cityId, @Valid PageOptions page, UserDetailsImpl user) Gets the artists for a city.getCityArtistProportions(@Valid PageOptions page) Gets the city-artist proportions.getCityArtistProportionsByCreation(@Valid PageOptions page) Gets the city-artist proportions, ordered by creation date.getCityById(UserDetailsImpl user, @NotNull UUID cityId) Finds a city by IDorg.springframework.data.domain.Page<EventResponseExtendedLocal>getEventsForCity(@NotNull UUID cityId, @Valid PageOptions page, UserDetailsImpl user) Gets the events for a city.getNearestUserCity(@Valid PointContainer query) Gets the nearest cities to a given point.getNearestUserCity(jakarta.servlet.http.HttpServletRequest request, String query) Gets the relevant cities for the user, based on their location.getPlaylist(UUID cityId) Gets or creates a playlist for a city.org.springframework.data.domain.Page<VenueEventNumResponse>getVenuesForCity(@NotNull UUID cityId, @Valid PageOptions page) Gets the venues for a city.patchCity(@NotNull UUID cityId, @Valid CityPatchRequest request) Patches (updates) a city.
-
Constructor Details
-
CityController
public CityController(CityService cityService, SearchService searchService, UserService userService) Constructs a new CityController.- Parameters:
cityService- The city service.searchService- The search service.userService- The user service.
-
-
Method Details
-
getCityById
@GetMapping(value="/{cityId}", produces="application/json") @ResponseBody public CityArtistsResponse getCityById(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable @NotNull @NotNull UUID cityId) Finds a city by ID- Parameters:
user- The authenticated user.cityId- the city ID- Returns:
- the city DTO
-
patchCity
@PatchMapping("/{cityId}") @ResponseBody public CityResponse patchCity(@PathVariable @NotNull @NotNull UUID cityId, @RequestBody @Valid @Valid CityPatchRequest request) Patches (updates) a city.- Parameters:
cityId- the ID to updaterequest- the payload body- Returns:
- The updated city.
-
deleteCity
@DeleteMapping("/{cityId}") @ResponseStatus(NO_CONTENT) public void deleteCity(@PathVariable @NotNull @NotNull UUID cityId) Deletes a city by ID. Requires admin permissions.- Parameters:
cityId- the city ID
-
getEventsForCity
@GetMapping(value="/{cityId}/events", produces="application/json") @ResponseBody public org.springframework.data.domain.Page<EventResponseExtendedLocal> getEventsForCity(@PathVariable @NotNull @NotNull UUID cityId, @Valid @Valid PageOptions page, @AuthenticationPrincipal UserDetailsImpl user) Gets the events for a city.- Parameters:
cityId- the city IDpage- the page optionsuser- The authenticated user.- Returns:
- a page of events for the city
-
getArtistsForCity
@GetMapping(value="/{cityId}/artists", produces="application/json") @ResponseBody public org.springframework.data.domain.Page<City.CityArtistApiResponse> getArtistsForCity(@PathVariable @NotNull @NotNull UUID cityId, @Valid @Valid PageOptions page, @AuthenticationPrincipal UserDetailsImpl user) Gets the artists for a city.- Parameters:
cityId- the city IDpage- the page optionsuser- The authenticated user.- Returns:
- a page of artists for the city
-
getVenuesForCity
@GetMapping(value="/{cityId}/venues", produces="application/json") @ResponseBody public org.springframework.data.domain.Page<VenueEventNumResponse> getVenuesForCity(@PathVariable @NotNull @NotNull UUID cityId, @Valid @Valid PageOptions page) Gets the venues for a city.- Parameters:
cityId- the city IDpage- the page options- Returns:
- a page of venues for the city
-
getNearestUserCity
@GetMapping(value="/relevant", produces="application/json") @ResponseBody public List<CityResponse> getNearestUserCity(jakarta.servlet.http.HttpServletRequest request, String query) Gets the relevant cities for the user, based on their location.- Parameters:
request- the HTTP requestquery- the search query- Returns:
- a list of relevant cities to the user
-
getNearestUserCity
@GetMapping(value="/nearest", produces="application/json") @ResponseBody public List<CityResponse> getNearestUserCity(@Valid @Valid PointContainer query) Gets the nearest cities to a given point.- Parameters:
query- the point container- Returns:
- a list of nearest cities to the user
-
citySearch
@GetMapping(value="/search", produces="application/json") @ResponseBody public List<CityResponse> citySearch(@AuthenticationPrincipal UserDetailsImpl user, @Valid @Valid SearchQuery query) Searches for a city by name and returns a list of cities that match.
Usage:/v1/cities/search?q=ithaca&limit=3- Parameters:
user- The authenticated user.query- the pojo containing the query string and (optionally), the "limit" count.- Returns:
- the list of cities
-
getPlaylist
@PostMapping(value="/{cityId}/playlist", produces="application/json") @ResponseBody public PlaylistDto getPlaylist(@PathVariable UUID cityId) Gets or creates a playlist for a city.- Parameters:
cityId- the city ID- Returns:
- the playlist DTO
-
getCityArtistProportions
@GetMapping(value="/city-artist-proportions", produces="application/json") @ResponseBody public List<CityArtistProportionResponse> getCityArtistProportions(@Valid @Valid PageOptions page) Gets the city-artist proportions.- Parameters:
page- The page options.- Returns:
- A list of city-artist proportion responses.
-
getCityArtistProportionsByCreation
@GetMapping(value="/city-artist-proportions/user-ordered", produces="application/json") @ResponseBody public List<CityArtistProportionResponse> getCityArtistProportionsByCreation(@Valid @Valid PageOptions page) Gets the city-artist proportions, ordered by creation date.- Parameters:
page- The page options.- Returns:
- A list of city-artist proportion responses.
-