ZQN
2024-06-22 b48de0e35c54bd4715f8de2b86bac5a539c27275
project-framework/src/main/java/com/project/framework/web/service/SysLoginService.java
@@ -114,6 +114,26 @@
        return tokenService.createToken(loginUser);
    }
    /**
     * 新注册获取验证码
     * @param phone 手机
     * @return  验证码
     */
    public Boolean getVerifyCodeNew(String phone) {
        // 生成4位随机数
        String code = "";
        Random ran = new Random();
        int randomNum = ran.nextInt(10000);
        code = String.format("%04d", randomNum);
        log.info("手机号:"+phone+"->验证码:"+code);
        boolean send = sendYp(phone, code);
        if (send){
            redisCache.setCacheObject(getCacheKey(phone), code, Constants.PHONE_EXPIRATION, TimeUnit.MINUTES);
            return true;
        }
        redisCache.setCacheObject(getCacheKey(phone), code, Constants.PHONE_EXPIRATION, TimeUnit.MINUTES);
        return false;
    }
    /**
     * 获取验证码
@@ -126,19 +146,7 @@
        if (user==null){
            throw new BaseException("您手机号尚未注册!");
        }
        // 生成4位随机数
        String code = "";
        Random ran = new Random();
        int randomNum = ran.nextInt(10000);
        code = String.format("%04d", randomNum);
        log.info("手机号:"+phone+"->验证码:"+code);
//        boolean send = sendAl(phone, code);
//        if (send){
//            redisCache.setCacheObject(getCacheKey(phone), code, Constants.PHONE_EXPIRATION, TimeUnit.MINUTES);
//            return true;
//        }
        redisCache.setCacheObject(getCacheKey(phone), code, Constants.PHONE_EXPIRATION, TimeUnit.MINUTES);
        return false;
        return getVerifyCodeNew(phone);
    }
    private boolean sendYp(String phone, String code ){
@@ -277,4 +285,6 @@
        return verify;
    }
}