From 857453533db10dd66d981b847f870481a7bf4ad8 Mon Sep 17 00:00:00 2001 From: Arne Dumarey Date: Tue, 17 Dec 2024 15:13:13 +0100 Subject: [PATCH] feat(address): add parameters to search --- paket.dependencies | 4 +- paket.lock | 4 +- .../Address/Oslo/AddressController-Search.cs | 39 +++++++++++++++---- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/paket.dependencies b/paket.dependencies index 4b5f7fa6..f4d4eed2 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -24,8 +24,8 @@ nuget Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.Oslo 4.14.0 nuget Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.BackOffice.Abstractions 4.14.0 copy_content_to_output_dir: always nuget Be.Vlaanderen.Basisregisters.BuildingRegistry.Api.Oslo 4.19.1 copy_content_to_output_dir: always nuget Be.Vlaanderen.Basisregisters.BuildingRegistry.Api.BackOffice.Abstractions 4.19.1 copy_content_to_output_dir: always -nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo 4.27.2 copy_content_to_output_dir: always -nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions 4.27.2 copy_content_to_output_dir: always +nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo 4.29.4 copy_content_to_output_dir: always +nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions 4.29.4 copy_content_to_output_dir: always nuget Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Oslo 5.8.1 copy_content_to_output_dir: always nuget Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.BackOffice.Abstractions 5.8.1 copy_content_to_output_dir: always nuget Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice 4.7.0 copy_content_to_output_dir: always diff --git a/paket.lock b/paket.lock index 9d057876..19e0c962 100644 --- a/paket.lock +++ b/paket.lock @@ -42,10 +42,10 @@ NUGET System.Security.Cryptography.ProtectedData (>= 4.7) System.Text.Json (>= 4.7.2) System.Threading.Tasks.Extensions (>= 4.5.4) - Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions (4.27.2) - copy_content_to_output_dir: always + Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions (4.29.4) - copy_content_to_output_dir: always Be.Vlaanderen.Basisregisters.Api (>= 23.1) MediatR.Contracts (>= 2.0.1) - Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo (4.27.2) - copy_content_to_output_dir: always + Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo (4.29.4) - copy_content_to_output_dir: always Be.Vlaanderen.Basisregisters.GrAr.Legacy (>= 21.14.1) MediatR.Contracts (>= 2.0.1) Be.Vlaanderen.Basisregisters.AggregateSource (9.0.1) diff --git a/src/Public.Api/Address/Oslo/AddressController-Search.cs b/src/Public.Api/Address/Oslo/AddressController-Search.cs index ae5d1f57..ec43e5e7 100644 --- a/src/Public.Api/Address/Oslo/AddressController-Search.cs +++ b/src/Public.Api/Address/Oslo/AddressController-Search.cs @@ -1,5 +1,6 @@ namespace Public.Api.Address.Oslo { + using System; using System.Threading; using System.Threading.Tasks; using AddressRegistry.Api.Oslo.Address.Search; @@ -27,12 +28,16 @@ public partial class AddressOsloController /// Zoeken naar adressen of straatnamen via een query. /// /// De zoek query. - /// Limiteer de zoek query in een te zoeken gemeente- of postnaam (optioneel). + /// Filter op de gemeentenaam van de zoek query (exact) (optioneel). + /// Filter op de NIS-code van de zoek query (exact) (optioneel). /// Aantal instanties dat teruggegeven wordt. Maximaal kunnen er 50 worden teruggegeven. Wanneer limit niet wordt meegegeven dan default 10 instanties (optioneel). /// /// Filter op de status van het adres of de straatnaam (exact) (optioneel). \ /// `"voorgesteld"` `"inGebruik"` `"gehistoreerd"` `"afgekeurd"` /// + /// + /// Specifieer de gewenste resultaten (exact) (optioneel). \ + /// `"adressen"` `"straatnamen"` /// /// /// @@ -62,9 +67,11 @@ public partial class AddressOsloController [HttpGet("adressen/zoeken", Name = nameof(SearchAddresses))] public async Task SearchAddresses( [FromQuery(Name = "q")] string? query, - [FromQuery(Name="gemeenteOfPostNaam")] string? municipalityOrPostalName, + [FromQuery(Name="gemeenteNaam")] string? municipalityName, + [FromQuery(Name="niscode")] string? nisCode, [FromQuery] int? limit, [FromQuery] string? status, + [FromQuery(Name="resultaatType")] string? resultType, [FromServices] SearchAddressesToggle searchAddressesToggle, [FromServices] IActionContextAccessor actionContextAccessor, [FromServices] IOptions responseOptions, @@ -81,8 +88,10 @@ public async Task SearchAddresses( RestRequest BackendRequest() => CreateBackendListRequest( limit, query, - municipalityOrPostalName, - status); + municipalityName, + nisCode, + status, + resultType); var value = await GetFromBackendAsync( contentFormat.ContentType, @@ -96,14 +105,28 @@ RestRequest BackendRequest() => CreateBackendListRequest( private static RestRequest CreateBackendListRequest( int? limit, string? query, - string? municipalityOrPostalName, - string? status) + string? municipalityName, + string? nisCode, + string? status, + string? resultType) { + ResultType? resultTypeParsed = null; + if (string.Equals(resultType, "adressen", StringComparison.OrdinalIgnoreCase)) + { + resultTypeParsed = ResultType.Address; + } + else if (string.Equals(resultType, "straatnamen", StringComparison.OrdinalIgnoreCase)) + { + resultTypeParsed = ResultType.StreetName; + } + var filter = new AddressSearchFilter { Query = query, - MunicipalityOrPostalName = municipalityOrPostalName, - Status = status + MunicipalityName = municipalityName, + NisCode = nisCode, + Status = status, + ResultType = resultTypeParsed }; return new RestRequest("adressen/zoeken")