package com.seer.teach.common.enums;

/**
 * 提供商枚举类
 */
public enum ProviderEnum {

    WECHAT("wechat", "微信"),
    ALIPAY("alipay", "支付宝"),
    LOCAL("local", "本地");

    private final String code;
    private final String description;

    ProviderEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据code获取对应的枚举值
     * @param code 状态码
     * @return 对应的枚举，如果不存在则返回null
     */
    public static ProviderEnum fromCode(String code) {
        for (ProviderEnum provider : ProviderEnum.values()) {
            if (provider.getCode().equals(code)) {
                return provider;
            }
        }
        return null;
    }
}