package com.sikey.wa04.business.domain.usecase;

import org.springframework.stereotype.Component;

import java.util.Random;

/**
 * 验证码校验
 */
@Component
public class SMSCodeVerifier {
    private final static int SMS_CODE_LENGTH = 4;

    public boolean verify(String phoneNumber, String code) {
        return false;
    }

    /**
     * 生成验证码
     *
     * @return 验证码
     */
    public String generation() {
        StringBuilder sb = new StringBuilder();
        Random random = new Random();

        for (int i = 0; i < SMS_CODE_LENGTH; i++) {
            sb.append(random.nextInt(9));
        }

        return sb.toString();
    }
}
