package com.crm.rely.backend.core.enums;

/**
 * 组别类型
 *
 * @author y
 * @create 2022/1/21
 */
public enum CustomGroupType {

    CLASSIC(1L, "CLASSIC"),
    VIP(2L, "VIP"),
    ORG(3L, "ORG"),
    PRO(4L, "PRO"),
    INSTANT(5L, "INSTANT"),

    NEW_INSTANT(6L, "INSTANT"),

    STANDARD(7L, "STANDARD"),

    CENT(8L, "CENT");


    private final Long code;
    private final String desc;

    CustomGroupType(Long code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Long getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static CustomGroupType matchCode(Long code) {
        for (CustomGroupType type : CustomGroupType.values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        return null;
    }

    public static Boolean exists(Long code, String desc) {
        CustomGroupType customGroupType = matchCode(code);
        if (customGroupType == null){
            return false;
        }

        if (customGroupType.getDesc().equals(desc)){
            return true;
        }else {
            return false;
        }

    }


}
