package com.sifang.modules.smallprogram;

import com.sifang.modules.customer.utils.GaodeUtil;
import com.sifang.modules.sunshine.SystemSetting.utils.Result;

import com.sifang.modules.sys.web.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value="${adminPath}/main/address")
public class SmallProgramAddressController extends BaseController {

    Logger logger= LoggerFactory.getLogger(getClass());

    /**
     * 根据地址获取经纬度  ***
     */
    @ResponseBody
    @RequestMapping(value="getAddressLonLat")
    public Result getAddressLonLat(String address){
        logger.info(">>>>>>>>>>>>getAddressLonLat  address:{}",address);
        Result result=new Result();
        String lonLat = GaodeUtil.getLonLat(address);
        logger.info(">>>>>>>>>>>>getAddressLonLat  lonLat:{}",lonLat);
        result.setOk();
        return result.data(lonLat);
    }

    /**
     * 根据经纬度 获取 地址 ***
     */
    @ResponseBody
    @RequestMapping(value = "getAddressByLonLat")
    public Result getAddressByLonLat(String lonLat){
        logger.info(">>>>>>>>>>>>getAddressByLonLat  lonLat:{}",lonLat);
        Result result=new Result();
        String address = GaodeUtil.getAddress(lonLat);
        logger.info(">>>>>>>>>>>>getAddressByLonLat  address:{}",address);
        result.setOk();
        return result.data(address);
    }
}
