From ffe4413db421aabb7446007ff76d4e9943c6fc84 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期五, 24 四月 2026 14:53:14 +0800
Subject: [PATCH] 删除废弃文件上传接口
---
src/main/java/com/ruoyi/project/common/CaptchaController.java | 46 +++++++++++++++++++++++++++++-----------------
1 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/src/main/java/com/ruoyi/project/common/CaptchaController.java b/src/main/java/com/ruoyi/project/common/CaptchaController.java
index 1e4933b..40255cb 100644
--- a/src/main/java/com/ruoyi/project/common/CaptchaController.java
+++ b/src/main/java/com/ruoyi/project/common/CaptchaController.java
@@ -1,22 +1,25 @@
package com.ruoyi.project.common;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-import javax.annotation.Resource;
-import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletResponse;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.google.code.kaptcha.Producer;
+import com.ruoyi.common.constant.CacheConstants;
+import com.ruoyi.common.constant.Constants;
+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.project.system.service.ISysConfigService;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.FastByteArrayOutputStream;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
-import com.google.code.kaptcha.Producer;
-import com.ruoyi.common.constant.Constants;
-import com.ruoyi.common.utils.IdUtils;
-import com.ruoyi.common.utils.sign.Base64;
-import com.ruoyi.framework.redis.RedisCache;
-import com.ruoyi.framework.web.domain.AjaxResult;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
/**
* 楠岃瘉鐮佹搷浣滃鐞�
@@ -24,6 +27,7 @@
* @author ruoyi
*/
@RestController
+@RequiredArgsConstructor
public class CaptchaController
{
@Resource(name = "captchaProducer")
@@ -32,12 +36,13 @@
@Resource(name = "captchaProducerMath")
private Producer captchaProducerMath;
- @Autowired
- private RedisCache redisCache;
+ private final RedisCache redisCache;
// 楠岃瘉鐮佺被鍨�
@Value("${ruoyi.captchaType}")
private String captchaType;
+
+ private final ISysConfigService configService;
/**
* 鐢熸垚楠岃瘉鐮�
@@ -45,9 +50,17 @@
@GetMapping("/captchaImage")
public AjaxResult getCode(HttpServletResponse response) throws IOException
{
+ AjaxResult ajax = AjaxResult.success();
+ boolean captchaEnabled = configService.selectCaptchaEnabled();
+ ajax.put("captchaEnabled", captchaEnabled);
+ if (!captchaEnabled)
+ {
+ return ajax;
+ }
+
// 淇濆瓨楠岃瘉鐮佷俊鎭�
String uuid = IdUtils.simpleUUID();
- String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
+ String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
String capStr = null, code = null;
BufferedImage image = null;
@@ -78,7 +91,6 @@
return AjaxResult.error(e.getMessage());
}
- AjaxResult ajax = AjaxResult.success();
ajax.put("uuid", uuid);
ajax.put("img", Base64.encode(os.toByteArray()));
return ajax;
--
Gitblit v1.9.3