package com.njzscloud.common.security.module.wechat.mini;

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;
import lombok.ToString;
import lombok.experimental.Accessors;

@Getter
@Setter
@ToString
@Accessors(chain = true)
public class WechatMiniLoginForm extends LoginForm {
    /**
     * 验证码
     */
    private String code;
    private String openid;
    private String unionid;

    public WechatMiniLoginForm() {
        super(AuthWay.WECHAT_MINI);
    }

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

    @Override
    public ValidRule[] rules() {
        return new ValidRule[]{
            ValidRule.of(() -> StrUtil.isNotBlank(code), "微信验证码不能为空"),
        };
    }
}
