package cn.com.ctop.kuaishou.modules.live.enums;

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

/**
 * 直播数据——广告报表 字段枚举，
 * 用于锁定EXCEL顺序不同时的字段与数据的对应关系
 */
public enum AdEnum {
    PARAMETER0("liveId", "直播id"),
    PARAMETER1("kuaishouName", "快手号"),
    PARAMETER2("liveStartTime", "直播开始时间"),
    PARAMETER3("liveEndTime", "直播结束时间"),
    PARAMETER4("liveDuration", "直播持续时间（分钟）"),
    PARAMETER5("anchorId", "主播id"),
    PARAMETER6("charge", "花费"),
    PARAMETER8("bclick", "行为数"),
    PARAMETER7("liveWatchAverageTime", "直播平均观看时长"),
    PARAMETER9("liveComments", "直播间评论数"),
    PARAMETER10("liveShares", "直播间分享数"),
    PARAMETER11("liveGifts", "直播间送礼数"),
    PARAMETER12("liveFans", "涨粉数"),
    PARAMETER13("liveFansCost", "涨粉成本"),
    PARAMETER14("liveWatchCount", "直播观看数"),
    PARAMETER15("liveOrderCount", "直接订单数"),
    PARAMETER16("liveGmv", "直接GMV"),
    PARAMETER17("liveRoi", "直接ROI");

    private String code;
    private String name;

    AdEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getCodeByName(String name) {
        for (AdEnum material : AdEnum.values()) {
            if (material.getName().equals(name)) {
                return material.getCode();
            }
        }
        return "";
    }

    public static String getNameByCode(String code) {
        for (AdEnum material : AdEnum.values()) {
            if (material.getCode().equals(code)) {
                return material.getName();
            }
        }
        return "";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String toString() {
        return "MaterialEnum{" +
                "code='" + code + '\'' +
                ", name=" + name +
                '}';
    }

    public static Map<String, String> getMap() {
        Map<String, String> map = new HashMap<>();
        for (AdEnum material : AdEnum.values()) {
            map.put(material.getName(), material.getCode());
        }
        return map;
    }
}
