diff --git a/doc/readme.md b/doc/readme.md index 29c0414..fe248bb 100644 --- a/doc/readme.md +++ b/doc/readme.md @@ -1,4 +1,4 @@ -# 20250409 +# 20250409(已上线20250424) ## 微信oauth2扫码登录 @@ -14,10 +14,19 @@ ADD COLUMN `wx_union_id` varchar(255) NULL COMMENT '微信-开放平台-unionid' ### 临时登录接口 -``` +```text /router/systemuser/temporary-login ``` +### 微信 + +```text +/api/user-wx/login +/api/user-wx/register +``` + +### 小程序登录 + # 20250325(已上线) ## user_expand diff --git a/src/main/java/cn/com/tenlion/operator/controller/api/user/wx/UserWxController.java b/src/main/java/cn/com/tenlion/operator/controller/api/user/wx/UserWxController.java index 79d2144..6d861c3 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/api/user/wx/UserWxController.java +++ b/src/main/java/cn/com/tenlion/operator/controller/api/user/wx/UserWxController.java @@ -12,7 +12,7 @@ import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "微信用户接口") +@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "微信小程序用户接口") @RestController @RequestMapping(ISystemConstant.API_PREFIX + "/user-wx") public class UserWxController extends DefaultBaseController { diff --git a/src/main/java/cn/com/tenlion/operator/login/wx/oauth2/auth/LoginWxOauth2AuthFilter.java b/src/main/java/cn/com/tenlion/operator/login/wx/oauth2/auth/LoginWxOauth2AuthFilter.java index 05306aa..fb4ec18 100644 --- a/src/main/java/cn/com/tenlion/operator/login/wx/oauth2/auth/LoginWxOauth2AuthFilter.java +++ b/src/main/java/cn/com/tenlion/operator/login/wx/oauth2/auth/LoginWxOauth2AuthFilter.java @@ -3,14 +3,12 @@ package cn.com.tenlion.operator.login.wx.oauth2.auth; import cn.com.tenlion.operator.properties.WxOauth2Properties; import cn.com.tenlion.operator.remote.wx.IWxOauth2RemoteService; import cn.com.tenlion.operator.remote.wx.entity.WxOauth2AccessToken; -import com.sun.xml.internal.bind.v2.runtime.output.SAXOutput; import org.apache.commons.lang3.StringUtils; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; -import org.springframework.security.web.util.matcher.RequestMatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; diff --git a/src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java b/src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java index 108762e..21af778 100644 --- a/src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java +++ b/src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java @@ -153,6 +153,10 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx po = new UserExpandPO(); po.setUserId(userId); } + if (!StringUtils.isBlank(po.getWxOpenId())) { + UserPO userPO = userService.getPO(po.getUserId()); + po.setIsUpdateWxUsernamePhone(RegexUtil.isPhone(userPO.getUserUsername()) ? 0 : 1); + } updateRedis(po); } diff --git a/src/main/java/cn/com/tenlion/operator/service/user/wx/UserWxMiniappService.java b/src/main/java/cn/com/tenlion/operator/service/user/wx/UserWxMiniappService.java index ddd1105..4c5dd60 100644 --- a/src/main/java/cn/com/tenlion/operator/service/user/wx/UserWxMiniappService.java +++ b/src/main/java/cn/com/tenlion/operator/service/user/wx/UserWxMiniappService.java @@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -34,7 +35,7 @@ public class UserWxMiniappService { private static final Logger LOG = LoggerFactory.getLogger(UserWxMiniappService.class); - private WxMiniappAccessToken miniappAccessToken = null; + private static WxMiniappAccessToken miniappAccessToken = null; @Autowired private WxMiniappProperties wxMiniappProperties; @Autowired @@ -54,11 +55,13 @@ public class UserWxMiniappService { /** * 保存openid和session_key的映射关系,需要创建用户时使用 */ - private final Map openIdSessionKeyMap = new ConcurrentHashMap<>(); + private static final Map openIdSessionKeyMap = new ConcurrentHashMap<>(); + /** * 刷新access_token */ + @PostConstruct public void refreshAccessToken() { long currentTimeMillis = System.currentTimeMillis(); if (miniappAccessToken != null && (currentTimeMillis - miniappAccessToken.getUpdateTime() < 5400000)) { diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 8cf09f8..e21bd28 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -143,7 +143,7 @@ api-path: # # 短信验证码服务 sms: - active: false + active: true type: default default-sms: account: xd001382 @@ -210,5 +210,5 @@ wx-miniapp: wx-oauth2: appid: wxb6296ee6223aafa0 appsecret: 09c423893098cd5566aead093ea5c25c - # redirect-uri: https://www.aimzhu.com/operator/oauth/wx/oauth2 + # redirect-uri: https://www.aimzhu.com/operator/oauth/wx/qrcode redirect-uri: http://121.36.71.250:58038/operator/oauth/wx/qrcode diff --git a/src/main/resources/static/assets/images/system-select-bg.jpg b/src/main/resources/static/assets/images/system-select-bg.jpg new file mode 100644 index 0000000..37a2cdb Binary files /dev/null and b/src/main/resources/static/assets/images/system-select-bg.jpg differ diff --git a/src/main/resources/templates/systemuser/system-select.html b/src/main/resources/templates/systemuser/system-select.html index 7e3a7a7..195e289 100644 --- a/src/main/resources/templates/systemuser/system-select.html +++ b/src/main/resources/templates/systemuser/system-select.html @@ -9,11 +9,15 @@ AI喵著