Commit c2cf1a20 authored by Ina Curdt's avatar Ina Curdt
Browse files

SI-557, 558 Adress-Services

parent 6e8f9037
......@@ -65,7 +65,7 @@ public class AddressController {
}
//@Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
@ApiOperation(value = "Anzeige Strassen nach Postleitzahl und Ort")
@ApiOperation(value = "Anzeige Strassen nach Postleitzahl und Ort und Ortsteil (optional)")
@ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
@GetMapping("/streets")
public List<String> findStreets(
......@@ -77,6 +77,19 @@ public class AddressController {
}
//@Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
@ApiOperation(value = "Anzeige Strassen nach Postleitzahl und Ort und Strasse")
@ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
@GetMapping("/housenumbers")
public List<String> findHousenumbers(
@RequestParam ("postcode") String postcode,
@RequestParam ("community") String community,
@RequestParam ("street") String street
) {
return addressService.getHousenumbers(postcode, community, street);
}
......
......@@ -41,15 +41,13 @@ public interface AddressRepository extends JpaRepository<TblAddress, Long > {
@Query("select distinct a.district from TblAddress a where postcode = :postcode and community = :community")
List<String> findDistrictsByPostcodeAndCommunity(@Param("postcode") String postcode, @Param("community") String community);
@Query("select distinct a.district from TblAddress a where postcode = :postcode")
List<String> findDistrictsByPostcode(@Param("postcode") String postcode);
@Query("select distinct a.district from TblAddress a where community = :community")
List<String> findDistrictsByCommunity(@Param("community") String community);
@Query("select distinct a.district from TblAddress a")
List<String> findAllDistricts();
@Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community")
List<String> findStreetsByPostcodeAndCommunity(@Param("postcode") String postcode, @Param("community") String community);
@Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community and district = :district")
List<String> findStreetsByPostcodeAndCommunityAndDistrict(@Param("postcode") String postcode, @Param("community") String community, @Param("district") String district);
@Query("select distinct a.housenumber from TblAddress a where postcode = :postcode and community = :community and street = :street")
List<String> findHousenumbersByPostcodeAndCommunityAndStreet(@Param("postcode") String postcode, @Param("community") String community, @Param("street") String street);
}
......@@ -53,7 +53,18 @@ public class AddressService {
}
public List<String> getStreets(String postcode, String community, Optional<String> district) {
return addressRepository.findDistrictsByPostcodeAndCommunity(postcode, community);
if(district.equals(Optional.empty())){
return addressRepository.findStreetsByPostcodeAndCommunity(postcode, community);
}
else{
return addressRepository.findStreetsByPostcodeAndCommunityAndDistrict(postcode, community, district.get());
}
}
public List<String> getHousenumbers(String postcode, String community, String street) {
return addressRepository.findHousenumbersByPostcodeAndCommunityAndStreet(postcode, community, street);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment