package com.gic.haoban.manage.api.enums.contact;

import org.apache.commons.lang3.StringUtils;

public enum ContactFollowTypeEnum {

    PRIVATE_PHONE(1, "私人电话","私人电话"),
    WECHAT_SESSION(2, "企微会话","企微会话"),
    PRODUCT(3, "发送商品","商品"),
    WECHAT_GROUP_SEND(4, "企微群发","企微群发"),
    CONTACT(5, "标记建联","标记了建联"),
    AUTO_CONTACT(6, "系统自动标记","系统自动标记"),
    MATERIAL(7, "营销素材","营销素材");

    private final int code;
    private final String description;
    private final String textMatch;

    ContactFollowTypeEnum(int code, String description,String textMatch) {
        this.code = code;
        this.description = description;
        this.textMatch = textMatch;
    }

    public String getTextMatch() {
        return textMatch;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static ContactFollowTypeEnum fromCode(int code) {
        for (ContactFollowTypeEnum type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        return null;
    }

    public static ContactFollowTypeEnum fromTextMatch(String textMatch) {
        if (StringUtils.isBlank(textMatch)) {
            return null;
        }
        for (ContactFollowTypeEnum type : values()) {
            if (textMatch.contains(type.textMatch)) {
                return type;
            }
        }
        return null;
    }
}