package com.cpop.oam.framework.enums;

import com.cpop.common.utils.StringUtils;

/**
 * 系统配置枚举
 * @author DB
 */
public enum OamConfigEnum {

    /**
     * 任务审核员工手机号
     */
    AUDIT_STAFF_PHONE("任务审核员工手机号", "OamAuditStaffPhone", "auditStaffPhone", true),
    /**
     * 核销管理员手机号
     */
    CANCEL_AFTER_VERIFICATION_STAFF_PHONE("核销管理员手机号", "OamCancelAfterVerificationStaffPhone",
        "cancelAfterVerificationStaffPhone", true),
    /**
     * 测试员工手机号
     */
    TEST_STAFF_PHONE("测试员工手机号", "TestStaffPhone", "testStaffPhone", true),
    /**
    * 需求转任务主体品牌
    */
    DEMAND_TO_TASK_BRAND("需求转任务主体品牌", "DemandToTaskBrand", "oamDemandToTaskBrand", true),
    /**
     * 需求转任务主体校区
     */
    DEMAND_TO_TASK_STORE("需求转任务主体校区", "DemandToTaskStore", "oamDemandToTaskStore", true),

    /**
     * 跟进间隔
     */
    FOLLOW_UP_INTERVAL("跟进间隔", "FollowUpInterval", "followUpInterval", true),

    /**
     * 签约间隔
     */
    SIGN_INTERVAL("签约间隔", "SignInterval", "signInterval", true),
    ;

    /**
     * 配置名
     */
    private final String name;

    /**
     * 配置键
     */
    private final String key;

    /**
     * 属性
     */
    private final String field;

    /**
     * 配置类型(是否系统内置)
     */
    private final Boolean type;

    OamConfigEnum(String name, String key, String field, Boolean type) {
        this.name = name;
        this.key = key;
        this.field = field;
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public String getKey() {
        return key;
    }

    public String getField() {
        return field;
    }

    public Boolean getType() {
        return type;
    }

    /**
     * 根据属性获取枚举
     * @param field 属性
     * @return OamConfigEnum
     */
    public static OamConfigEnum matchField(String field) {
        OamConfigEnum oamConfigEnum = null;
        for (OamConfigEnum configEnum : values()) {
            if (StringUtils.equals(configEnum.getField(), field)) {
                oamConfigEnum = configEnum;
                break;
            }
        }
        return oamConfigEnum;
    }

    /**
     * 根据键获取枚举
     * @param key 属性
     * @return OamConfigEnum
     */
    public static OamConfigEnum matchKey(String key) {
        OamConfigEnum oamConfigEnum = null;
        for (OamConfigEnum configEnum : values()) {
            if (StringUtils.equals(configEnum.getKey(), key)) {
                oamConfigEnum = configEnum;
                break;
            }
        }
        return oamConfigEnum;
    }
}
