package com.cf.imes.module.system.enums.sms;

import cn.hutool.core.util.ArrayUtil;
import com.cf.imes.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 用户短信验证码发送场景的枚举
 *
 * @author 晨丰科技
 */
@Getter
@AllArgsConstructor
public enum SmsSceneEnum implements IntArrayValuable {

    USER_UPDATE_MOBILE(1, "user-update-mobile", "修改手机"),
    USER_RESET_PASSWORD(2, "user-reset-password", "忘记密码"),
    USER_UPDATE_PASSWORD(3, "user-update-password", "修改密码"),
    USER_LOGIN_CAPTCHAVERIFICATION(4, "user-login-captchaverification", "登录验证码"),
    ADMIN_LOGIN(20, "admin-sms-login", "后台用户 - 手机号登录"),
    ADMIN_MEMBER_LOGIN(21, "admin-sms-login", "后台用户 - 手机号登录"),
    MEMBER_LOGIN(22, "user-sms-login", "会员用户 - 手机号登陆");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(SmsSceneEnum::getScene).toArray();

    /**
     * 验证场景的编号
     */
    private final Integer scene;
    /**
     * 模版编码
     */
    private final String templateCode;
    /**
     * 描述
     */
    private final String description;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static SmsSceneEnum getCodeByScene(Integer scene) {
        return ArrayUtil.firstMatch(sceneEnum -> sceneEnum.getScene().equals(scene),
                values());
    }

}
