package com.skyversation.poiaddr.addquery;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.sql.DriverManager;
import java.sql.SQLException;

@Service
public class Constant {
    public static Constant instance = new Constant();

    private Constant() {
    }

    public static Constant getInstance() {
        if (instance == null)
            instance = new Constant();
        return instance;
    }

    //    TODO 青浦区行政区划编码：310118 松江区行政区划编码：310117
    private String area;

    private String[] towns;

    @Value("${app.search_server_id}")
    private String searchServerId;

    //    TODO 服务器融合版地名地址接口
    public static String SJ_SZX_SEARCH_BY_NAME;

    public static void setTowns(String[] town) {
        getInstance().towns = town;
    }

    public static String[] getTowns() {
        return getInstance().towns;
    }

    public static void setArea(String area) {
        getInstance().area = area;
    }

    public static String getArea() {
        return getInstance().area;
    }

    public static String getAMAP_CITY_CODE() {
        return "青浦".equals(getArea()) ? "310118" : "310117";
    }

    public static final String WD_USER_NAME = "yuanyi";
    public static final String WD_USER_PWD = "yuanyi@123";
    public static final String GET_TOKEN_URL = "http://10.235.245.226:7010/addrMatch/auth/getToken";
    public static final String GET_ADDRESS_MEG_URL = "http://10.235.245.226:7010/addrMatch/addrApi/searchAddr";
    public static final String SZX_URL = "https://service-api.onemap.sh.gov.cn/data-service-manage-service/MapProxyApi/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBsaWNhdGlvbl9pZCI6NjEsImFwcGxpY2F0aW9uX25hbWUiOiLpnZLmtabkuozkuInnu7TmnI3liqHns7vnu58iLCJleHAiOjIwNDY2Nzg0MDN9.IKUMdjUX4U1jncIUNren-iotL7duXI90aLECMjpvUX8/address_search/MapServer?page_num=1&page_size=5";
//    TODO 服务器融合版地名地址接口
//    public static final String SJ_SZX_SEARCH_BY_NAME = "http://172.30.77.19:8081/openapi/1736930075105";
    //    TODO 关键字模糊搜索服务
//    public static final String SJ_SZX_SEARCH_BY_NAME2 = "http://172.30.77.19:8081/openapi/1742459783686";
    public static final String V4_URL = "http://10.235.245.174:10011/proxy/address/getAddressV4?token=65463DEE-620A-0ED5-2385-17ECD07CD351&address=";

    @PostConstruct
    public void initDbConnection() throws SQLException {
//      加载驱动
        System.out.println("加载搜索服务id！");
        SJ_SZX_SEARCH_BY_NAME = "http://172.30.77.20:8084/openapi/" + searchServerId;
        System.out.println("服务接口：" + SJ_SZX_SEARCH_BY_NAME);
    }

    public static String AMAP_GEO_URL = "https://restapi.amap.com/v3/geocode/geo";
    public static String AMAP_REGEO_URL = "https://restapi.amap.com/v3/geocode/regeo";
    public static String AMAP_SEARCH_NAME_V3 = "https://restapi.amap" +
            ".com/v3/place/text";
    public static String AMAP_SEARCH_TYPES = "010000|020000|030000|040000|050000|060000|070000|080000|090000" +
            "|100000|110000|120000|130000|140000|150000|160000|170000|180000|190000|200000|220000|970000|980000|990000";

    public static String AMAP_KEY = "161e0c673807a9586ba5a115da2a0112";

    //    oauth和dms搭建服务器地址
    public static String ServerBaseUrl = "http://121.43.55.7:";
    //    DMS服务端口和路径
    public static String Dms_Base_Url = ServerBaseUrl + "2101/proxy_dms";
    //    Oauth服务端口和路径
    public static String Oauth_Base_Url = ServerBaseUrl + "2101/proxy_oauth";

    //    Oauth登录接口（直接使用user001默认登录获取token）
    public static String Oauth_login_URL = Oauth_Base_Url + "/user/login?userName=user001&password=1234567890&clientId=2";

    //    DMS添加数据接口
    public static String DMS_addContent_URL = Dms_Base_Url + "/content/addContent";
    //    DMS修改数据接口
    public static String DMS_updateContent_URL = Dms_Base_Url + "/content/updateContent";
    //    DMS查询接口
    public static String DMS_selectContentList_URL = Dms_Base_Url + "/content/selectContentList";
}
