| | |
| | | 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.R; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | 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 R<?> getCode(HttpServletResponse response) throws IOException |
| | | public AjaxResult getCode(HttpServletResponse response) throws IOException |
| | | { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | boolean captchaEnabled = configService.selectCaptchaEnabled(); |
| | | map.put("captchaEnabled", captchaEnabled); |
| | | ajax.put("captchaEnabled", captchaEnabled); |
| | | if (!captchaEnabled) |
| | | { |
| | | return R.ok(map); |
| | | return ajax; |
| | | } |
| | | |
| | | // 保存验证码信息 |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | return R.fail(e.getMessage()); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | map.put("uuid", uuid); |
| | | map.put("img", Base64.encode(os.toByteArray())); |
| | | return R.ok(map); |
| | | ajax.put("uuid", uuid); |
| | | ajax.put("img", Base64.encode(os.toByteArray())); |
| | | return ajax; |
| | | } |
| | | } |