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

import lombok.Getter;

@Getter
public enum ContentPlatformAccountTypeEnum {
    PARTNER(1, "合作方"),
    INTERNAL(2, "内部账号"),
    AGENT(3, "代理商"),

    other(999, "其他");

    private final int val;
    private final String description;

    ContentPlatformAccountTypeEnum(int val, String description) {
        this.val = val;
        this.description = description;
    }

    public static ContentPlatformAccountTypeEnum from(int val) {
        for (ContentPlatformAccountTypeEnum typeEnum : ContentPlatformAccountTypeEnum.values()) {
            if (typeEnum.getVal() == val) {
                return typeEnum;
            }
        }
        return other;
    }

    /** 搜索入口仅对自营/代理类型账号放开 */
    public boolean allowSearch() {
        return this == INTERNAL || this == AGENT;
    }
}
