-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: null pointer bugfix: missed email verified and createdDate in edit enterprise user bugfix: missed i18n sidebar bugfix: no buildings found
- Loading branch information
1 parent
132e385
commit 85ae143
Showing
34 changed files
with
423 additions
and
139 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...terprise/src/main/java/greenbuildings/enterprise/adapters/geocoding/GeocodingAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package greenbuildings.enterprise.adapters.geocoding; | ||
|
||
import greenbuildings.enterprise.dtos.AddressSuggestionDTO; | ||
import lombok.RequiredArgsConstructor; | ||
import org.apache.commons.text.StringSubstitutor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
import java.util.Map; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class GeocodingAdapter { | ||
|
||
private final RestTemplate restTemplate; | ||
private final GeocodingMapper mapper; | ||
|
||
@Value("${geocoding.key}") | ||
private String key; | ||
|
||
@Value("${geocoding.url}") | ||
private String url; | ||
|
||
public AddressSuggestionDTO reverse(double latitude, double longitude) { | ||
var requestUrl = StringSubstitutor | ||
.replace("${url}?lat=${lat}&lon=${lon}&api_key=${key}", | ||
Map.of("url", this.url, | ||
"lat", latitude, | ||
"lon", longitude, | ||
"key", key)); | ||
var response = restTemplate.getForObject(requestUrl, GeocodingReverseResponse.class); | ||
return mapper.toAddressSuggestion(response); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...terprise/src/main/java/greenbuildings/enterprise/adapters/geocoding/GeocodingAddress.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package greenbuildings.enterprise.adapters.geocoding; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* This DTO is intended for internal use within the adapter and should not be used outside of it. | ||
*/ | ||
public record GeocodingAddress( | ||
String road, | ||
String quarter, | ||
String suburb, | ||
String city, | ||
String postcode, | ||
String country, | ||
@JsonProperty("country_code") String countryCode | ||
) { | ||
} |
20 changes: 20 additions & 0 deletions
20
...nterprise/src/main/java/greenbuildings/enterprise/adapters/geocoding/GeocodingMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package greenbuildings.enterprise.adapters.geocoding; | ||
|
||
import greenbuildings.enterprise.dtos.AddressSuggestionDTO; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.mapstruct.MappingConstants; | ||
import org.mapstruct.ReportingPolicy; | ||
|
||
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, componentModel = MappingConstants.ComponentModel.SPRING) | ||
public interface GeocodingMapper { | ||
|
||
@Mapping(target = "city", source = "address.city") | ||
@Mapping(target = "road", source = "address.road") | ||
@Mapping(target = "quarter", source = "address.quarter") | ||
@Mapping(target = "suburb", source = "address.suburb") | ||
@Mapping(target = "postcode", source = "address.postcode") | ||
@Mapping(target = "country", source = "address.country") | ||
@Mapping(target = "countryCode", source = "address.countryCode") | ||
AddressSuggestionDTO toAddressSuggestion(GeocodingReverseResponse response); | ||
} |
14 changes: 14 additions & 0 deletions
14
.../src/main/java/greenbuildings/enterprise/adapters/geocoding/GeocodingReverseResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package greenbuildings.enterprise.adapters.geocoding; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* This DTO is intended for internal use within the adapter and should not be used outside of it. | ||
*/ | ||
public record GeocodingReverseResponse( | ||
String lat, | ||
String lon, | ||
@JsonProperty("display_name") String displayName, | ||
GeocodingAddress address | ||
) { | ||
} |
13 changes: 13 additions & 0 deletions
13
sep490-enterprise/src/main/java/greenbuildings/enterprise/dtos/AddressSuggestionDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package greenbuildings.enterprise.dtos; | ||
|
||
public record AddressSuggestionDTO( | ||
String displayName, | ||
String road, | ||
String quarter, | ||
String suburb, | ||
String city, | ||
String postcode, | ||
String country, | ||
String countryCode | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
sep490-enterprise/src/main/java/greenbuildings/enterprise/rest/GeocodingResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package greenbuildings.enterprise.rest; | ||
|
||
import greenbuildings.enterprise.adapters.geocoding.GeocodingAdapter; | ||
import greenbuildings.enterprise.dtos.AddressSuggestionDTO; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/geocoding") | ||
@RequiredArgsConstructor | ||
public class GeocodingResource { | ||
private final GeocodingAdapter geocodingAdapter; | ||
|
||
@GetMapping("/reverse") | ||
public ResponseEntity<AddressSuggestionDTO> reverse(@RequestParam @NotNull Double latitude, | ||
@RequestParam @NotNull Double longitude) { | ||
return ResponseEntity.ok(geocodingAdapter.reverse(latitude, longitude)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
sep490-enterprise/src/main/resources/db/migration/V0.0.1.10__BuildingAddress.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE buildings | ||
ADD address VARCHAR(255) NOT NULL DEFAULT ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.