|
@@ -40,14 +40,15 @@ public class MapConfigController {
|
|
|
|
|
|
@PostMapping("/geocode")
|
|
@PostMapping("/geocode")
|
|
public ResultData geocode(@RequestBody MapParam param){
|
|
public ResultData geocode(@RequestBody MapParam param){
|
|
- if(param.getMapId() == null || StringUtils.isBlank(param.getAddress())){
|
|
|
|
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
|
- }
|
|
|
|
- MapConfig mapConfig = mapConfigService.getById(param.getMapId());
|
|
|
|
- if(mapConfig == null || mapConfig.getGeocodeUrl() == null){
|
|
|
|
- throw new BusinessException(ResultCode.RECORD_NOT_EXIST);
|
|
|
|
- }
|
|
|
|
try {
|
|
try {
|
|
|
|
+ if(param.getMapId() == null || StringUtils.isBlank(param.getAddress())){
|
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
|
+ }
|
|
|
|
+ MapConfig mapConfig = mapConfigService.getById(param.getMapId());
|
|
|
|
+ if(mapConfig == null || mapConfig.getGeocodeUrl() == null){
|
|
|
|
+ throw new BusinessException(ResultCode.RECORD_NOT_EXIST);
|
|
|
|
+ }
|
|
|
|
+
|
|
String url = mapConfig.getGeocodeUrl().replace("{address}",param.getAddress());
|
|
String url = mapConfig.getGeocodeUrl().replace("{address}",param.getAddress());
|
|
String s = HttpUtil.get(url);
|
|
String s = HttpUtil.get(url);
|
|
JSONObject jsonObject = JSON.parseObject(s);
|
|
JSONObject jsonObject = JSON.parseObject(s);
|