| | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.CaptchaType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | |
| | | */ |
| | | @ApiOperation("生成验证码") |
| | | @GetMapping("/captchaImage") |
| | | public AjaxResult<Map<String, Object>> getCode() { |
| | | public R<Map<String, Object>> getCode() { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | boolean captchaOnOff = configService.selectCaptchaOnOff(); |
| | | ajax.put("captchaOnOff", captchaOnOff); |
| | | if (!captchaOnOff) { |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | // 保存验证码信息 |
| | | String uuid = IdUtil.simpleUUID(); |
| | |
| | | RedisUtils.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES); |
| | | ajax.put("uuid", uuid); |
| | | ajax.put("img", captcha.getImageBase64()); |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | |
| | | private String getCodeResult(String capStr) { |