高德行政区接入
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user