package com.skyversation.poiaddr.util;

import com.skyversation.poiaddr.entity.ProxyItem;
import com.skyversation.poiaddr.entity.UserRecord;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Constant {

    public static Constant instance = new Constant();

    private Constant(){};

    public static Constant getInstance(){
        if(instance == null)
            instance = new Constant();
        if(instance.defaultToken.size() < 1)
            instance.initData();
        return instance;
    }

    /**
     * 外部amap地理/逆地理搜索
     * */
    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_DRIVING = "https://restapi.amap.com/v5/direction/driving";
    public static String AMAP_DRIVING = "https://restapi.amap.com/v3/direction/driving";
    /**
     * amap经纬度误差
     * */
    public static double AMAP_LAT_WUCHA = -0.001853;
    public static double AMAP_LON_WUCHA = 0.004624;


    public List<String> defaultToken = new ArrayList<>();
    public Map<String, UserRecord> defaultTokenMap = new HashMap<>();
    public Map<String, String> dicMap = new HashMap<>();

    public Map<String, ProxyItem> requestMap = new HashMap<>();

    public Map<String, String> proxyMap = new HashMap<>();
    public Map<String, String> proxyMODEL = new HashMap<>();
    public Map<String, String> proxyGLTF = new HashMap<>();
    public Map<String, String> proxyDATA = new HashMap<>();
    public Map<String, String> proxyUNKNOWN = new HashMap<>();
//    public static String OAUTH_URL = "http://122.228.28.40:10096/oauth/api/user/getUserByToken";

    public static String OAUTH_URL = "http://121.43.55.7:10086/oauth/api/user/getUserByToken";
    public static String SEARCH_BY_NAME_URL = "http://121.43.55.7:10011/proxy/searchByName?address=";
    public static String SEARCH_BY_NAME_V3_URL = "http://121.43.55.7:10011/proxy/searchByNameV3?address=";
    public static String AMAP_DRIVING_URL = "http://121.43.55.7:10011/proxy/driving?key=";
    public static String TDT_IMAGE_URL = "http://121.43.55.7:10011/proxy/tdt_image?key=";
    public static String OAUTH_URL_GETUSER = "http://121.43.55.7:10086/oauth/api/user/getUserByToken";
    public static String OAUTH_GET_USER_BY_TOKEN = "http://121.43.55.7:10086/oauth/api/user/getUserByToken";
    public static String OAUTH_PY_URL = "http://121.43.55.7:10086/oauth/py/validateToken";
    public static String OAUTH_RECORD_URL = "http://127.0.0.1:10086/oauth/record/addRecord";
    public static String DMS_URL_UPDATE = "http://121.43.55.7:";
//    public static String OAUTH_URL = "http://127.0.0.1:10096/oauth/api/user/getUserByToken";

    public static String OAUTH_LOGIN_URL = "http://121.43.55.7:8888/oauth/api/user/login";
    public static final String TOKEN = "token";
    public static final String STRURL = "strUrl";
    public static final String SERVICEID = "serviceId";

    /** 网络请求返回值 **/
    public final static int SUCCESS = 200;
    /** 参数错误 **/
    public final static int PARAM_ERROR = -1;
    /** 服务端错误 **/
    public final static int SERVER_ERROR = 500;
    /** 无权限 **/
    public final static int NO_PERMISSION = 201;
    /** 数据错误，无数据 **/
    public final static int NO_DATA = 202;
    /** 内部错误 **/
    public final static int INTER_ERROR = 203;
    /** 数据库错误 **/
    public final static int DATABASE_ERROR = 204;
    /** 数据为空 **/
    public final static int NULL_DATA = 205;
    /** 用户过期 **/
    public final static int USER_FAILURE = 206;
    /** 用户失效 **/
    public final static int USER_ARCHIVED = 207;
    /** 无token **/
    public final static int NO_TOKEN = 208;
    /** 无效token **/
    public final static int FAILURE_TOKEN = 212;
    /** 没有注册此服务 **/
    public final static int NO_SERVICE = 213;
    /** ip验证不通过 **/
    public final static int IP_NOT_PASS = 314;
    /** 事项验证不通过 **/
    public final static int MATTER_NOT_PASS = 315;
    /** 经纬度格式错误 **/
    public final static int LAT_LON_ERROR = 316;


    /** JWT ACCESS 密钥加密 **/
    public final static String JWT_ACCESS_PRIVATE_KEY = "SKYVERSATION-ACCESS";
    /** JWT REFRESH 密钥加密 **/
    public final static String JWT_REFRESH_PRIVATE_KEY = "SKYVERSATION-REFRESH";

    /** access token 有效时间 **/
    public final static long ACCESS_TOKEN_TIME = 1000 * 60 * 60 * 16;
    public void initData(){
        defaultToken.add("65463DEE-620A-0ED5-2385-17ECD07CD351");
        defaultToken.add("C651EBF8-5728-4F2F-1C1F-52A9F1BDC889");
        defaultToken.add("079B1D50-DE99-AF49-FF56-DCB95D3E3147");
        defaultToken.add("C4BCA7C6-DF66-4A7D-2931-A258DFEFF8AB");
        defaultToken.add("CFC5CEB8-755F-0916-899C-4CD578F323CC");
        defaultToken.add("DF45046F-AE7B-50B3-C084-FECDE82CEE32");
        defaultToken.add("1472624D-EBC3-8B49-F1A2-B21446925D48");
        defaultToken.add("1C73AFA8-3567-E2CC-048D-6ECAB6DD58D6");
        defaultToken.add("40DC31DD-2FA7-F6D1-5197-D5B9A3E823EE");
        defaultToken.add("622067E9-93E5-D8EC-E677-85B58A63C0C7");// 750 专用token

        UserRecord userF750 = new UserRecord();
        userF750.setUserId(999999);
        userF750.setAccessToken("622067E9-93E5-D8EC-E677-85B58A63C0C7");
        userF750.setContent("750项目专用 转发服务");
        userF750.setUserName("750项目转发服务");
        userF750.setServiceOrigin("750");
        defaultTokenMap.put("622067E9-93E5-D8EC-E677-85B58A63C0C7", userF750);
        UserRecord userFNB = new UserRecord();
        userFNB.setUserId(999998);
        userFNB.setAccessToken("65463DEE-620A-0ED5-2385-17ECD07CD351");
        userFNB.setContent("内部人员专用token");
        userFNB.setUserName("内部人员专用token");
        userFNB.setServiceOrigin("neibu");
        defaultTokenMap.put("65463DEE-620A-0ED5-2385-17ECD07CD351", userFNB);

//        dicMap.put("NatGeo_World_Map" ,"https://server.arcgisonline.com/arcgis/rest/services/NatGeo_World_Map/MapServer");
//        dicMap.put("USA_Topo_Maps" ,"https://server.arcgisonline.com/arcgis/rest/services/USA_Topo_Maps/MapServer");
//        dicMap.put("World_Imagery" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer");
//        dicMap.put("World_Physical_Map" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer");
//        dicMap.put("World_Shaded_Relief" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Shaded_Relief/MapServer");
//        dicMap.put("World_Terrain_Base" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer");
//        dicMap.put("World_Street_Map" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer");
//        dicMap.put("World_Topo_Map" ,"https://server.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer");
//        dicMap.put("3DModel" ,"http://122.228.13.28:1009/3DTiles/qp/QPXZFWZX/JJ");

    }


}