package com.bonus.auth.config;

import com.fasterxml.jackson.annotation.JsonCreator;

/**
 * @author bonus
 */

public enum VerificationCodeType {
    /**
     * 登录
     */
    LOGIN,
    /**
     * 注册
     */
    REGISTER;

    @JsonCreator
    public static VerificationCodeType fromString(String key) {
        if (key == null) {
            return null;
        }

        // 自定义转换逻辑，允许大小写不敏感的匹配
        for (VerificationCodeType type : VerificationCodeType.values()) {
            if (type.name().equalsIgnoreCase(key)) {
                return type;
            }
        }
        // throw new ServiceException("不支持的登录方式");
        return null;
    }
}
