From d49617a5473fcf5c3b4fecc2582a311bd391180d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Thu, 2 Jul 2026 15:45:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(system):=20=E4=BF=AE=E5=A4=8D=E8=B6=85?= =?UTF-8?q?=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98=E6=A0=87=E8=AF=86=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=92=8C=E5=BE=AE=E4=BF=A1=E7=99=BB=E5=BD=95openid?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在超级管理员用户创建时正确设置isSuperAdmin和isAdmin标识 - 修正超级管理员isAdmin属性设置顺序 - 微信登录接口中将openid和unionid设置到userParam,保证后续用户查找和注册使用 - 对已有用户补充openid和unionid信息,避免老用户缺少openid导致问题 - 更新用户信息后保存,确保数据一致性 --- .../common/system/controller/WxLoginController.java | 12 ++++++++++++ .../system/service/impl/TenantServiceImpl.java | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java b/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java index ec18175..e3b474e 100644 --- a/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java +++ b/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java @@ -134,11 +134,23 @@ public class WxLoginController extends BaseController { if (openid == null) { return fail("获取openid失败", null); } + // 关键:把 openid/unionid 设置到 userParam,否则后续查库/注册都拿不到 openid + userParam.setOpenid(openid); + if (StrUtil.isNotBlank(unionid)) { + userParam.setUnionid(unionid); + } // 2.通过openid查询用户是否已存在 User user = userService.getByOauthId(userParam); // 3.存在则签发token并返回登录成功,不存在则注册新用户 if (user == null) { user = addUser(userParam); + } else if (StrUtil.isBlank(user.getOpenid())) { + // 老用户(比如手机号注册)没有 openid,补上 + user.setOpenid(openid); + if (StrUtil.isNotBlank(unionid)) { + user.setUnionid(unionid); + } + userService.updateById(user); } // 4.签发token loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_LOGIN, null, user.getTenantId(), request); diff --git a/src/main/java/com/gxwebsoft/common/system/service/impl/TenantServiceImpl.java b/src/main/java/com/gxwebsoft/common/system/service/impl/TenantServiceImpl.java index ba23291..aafb255 100644 --- a/src/main/java/com/gxwebsoft/common/system/service/impl/TenantServiceImpl.java +++ b/src/main/java/com/gxwebsoft/common/system/service/impl/TenantServiceImpl.java @@ -108,9 +108,10 @@ public class TenantServiceImpl extends ServiceImpl impleme superAdmin.setUsername("superAdmin"); superAdmin.setNickname(company.getShortName()); superAdmin.setPhone(company.getPhone()); + superAdmin.setIsSuperAdmin(true); + superAdmin.setIsAdmin(true); superAdmin.setEmail(company.getEmail()); superAdmin.setTemplateId(company.getTemplateId()); - superAdmin.setIsAdmin(true); superAdmin.setRealName(company.getBusinessEntity()); superAdmin.setPassword(userService.encodePassword("$2a$10$iMsEmh.rPlzwy/SVe6KW3.62vlwqMJpibhCF9jYN.fMqxdqymzMzu")); if (company.getPassword() != null) {