package org.xyzh.common.core.enums;

/**
 * @description    验证码类型
 * @filename    CaptchaType.java
 * @author    yslg
 * @copyright yslg
 * @since 2025-11-03
 */
public enum CaptchaType {

    EMAIL(1, "EMAIL", "邮箱验证码"),
    SMS(2, "SMS", "短信验证码"),
    IMAGE(3, "IMAGE", "图形验证码");

    /**
     * 验证码类型编码
     */
    private int code;

     /**
     * 验证码类型名称
     */
    private String name;

     /**
     * 验证码类型描述
     */
    private String description;

    private CaptchaType(int code, String name, String description) {
        this.code = code;
        this.name = name;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    /**
     * @description    根据名称获取验证码类型
     * @param    name 验证码类型名称
     * @return    验证码类型
     * @author    yslg
     * @since 2025-11-03
     */
    public static CaptchaType fromName(String name) {
        for (CaptchaType type : CaptchaType.values()) {
            if (type.getName().equalsIgnoreCase(name)) {
                return type;
            }
        }
        return null;
    }
    
}
