package com.cloud.host;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum PoolInfoEnum {

    CENTRAL_NODE("中心节点", "CIDC-CORE-00"),
    YUNNAN_KUNMING("云南-昆明", "CIDC-RP-04"),
    HUADONG_SUZHOU("华东-苏州", "CIDC-RP-25"),
    HUANAN_GUANGZHOU3("华南-广州3", "CIDC-RP-26"),
    XINAN_CHENGDU("西南-成都", "CIDC-RP-27"),
    HUAZHONG_ZHENGZHOU1("华中-郑州1", "CIDC-RP-28"),
    HUABEI_BEIJING3("华北-北京3", "CIDC-RP-29"),
    HUAZHONG_CHANGSHA2("华中-长沙2", "CIDC-RP-30"),
    HUADONG_JINAN("华东-济南", "CIDC-RP-31"),
    XIBEI_XIAN("西北-西安", "CIDC-RP-32"),
    HUADONG_SHANGHAI1("华东-上海1", "CIDC-RP-33"),
    XINAN_CHONGQING("西南-重庆", "CIDC-RP-34"),
    HUADONG_HANGZHOU("华东-杭州", "CIDC-RP-35"),
    TIANJIN_TIANJIN("天津-天津", "CIDC-RP-36"),
    JILIN_CHANGCHUN("吉林-长春", "CIDC-RP-37"),
    HUBEI_XIANGYANG("湖北-襄阳", "CIDC-RP-38"),
    JIANGXI_NANCHANG("江西-南昌", "CIDC-RP-39"),
    GANSU_LANZHOU("甘肃-兰州", "CIDC-RP-40"),
    SHANXI_TAIYUAN("山西-太原", "CIDC-RP-41"),
    LIAONING_SHENYANG("辽宁-沈阳", "CIDC-RP-42"),
    YUNNAN_KUNMING2("云南-昆明2", "CIDC-RP-43"),
    HEBEI_SHIJIAZHUANG("河北-石家庄", "CIDC-RP-44"),
    FUJIAN_XIAMEN("福建-厦门", "CIDC-RP-45"),
    GUANGXI_NANNING("广西-南宁", "CIDC-RP-46"),
    ANHUI_HUAINAN("安徽-淮南", "CIDC-RP-47"),
    HUABEI_HUHEHAOTE("华北-呼和浩特", "CIDC-RP-48"),
    XINAN_GUIYANG("西南-贵阳", "CIDC-RP-49"),
    HAINAN_HAIKOU("海南-海口", "CIDC-RP-53"),
    XINJIANG_CHANGJI("新疆-昌吉", "CIDC-RP-54"),
    HEILONGJIANG_HAERBIN("黑龙江-哈尔滨", "CIDC-RP-55"),
    NINGXIA_ZHONGWEI("宁夏-中卫", "CIDC-RP-60"),
    QINGHAI_HAIDONG("青海-海东", "CIDC-RP-61"),
    XIZANG_LASA("西藏-拉萨", "CIDC-RP-62"),
    GUANGXI_NANNING3("广西-南宁3", "CIDC-RP-65");

    private String poolName;
    private String poolId;

    /**
     * 通过poolId精准获取poolName
     *
     * @param poolId 池ID
     * @return poolName，如果未找到返回null
     */
    public static String getPoolNameByPoolId(String poolId) {
        return Stream.of(values())
                .filter(pool -> pool.getPoolId().equals(poolId))
                .map(PoolInfoEnum::getPoolName)
                .findFirst()
                .orElse(null);
    }

    /**
     * 通过城市名称匹配获取poolId
     *
     * @param cityName 城市名称
     * @return poolId，如果未找到返回null
     */
    public static String getPoolIdByCityName(String cityName) {
        return Stream.of(values())
                .filter(pool -> pool.getPoolName().contains(cityName))
                .map(PoolInfoEnum::getPoolId)
                .findFirst()
                .orElse(null);
    }
}
