From ffc72209449de208de3b66ae3ee9c2a7998b95d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E6=96=87=E8=B1=AA?= <980287353@qq.com> Date: Wed, 20 Aug 2025 16:01:01 +0800 Subject: [PATCH] publish 2.0.17-test2 --- pom.xml | 18 +++++++++--------- springboot-ademo/pom.xml | 4 ++-- springboot-annotation/pom.xml | 2 +- springboot-database/pom.xml | 2 +- springboot-login/pom.xml | 2 +- .../login/controller/LoginController.java | 2 +- springboot-message/pom.xml | 2 +- springboot-platform/pom.xml | 2 +- .../config/wxmp/PlatformWxmpConfig.java | 15 ++++++++++++--- .../config/wxmp/bean/WxConfigBean.java | 12 +++++++++++- springboot-role/pom.xml | 2 +- springboot-util/pom.xml | 2 +- springboot-web/pom.xml | 2 +- 13 files changed, 43 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index 116529d..ec2f362 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 2.0.17-test + 2.0.17-test2 pom springboot-parent 杭州铁晟科技有限公司基础依赖 @@ -58,49 +58,49 @@ com.tiesheng.springboot-parent springboot-database - 2.0.17-test + 2.0.17-test2 com.tiesheng.springboot-parent springboot-login - 2.0.17-test + 2.0.17-test2 com.tiesheng.springboot-parent springboot-web - 2.0.17-test + 2.0.17-test2 com.tiesheng.springboot-parent springboot-util - 2.0.17-test + 2.0.17-test2 com.tiesheng.springboot-parent springboot-platform - 2.0.17-test + 2.0.17-test2 com.tiesheng.springboot-parent springboot-message - 2.0.17-test + 2.0.17-test2 com.tiesheng.springboot-parent springboot-role - 2.0.17-test + 2.0.17-test2 com.tiesheng.springboot-parent springboot-annotation - 2.0.17-test + 2.0.17-test2 diff --git a/springboot-ademo/pom.xml b/springboot-ademo/pom.xml index f8e9980..d8e5410 100644 --- a/springboot-ademo/pom.xml +++ b/springboot-ademo/pom.xml @@ -6,11 +6,11 @@ com.tiesheng.springboot-parent springboot-parent - 2.0.17-test + 2.0.17-test2 springboot-ademo - 2.0.17-test + 2.0.17-test2 8 diff --git a/springboot-annotation/pom.xml b/springboot-annotation/pom.xml index 57241ef..56078e8 100644 --- a/springboot-annotation/pom.xml +++ b/springboot-annotation/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 2.0.17-test + 2.0.17-test2 springboot-annotation diff --git a/springboot-database/pom.xml b/springboot-database/pom.xml index 2b98218..7aa92fd 100644 --- a/springboot-database/pom.xml +++ b/springboot-database/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 2.0.17-test + 2.0.17-test2 springboot-database diff --git a/springboot-login/pom.xml b/springboot-login/pom.xml index 993c6ed..1c442a8 100644 --- a/springboot-login/pom.xml +++ b/springboot-login/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 2.0.17-test + 2.0.17-test2 springboot-login diff --git a/springboot-login/src/main/java/com/tiesheng/login/controller/LoginController.java b/springboot-login/src/main/java/com/tiesheng/login/controller/LoginController.java index c7dc25c..2aa60a6 100644 --- a/springboot-login/src/main/java/com/tiesheng/login/controller/LoginController.java +++ b/springboot-login/src/main/java/com/tiesheng/login/controller/LoginController.java @@ -170,7 +170,7 @@ public class LoginController { extra = ""; } String configUrl = globalConfig.buildPath("/login/wxmp/oauth2/" + service + "?extra=" + extra); - String authorizationUrl = platformWxmpConfig.buildAuthorizationUrl(service, configUrl, "snsapi_base"); + String authorizationUrl = platformWxmpConfig.buildAuthorizationUrl(service, configUrl); response.sendRedirect(authorizationUrl); } diff --git a/springboot-message/pom.xml b/springboot-message/pom.xml index 5bab2e3..fc51b63 100644 --- a/springboot-message/pom.xml +++ b/springboot-message/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 2.0.17-test + 2.0.17-test2 springboot-message diff --git a/springboot-platform/pom.xml b/springboot-platform/pom.xml index c56a2f9..c5c9b2e 100644 --- a/springboot-platform/pom.xml +++ b/springboot-platform/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 2.0.17-test + 2.0.17-test2 springboot-platform diff --git a/springboot-platform/src/main/java/com/tiesheng/platform/config/wxmp/PlatformWxmpConfig.java b/springboot-platform/src/main/java/com/tiesheng/platform/config/wxmp/PlatformWxmpConfig.java index 1785ed2..a63a5a5 100644 --- a/springboot-platform/src/main/java/com/tiesheng/platform/config/wxmp/PlatformWxmpConfig.java +++ b/springboot-platform/src/main/java/com/tiesheng/platform/config/wxmp/PlatformWxmpConfig.java @@ -19,6 +19,7 @@ import org.springframework.context.annotation.Configuration; import java.util.HashMap; import java.util.Map; +import java.util.Objects; /** * @author hao @@ -122,12 +123,12 @@ public class PlatformWxmpConfig { * * @return */ - public String buildAuthorizationUrl(String service, String redirectUrl, String scope) { + public String buildAuthorizationUrl(String service, String redirectUrl) { WxConfigBean configBean = getConfigBean(service); return "https://open.weixin.qq.com/connect/oauth2/authorize" + "?appid=" + configBean.getAppId() + "&redirect_uri=" + URLUtil.encodeAll(redirectUrl) - + "&response_type=code&scope=" + scope + + "&response_type=code&scope=" + configBean.getScope() + "&state=STATE#wechat_redirect"; } @@ -141,7 +142,15 @@ public class PlatformWxmpConfig { public WxUserInfo getOAuth2AccessToken(String service, String code) { WxConfigBean configBean = getConfigBean(service); WxOAuth2AccessToken wxOAuth2AccessToken = WxOAuth2AccessToken.create(configBean.getAppId(), configBean.getAppSecret(), code); - WxUserInfo wxUserInfo = WxUserInfo.create(wxOAuth2AccessToken); + + WxUserInfo wxUserInfo = null; + if (Objects.equals(configBean.getScope(), "snsapi_userinfo")) { + wxUserInfo = WxUserInfo.create(wxOAuth2AccessToken); + } else { + wxUserInfo = new WxUserInfo(); + wxUserInfo.setOpenid(wxOAuth2AccessToken.getOpenid()); + wxUserInfo.setRealUser(wxOAuth2AccessToken.isRealUser()); + } wxUserInfo.setAppId(configBean.getAppId()); return wxUserInfo; } diff --git a/springboot-platform/src/main/java/com/tiesheng/platform/config/wxmp/bean/WxConfigBean.java b/springboot-platform/src/main/java/com/tiesheng/platform/config/wxmp/bean/WxConfigBean.java index 5a24275..6a77b4b 100644 --- a/springboot-platform/src/main/java/com/tiesheng/platform/config/wxmp/bean/WxConfigBean.java +++ b/springboot-platform/src/main/java/com/tiesheng/platform/config/wxmp/bean/WxConfigBean.java @@ -7,10 +7,12 @@ public class WxConfigBean { private String appId; private String appSecret; + private String scope = "snsapi_userinfo"; /////////////////////////////////////////////////////////////////////////// // setter\getter - /////////////////////////////////////////////////////////////////////////// + + /// //////////////////////////////////////////////////////////////////////// public String getAppId() { return appId; @@ -27,4 +29,12 @@ public class WxConfigBean { public void setAppSecret(String appSecret) { this.appSecret = appSecret; } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } } diff --git a/springboot-role/pom.xml b/springboot-role/pom.xml index cb36262..db18690 100644 --- a/springboot-role/pom.xml +++ b/springboot-role/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 2.0.17-test + 2.0.17-test2 springboot-role diff --git a/springboot-util/pom.xml b/springboot-util/pom.xml index 99b3eed..d48d3ce 100644 --- a/springboot-util/pom.xml +++ b/springboot-util/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 2.0.17-test + 2.0.17-test2 springboot-util diff --git a/springboot-web/pom.xml b/springboot-web/pom.xml index 6d7af21..1cdd046 100644 --- a/springboot-web/pom.xml +++ b/springboot-web/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 2.0.17-test + 2.0.17-test2 springboot-web