mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-01-26 11:51:55 +08:00
[feat] 非生产环境不再实际下发短信验证码
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ruoyi.gateway.service.impl;
|
|||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -9,6 +10,7 @@ import javax.imageio.ImageIO;
|
|||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.ujcms.commons.sms.AliyunUtils;
|
import com.ujcms.commons.sms.AliyunUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.FastByteArrayOutputStream;
|
import org.springframework.util.FastByteArrayOutputStream;
|
||||||
import com.google.code.kaptcha.Producer;
|
import com.google.code.kaptcha.Producer;
|
||||||
@@ -49,6 +51,9 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CaptchaProperties.SMS.Aliyuncs smsAliyuncs;
|
private CaptchaProperties.SMS.Aliyuncs smsAliyuncs;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成验证码
|
* 生成验证码
|
||||||
*/
|
*/
|
||||||
@@ -124,6 +129,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
|||||||
String code = captchaProducerNumber.createText();
|
String code = captchaProducerNumber.createText();
|
||||||
redisService.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
redisService.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
||||||
expire = redisService.getExpire(verifyKey);
|
expire = redisService.getExpire(verifyKey);
|
||||||
|
if (Arrays.stream(environment.getActiveProfiles()).toList().contains("prod")) {
|
||||||
AliyunUtils.sendSms(
|
AliyunUtils.sendSms(
|
||||||
smsAliyuncs.getAccessKeyId(),
|
smsAliyuncs.getAccessKeyId(),
|
||||||
smsAliyuncs.getAccessKeySecret(),
|
smsAliyuncs.getAccessKeySecret(),
|
||||||
@@ -132,6 +138,9 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
|||||||
JSONObject.of("code", code),
|
JSONObject.of("code", code),
|
||||||
receiver
|
receiver
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
ajax.put("captchaCode",code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ajax.put("expire", expire);
|
ajax.put("expire", expire);
|
||||||
ajax.put("uuid", uuid);
|
ajax.put("uuid", uuid);
|
||||||
|
|||||||
Reference in New Issue
Block a user