From e73e0fb6b5cbf095751da8fabe345fe17a41939d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Tue, 7 Apr 2026 01:43:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(auth):=20=E5=AE=8C=E5=96=84=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E7=99=BB=E5=BD=95=E7=8A=B6=E6=80=81=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E7=BB=91=E5=AE=9A=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E5=8F=B7=E5=92=8C=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增响应字段 nextAction、redirectUrl 和 successMessage,用于表示下一步操作 - 扫码登录状态为绑定手机号时,设置 nextAction 为 bind_phone,清空跳转地址 - 扫码已确认且有访问令牌时,设置跳转控制台页面,带成功提示信息 - 其他状态默认保持等待状态,确保扫码流程向前推进 - 更新扫码登录响应模型,优化前端流程控制体验 --- .workbuddy/expert-history.json | 17 +++++++++++++++++ .workbuddy/memory/2026-04-07.md | 12 ++++++++++++ .../auto/dto/QrLoginStatusResponse.java | 9 +++++++++ .../auto/service/impl/QrLoginServiceImpl.java | 12 ++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 .workbuddy/expert-history.json create mode 100644 .workbuddy/memory/2026-04-07.md diff --git a/.workbuddy/expert-history.json b/.workbuddy/expert-history.json new file mode 100644 index 0000000..5ded824 --- /dev/null +++ b/.workbuddy/expert-history.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "sessions": { + "da2fb4dc76a94426a7dfef478f674489": [ + { + "expertId": "SeniorDeveloper", + "name": "Will", + "profession": "高级开发工程师", + "avatarUrl": "https://acc-1258344699.cos.accelerate.myqcloud.com/workbuddy/experts/avatars/02-Engineering/SeniorDeveloper/SeniorDeveloper.png", + "promptUrl": "https://acc-1258344699.cos.accelerate.myqcloud.com/workbuddy/experts/experts/02-Engineering/SeniorDeveloper/SeniorDeveloper_zh.md", + "usedAt": 1775495439006, + "industryId": "all" + } + ] + }, + "lastUpdated": 1775497010453 +} \ No newline at end of file diff --git a/.workbuddy/memory/2026-04-07.md b/.workbuddy/memory/2026-04-07.md new file mode 100644 index 0000000..2eae388 --- /dev/null +++ b/.workbuddy/memory/2026-04-07.md @@ -0,0 +1,12 @@ +## 2026-04-07 工作记录 + +### 微信扫码登录问题修复 +1. 修复了UserSyncService中tenant_id字段名问题(从tenantId改为tenant_id) +2. 同时发送两种格式的tenant_id字段确保兼容性 +3. 修改了WxOfficialController,在同步前从数据库重新加载用户对象 +4. 添加了详细的调试日志便于问题排查 + +### 待解决问题 +1. websopy侧app_user_cache同步失败(tenant_id为null) +2. 扫码成功后需跳转到强制绑定手机号页面 +3. 注册成功后应跳转到控制台/console \ No newline at end of file diff --git a/src/main/java/com/gxwebsoft/auto/dto/QrLoginStatusResponse.java b/src/main/java/com/gxwebsoft/auto/dto/QrLoginStatusResponse.java index 99114aa..b833615 100644 --- a/src/main/java/com/gxwebsoft/auto/dto/QrLoginStatusResponse.java +++ b/src/main/java/com/gxwebsoft/auto/dto/QrLoginStatusResponse.java @@ -37,6 +37,15 @@ public class QrLoginStatusResponse { @Schema(description = "状态提示信息") private String message; + @Schema(description = "下一步操作:bind_phone-绑定手机号, redirect-跳转, login-直接登录") + private String nextAction; + + @Schema(description = "跳转URL(当nextAction为redirect时使用)") + private String redirectUrl; + + @Schema(description = "成功消息") + private String successMessage; + public QrLoginStatusResponse(String status, String accessToken, User userInfo, Long expiresIn, Integer tenantId) { this.status = status; this.accessToken = accessToken; diff --git a/src/main/java/com/gxwebsoft/auto/service/impl/QrLoginServiceImpl.java b/src/main/java/com/gxwebsoft/auto/service/impl/QrLoginServiceImpl.java index 87feed1..e959fb1 100644 --- a/src/main/java/com/gxwebsoft/auto/service/impl/QrLoginServiceImpl.java +++ b/src/main/java/com/gxwebsoft/auto/service/impl/QrLoginServiceImpl.java @@ -442,6 +442,18 @@ public class QrLoginServiceImpl implements QrLoginService { || QR_LOGIN_STATUS_BIND_PHONE.equals(qrLoginData.getStatus())); response.setMessage(qrLoginData.getMessage()); + // 设置下一步操作逻辑 + if (QR_LOGIN_STATUS_BIND_PHONE.equals(qrLoginData.getStatus()) || Boolean.TRUE.equals(qrLoginData.getNeedBindPhone())) { + response.setNextAction("bind_phone"); + response.setRedirectUrl(null); + } else if (QR_LOGIN_STATUS_CONFIRMED.equals(qrLoginData.getStatus()) && StrUtil.isNotBlank(qrLoginData.getAccessToken())) { + response.setNextAction("redirect"); + response.setRedirectUrl("/console"); + response.setSuccessMessage("登录成功,即将跳转到控制台"); + } else { + response.setNextAction("wait"); + } + if (qrLoginData.getUserId() != null) { try { User user = userService.getAllByUserId(String.valueOf(qrLoginData.getUserId()));