| | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import com.ruoyi.common.annotation.Anonymous; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.CaptchaType; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Anonymous |
| | | @Slf4j |
| | | @Validated |
| | | @Api(value = "验证码操作处理", tags = {"验证码管理"}) |
| | |
| | | if (smsProperties.getEnabled()) { |
| | | R.fail("当前系统没有开启短信功能!"); |
| | | } |
| | | String key = Constants.CAPTCHA_CODE_KEY + phonenumber; |
| | | String key = CacheConstants.CAPTCHA_CODE_KEY + phonenumber; |
| | | String code = RandomUtil.randomNumbers(4); |
| | | RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION)); |
| | | // 验证码模板id 自行处理 (查数据库或写死均可) |
| | |
| | | } |
| | | // 保存验证码信息 |
| | | String uuid = IdUtil.simpleUUID(); |
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; |
| | | String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid; |
| | | // 生成验证码 |
| | | CaptchaType captchaType = captchaProperties.getType(); |
| | | boolean isMath = CaptchaType.MATH == captchaType; |