Przeglądaj źródła

fix: 停车券 jump 方法添加诊断日志排查 400 问题

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 1 dzień temu
rodzic
commit
d2104fb3c9

+ 5 - 0
car-wash-miniapp/src/main/java/com/kym/miniapp/controller/ParkingCouponController.java

@@ -50,8 +50,11 @@ public class ParkingCouponController {
     @SaIgnore
     @GetMapping
     public void jump(HttpServletResponse response, @RequestParam String code) throws IOException {
+        log.info("停车券跳转请求, code: {}", code);
         var url = KymCache.INSTANCE.getParkingCouponUrl(code);
+        log.info("从缓存获取停车券URL, code: {}, urlLength: {}", code, url != null ? url.length() : 0);
         if (url == null || url.isEmpty()) {
+            log.warn("停车券链接已失效, code: {}", code);
             response.setContentType("text/html; charset=utf-8");
             response.getWriter().write("""
                 <!DOCTYPE html>
@@ -65,11 +68,13 @@ public class ParkingCouponController {
         }
 
         if (url.length() < MAX_REDIRECT_URL_LENGTH) {
+            log.info("短 URL 直接重定向, code: {}, urlLength: {}", code, url.length());
             response.sendRedirect(url);
             return;
         }
 
         // URL 过长时使用服务端代理,避免浏览器 GET 请求触发第三方服务器 414
+        log.info("长 URL 使用代理, code: {}, urlLength: {}", code, url.length());
         try {
             String content = HttpUtil.get(url);
             String origin = extractOrigin(url);