package com.ruoyi.gateway.enhance.utils;

import lombok.extern.slf4j.Slf4j;

/**
 * 根据 IP获取地址
 *
 * @author MrBird
 */
@Slf4j
public class AddressUtil {

    public static String getCityInfo(String ip) {
        return "";
//        DbSearcher searcher = null;
//        try {
//            String dbPath = AddressUtil.class.getResource("/ip2region/ip2region.db").getPath();
//            File file = new File(dbPath);
//            if (!file.exists()) {
//                String tmpDir = System.getProperties().getProperty(FebsConstant.JAVA_TEMP_DIR);
//                dbPath = tmpDir + "ip.db";
//                file = new File(dbPath);
//                InputStream resourceAsStream = AddressUtil.class.getClassLoader().getResourceAsStream("classpath:ip2region/ip2region.db");
//                if (resourceAsStream != null) {
//                    FileUtils.copyInputStreamToFile(resourceAsStream, file);
//                }
//            }
//            DbConfig config = new DbConfig();
//            searcher = new DbSearcher(config, file.getPath());
//            Method method = searcher.getClass().getMethod("btreeSearch", String.class);
//            DataBlock dataBlock = (DataBlock) method.invoke(searcher, ip);
//            return dataBlock.getRegion();
//        } catch (Exception e) {
//            log.warn("获取地址信息异常,{}", e.getMessage());
//            return StringUtils.EMPTY;
//        } finally {
//            if (searcher != null) {
//                try {
//                    searcher.close();
//                } catch (IOException e) {
//                    e.printStackTrace();
//                }
//            }
//        }
    }
}