高德行政区接入
This commit is contained in:
@@ -37,7 +37,7 @@ public class LoginFilter implements Filter {
|
||||
"css/**",
|
||||
"js/**",
|
||||
"cashierService/phoneValidateCode",//验证码
|
||||
"cashierService/tbPlatformDict",//
|
||||
"cashierService/location/**",//
|
||||
"cashierService/home/homePageUp",//首页上半
|
||||
"cashierService/home",//首页
|
||||
"cashierService/login/**"//登录部分接口不校验
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.LocationUtils;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/location")
|
||||
public class LocationController {
|
||||
|
||||
|
||||
/**
|
||||
* 行政区域查询
|
||||
*
|
||||
* @param keywords citycode市、adcode区
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/district")
|
||||
public Result createOrder(String keywords) throws JsonProcessingException {
|
||||
String district = LocationUtils.district(keywords);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
// 将 JSON 字符串解析为 JsonNode 对象
|
||||
JsonNode jsonNode = mapper.readTree(district);
|
||||
JsonNode districts = jsonNode.get("districts");
|
||||
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS, districts);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,24 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.lang.Math.*;
|
||||
import static java.lang.Math.sin;
|
||||
|
||||
public class LocationUtils {
|
||||
|
||||
public static String district(String keywords) {
|
||||
Map<String, String> param=new HashMap<>();
|
||||
//超掌柜生活-用户端
|
||||
param.put("key","7a7f2e4790ea222660a027352ee3af39");
|
||||
param.put("keywords",keywords);
|
||||
param.put("subdistrict","1");
|
||||
param.put("extensions","base");
|
||||
String s = HttpClientUtil.doGet("https://restapi.amap.com/v3/config/district", param);
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将角度转化为弧度
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user