package cn.huge.module.kind.controller.client; import cn.huge.base.common.utils.ObjectUtils; import cn.huge.base.common.utils.ReturnFailUtils; import cn.huge.base.common.utils.ReturnSucUtils; import cn.huge.module.kind.domain.po.SyRegion; import cn.huge.module.kind.service.SyRegionService; import cn.huge.module.sys.dto.QueAddrBaseDTO; import cn.huge.module.utils.BaiduMapAddrDTO; import cn.huge.module.utils.BaiduMapUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; /** * @title: 地域表接口api-web端 * @description: 地域表接口api-web端 * @company: hugeinfo * @author: wangwh * @time: 2024-09-04 16:48:57 * @version: 1.0.0 */ @Slf4j @RestController @RequestMapping("/api/client/syRegion") public class SyregionClientController { @Autowired(required = false) private HttpServletRequest request; @Autowired private SyRegionService service; /** * 根据百度地图经纬度获取街道 * @url {ctx}/api/client/syRegion/getQueAddrByBaiduiLngLat * @param lng 经度 * @param lat 维度 * @return */ @GetMapping("/getQueAddrByBaiduiLngLat") public Object getQueAddrByBaiduiLngLat(@RequestParam(value = "lng") String lng, @RequestParam(value = "lat") String lat) { try { QueAddrBaseDTO syRegionBaseDTO = new QueAddrBaseDTO(); BaiduMapAddrDTO baiduMapAddrDTO = BaiduMapUtils.getAddrByLngLat(lng, lat, BaiduMapUtils.coordtype_bd09ll); if (ObjectUtils.isNotEmpty(baiduMapAddrDTO)) { QueryWrapper syRegionQueryWrapper = new QueryWrapper<>(); // 查询省 syRegionQueryWrapper.eq("name", baiduMapAddrDTO.getProvince()); SyRegion province = service.getOne(syRegionQueryWrapper); syRegionBaseDTO.setQueProv(province.getId()); syRegionBaseDTO.setQueProvName(province.getName()); // 查询市 syRegionQueryWrapper.eq("name", baiduMapAddrDTO.getCity()); SyRegion city = service.getOne(syRegionQueryWrapper); syRegionBaseDTO.setQueProv(city.getId()); syRegionBaseDTO.setQueProvName(city.getName()); // 查询区 syRegionQueryWrapper.eq("name", baiduMapAddrDTO.getDistrict()); SyRegion district = service.getOne(syRegionQueryWrapper); syRegionBaseDTO.setQueProv(district.getId()); syRegionBaseDTO.setQueProvName(district.getName()); // 查询街道 syRegionQueryWrapper.eq("name", baiduMapAddrDTO.getTown()); SyRegion town = service.getOne(syRegionQueryWrapper); syRegionBaseDTO.setQueProv(town.getId()); syRegionBaseDTO.setQueProvName(town.getName()); } return ReturnSucUtils.getRepInfo(syRegionBaseDTO); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } }