|
@@ -2,7 +2,6 @@ package cc.iotkit.web.controller;
|
|
|
|
|
|
import cc.iotkit.common.constant.Constants;
|
|
|
import cc.iotkit.common.constant.GlobalConstants;
|
|
|
-import cc.iotkit.common.exception.BizException;
|
|
|
import cc.iotkit.common.redis.utils.RedisUtils;
|
|
|
import cc.iotkit.common.utils.ReflectUtils;
|
|
|
import cc.iotkit.common.utils.SpringUtils;
|
|
@@ -14,13 +13,10 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
|
|
import cn.hutool.captcha.AbstractCaptcha;
|
|
|
import cn.hutool.captcha.generator.CodeGenerator;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
-import cn.hutool.core.util.RandomUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import jakarta.validation.constraints.NotBlank;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-
|
|
|
import org.springframework.expression.Expression;
|
|
|
import org.springframework.expression.ExpressionParser;
|
|
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
|
@@ -29,8 +25,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.time.Duration;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 验证码操作处理
|
|
@@ -46,56 +40,6 @@ import java.util.Map;
|
|
|
public class CaptchaController {
|
|
|
|
|
|
private final CaptchaProperties captchaProperties;
|
|
|
-// private final SmsProperties smsProperties;
|
|
|
-// private final MailProperties mailProperties;
|
|
|
-
|
|
|
- /**
|
|
|
- * 短信验证码
|
|
|
- *
|
|
|
- * @param phonenumber 用户手机号
|
|
|
- */
|
|
|
-// @PostMapping("/resource/sms/code")
|
|
|
-// public void smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
|
|
|
-// if (!smsProperties.getEnabled()) {
|
|
|
-// throw new BizException("当前系统没有开启短信功能!");
|
|
|
-// }
|
|
|
-// String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber;
|
|
|
-// String code = RandomUtil.randomNumbers(4);
|
|
|
-// RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
|
|
-// // 验证码模板id 自行处理 (查数据库或写死均可)
|
|
|
-// String templateId = "";
|
|
|
-// Map<String, String> map = new HashMap<>(1);
|
|
|
-// map.put("code", code);
|
|
|
-// SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
|
|
|
-// SmsResult result = smsTemplate.send(phonenumber, templateId, map);
|
|
|
-// if (!result.isSuccess()) {
|
|
|
-// log.error("验证码短信发送异常 => {}", result);
|
|
|
-// throw new RuntimeException("验证码短信发送异常");
|
|
|
-// }
|
|
|
-// return ;
|
|
|
-// }
|
|
|
-
|
|
|
- /**
|
|
|
- * 邮箱验证码
|
|
|
- *
|
|
|
- * @param email 邮箱
|
|
|
- */
|
|
|
-// @PostMapping("/resource/email/code")
|
|
|
-// public void emailCode(@NotBlank(message = "{user.email.not.blank}") String email) {
|
|
|
-// if (!mailProperties.getEnabled()) {
|
|
|
-// throw new BizException("当前系统没有开启邮件功能!"));
|
|
|
-// }
|
|
|
-// String key = GlobalConstants.CAPTCHA_CODE_KEY + email;
|
|
|
-// String code = RandomUtil.randomNumbers(4);
|
|
|
-// RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
|
|
-// try {
|
|
|
-// MailUtils.sendText(email, "登录验证码", "您本次验证码为:" + code + ",有效性为" + Constants.CAPTCHA_EXPIRATION + "分钟,请尽快填写。");
|
|
|
-// } catch (Exception e) {
|
|
|
-// log.error("验证码短信发送异常 => {}", e.getMessage());
|
|
|
-// throw new RuntimeException("验证码短信发送异常");
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
|
|
|
/**
|
|
|
* 生成验证码
|