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

import lombok.Getter;

import java.util.Objects;

@Getter
public enum ExternalChannelStatusEnum {

    PENDING(0, "待处理"),
    PROCESSED(1, "已处理"),
    FAILED(2, "处理失败"),
    UNKNOWN_CHANNEL(3, "未知渠道"),

    other(999, "其他");

    private final Integer val;
    private final String description;

    ExternalChannelStatusEnum(Integer val, String description) {
        this.val = val;
        this.description = description;
    }

    public static ExternalChannelStatusEnum from(Integer val) {
        for (ExternalChannelStatusEnum statusEnum : ExternalChannelStatusEnum.values()) {
            if (Objects.equals(statusEnum.getVal(), val)) {
                return statusEnum;
            }
        }
        return other;
    }

}
