package com.ytpm.advertise.enums;

import lombok.Getter;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * taku 聚合广告平台枚举
 */
@Getter
public enum AdPlatformTypeEnum {
    TENCENT(8, "腾讯广告"),
    CSJ(15, "穿山甲"),
    BAIDU(22, "百度联盟"),
    KUAI_SHOU(28, "快手"),
    SIGMOB(29, "Sigmob"),
    HUAWEI(39, "华为广告"),
    GROMORE(46, "gromore"),
    MI_UION(49, "米盟"),
    ADX(66, "TakuADX"),
    JAN(72, "京媒平台"),
    QM(74, "趣盟"),
    VIVO(79, "VIVO广告联盟"),
    OPPO(80, "OPPO广告联盟"),
    XIAOMI(81, "小米Columbus"),
    TANX(82, "阿里妈妈"),
    AD_MATE_X(93, "美数AdMateX"),
    IQIYI(94, "爱奇艺联盟"),
    BEI_ZI(95, "倍孜"),
    ADINTL(96, "章鱼广告"),
    ;
    private final int code;
    private final String desc;

    private static final Map<Integer, String> CODE_TO_DESC;

    static {
        // 初始化映射表，仅执行一次（类加载阶段）
        Map<Integer, String> tempMap = new HashMap<>(values().length);
        for (AdPlatformTypeEnum type : values()) {
            tempMap.put(type.code, type.desc);
        }
        // 转为不可变集合，防止意外修改，同时提升读性能
        CODE_TO_DESC = Collections.unmodifiableMap(tempMap);
    }

    AdPlatformTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getDesc(int code) {
        return CODE_TO_DESC.getOrDefault(code, "");
    }
}
