package com.tzld.piaoquan.api.common.enums.contentplatform;

import lombok.Getter;

import java.util.EnumSet;
import java.util.Set;

/**
 * 需求渠道枚举,对应 content_platform_demand_video.channel_name
 */
@Getter
public enum DemandChannelEnum {

    QW("群/企微合作-稳定"),
    XCX("小程序投流-稳定"),
    GZH_TOULIU("公众号投流-稳定"),
    GZH_JIZHUAN("公众号合作-即转-稳定"),
    GZH_DAILY("公众号合作-Daily-自选");

    /** 搜索入口白名单 */
    public static final Set<DemandChannelEnum> SEARCH_ALLOWED = EnumSet.of(XCX, GZH_TOULIU);

    /** 合作类渠道: crowd_segment 语义=合作方代码,可用 user.channel 过滤 */
    public static final Set<DemandChannelEnum> PARTNER_CROWD = EnumSet.of(QW, GZH_JIZHUAN, GZH_DAILY);

    private final String value;

    DemandChannelEnum(String value) {
        this.value = value;
    }

    /** 字符串反查枚举,未匹配返回 null */
    public static DemandChannelEnum fromValue(String value) {
        if (value == null) return null;
        for (DemandChannelEnum c : values()) {
            if (c.value.equals(value)) return c;
        }
        return null;
    }

    public boolean isPartner() {
        return PARTNER_CROWD.contains(this);
    }

    public boolean allowSearch() {
        return SEARCH_ALLOWED.contains(this);
    }
}
