Переглянути джерело

api 百度地图AK改为用户提供的

limingming 1 рік тому
батько
коміт
19a9b1140a

+ 3 - 1
rouyi-api/src/main/resources/application.yml

@@ -159,4 +159,6 @@ aliyun:
     #短信模板
     templateCode: SMS_283430418
 
-
+#百度逆地理转换
+baidu:
+  AK: ItMxrFXSvbyKKbAsxPCfO2jwqvfWyaBh

+ 18 - 0
ruoyi-common/src/main/java/com/ruoyi/common/config/BaiduProperties.java

@@ -0,0 +1,18 @@
+package com.ruoyi.common.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author liming
+ * @date 2023/08/02
+ */
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "baidu")
+public class BaiduProperties {
+
+    private String AK;
+
+}

+ 7 - 1
ruoyi-common/src/main/java/com/ruoyi/common/core/baiduMap/SearchHttpAK.java

@@ -1,6 +1,8 @@
 
 package com.ruoyi.common.core.baiduMap;
 
+import com.ruoyi.common.config.BaiduProperties;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.util.UriUtils;
 
@@ -16,15 +18,19 @@ import java.util.Map;
  */
 @Component
 public class SearchHttpAK {
+    @Autowired
+    private BaiduProperties baiduProperties;
 
     public static String URL = "https://api.map.baidu.com/reverse_geocoding/v3?";
 
-    public static String AK = "bkclPNKHhZfdCXNoNVpvrFkYVVdvrzBG";
+//    public static String AK = "bkclPNKHhZfdCXNoNVpvrFkYVVdvrzBG";
+
 
     public String convertIp (String latitudeAndLongitude) throws Exception {
 
         SearchHttpAK snCal = new SearchHttpAK();
 
+        String AK = baiduProperties.getAK();
         Map<String, String> params = new LinkedHashMap<>();
         params.put("ak", AK);
         params.put("output", "json");