| | |
| | | import com.ruoyi.common.utils.sign.Base64;
|
| | | import com.ruoyi.common.utils.uuid.IdUtils;
|
| | | import com.ruoyi.framework.redis.RedisCache;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.project.system.service.ISysConfigService;
|
| | | import jakarta.annotation.Resource;
|
| | | import jakarta.servlet.http.HttpServletResponse;
|
| | |
| | | import javax.imageio.ImageIO;
|
| | | import java.awt.image.BufferedImage;
|
| | | import java.io.IOException;
|
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit;
|
| | |
|
| | | /**
|
| | |
| | | * 生成验证码
|
| | | */
|
| | | @GetMapping("/captchaImage")
|
| | | public AjaxResult getCode(HttpServletResponse response) throws IOException
|
| | | public R<?> getCode(HttpServletResponse response) throws IOException |
| | | {
|
| | | AjaxResult ajax = AjaxResult.success();
|
| | | Map<String, Object> map = new HashMap<>(); |
| | | boolean captchaEnabled = configService.selectCaptchaEnabled();
|
| | | ajax.put("captchaEnabled", captchaEnabled);
|
| | | map.put("captchaEnabled", captchaEnabled); |
| | | if (!captchaEnabled)
|
| | | {
|
| | | return ajax;
|
| | | return R.ok(map); |
| | | }
|
| | |
|
| | | // 保存验证码信息
|
| | |
| | | }
|
| | | catch (IOException e)
|
| | | {
|
| | | return AjaxResult.error(e.getMessage());
|
| | | return R.fail(e.getMessage()); |
| | | }
|
| | |
|
| | | ajax.put("uuid", uuid);
|
| | | ajax.put("img", Base64.encode(os.toByteArray()));
|
| | | return ajax;
|
| | | map.put("uuid", uuid); |
| | | map.put("img", Base64.encode(os.toByteArray())); |
| | | return R.ok(map); |
| | | }
|
| | | }
|