lyhzzz 6 дней назад
Родитель
Сommit
a681d7a9fb

+ 8 - 7
src/main/java/com/fdkankan/fusion/controller/MapConfigController.java

@@ -40,14 +40,15 @@ public class MapConfigController {
 
     @PostMapping("/geocode")
     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 {
+            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 s = HttpUtil.get(url);
             JSONObject jsonObject = JSON.parseObject(s);