[feat] 非生产环境不再实际下发短信验证码
parent
de924c7ee0
commit
04adbe7d46
|
|
@ -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,14 +129,18 @@ 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);
|
||||||
AliyunUtils.sendSms(
|
if (Arrays.stream(environment.getActiveProfiles()).toList().contains("prod")) {
|
||||||
smsAliyuncs.getAccessKeyId(),
|
AliyunUtils.sendSms(
|
||||||
smsAliyuncs.getAccessKeySecret(),
|
smsAliyuncs.getAccessKeyId(),
|
||||||
smsAliyuncs.getSignName(),
|
smsAliyuncs.getAccessKeySecret(),
|
||||||
smsAliyuncs.getTemplateCode(),
|
smsAliyuncs.getSignName(),
|
||||||
JSONObject.of("code", code),
|
smsAliyuncs.getTemplateCode(),
|
||||||
receiver
|
JSONObject.of("code", code),
|
||||||
);
|
receiver
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ajax.put("captchaCode",code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ajax.put("expire", expire);
|
ajax.put("expire", expire);
|
||||||
ajax.put("uuid", uuid);
|
ajax.put("uuid", uuid);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue