From 664cae654867b528ea339f187ebe290cb04d6fcf Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期四, 27 八月 2026 18:41:21 +0800
Subject: [PATCH] docs: 关机前交接——运行状态、待验证项、外置配置要点
---
traffic-audit-server/src/main/java/com/trafficaudit/security/captcha/CaptchaController.java | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/security/captcha/CaptchaController.java b/traffic-audit-server/src/main/java/com/trafficaudit/security/captcha/CaptchaController.java
new file mode 100644
index 0000000..d034b87
--- /dev/null
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/security/captcha/CaptchaController.java
@@ -0,0 +1,51 @@
+package com.trafficaudit.security.captcha;
+
+import com.trafficaudit.common.Result;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api/auth")
+public class CaptchaController {
+
+ @Resource
+ private CaptchaService captchaService;
+
+ @GetMapping("/captcha")
+ public Result<Map<String, Object>> captcha() {
+ return Result.ok(captchaService.generate());
+ }
+
+ @PostMapping("/captcha/verify")
+ public Result<Map<String, Object>> verify(@RequestBody Map<String, Object> params) {
+ String captchaId = (String) params.get("captchaId");
+ List<String> clickIds = strList(params.get("captchaClickIds"));
+ CaptchaService.VerifyResult r = captchaService.verify(captchaId, clickIds);
+ switch (r) {
+ case OK:
+ return Result.ok(Collections.singletonMap("ok", true));
+ case WRONG:
+ return Result.error(4001, "鐐瑰嚮椤哄簭閿欒锛岃閲嶆柊鐐瑰嚮");
+ case RETRY_LIMIT:
+ return Result.error(4002, "閿欒娆℃暟杩囧锛屽凡鏇存崲棰樼洰");
+ default:
+ return Result.error(4003, "楠岃瘉鐮佷笉瀛樺湪鎴栧凡杩囨湡锛岃鍒锋柊");
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private List<String> strList(Object o) {
+ if (o instanceof List) {
+ return (List<String>) o;
+ }
+ return Collections.emptyList();
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.1