package com.njzscloud.common.security.module.code;

import cn.hutool.core.util.StrUtil;
import com.njzscloud.common.mvc.validator.ValidRule;
import com.njzscloud.common.security.contant.AuthWay;
import com.njzscloud.common.security.support.LoginForm;
import lombok.Getter;
import lombok.Setter;

/**
 * 登录参数
 */
@Getter
@Setter
public class CodeLoginForm extends LoginForm {
    /**
     * 手机号
     */
    private String phone;

    /**
     * 验证码
     */
    private String code;

    /**
     * 获取验证码时使用的 uid
     */
    private String codeId;

    public CodeLoginForm() {
        super(AuthWay.PHONE);
    }

    @Override
    public String getName() {
        return phone;
    }

    @Override
    public ValidRule[] rules() {
        return new ValidRule[]{
            ValidRule.of(() -> StrUtil.isNotBlank(phone), "手机号不能为空"),
            ValidRule.of(() -> StrUtil.isNotBlank(code), "验证码不能为空"),
            ValidRule.of(() -> StrUtil.isNotBlank(codeId), "验证码标识不能为空"),
        };
    }
}
