fix(用户管理):新增用户unionId获取逻辑

This commit is contained in:
2025-04-24 11:42:56 +08:00
parent 8b0a2cc636
commit 29ed66e0e3
12 changed files with 71 additions and 18 deletions
@@ -36,5 +36,5 @@ public interface ZltUserDetailsService extends UserDetailsService {
* 根据微信用户id/openId查询用户
* @param wxOpenId 用户id/openId
*/
UserDetails loadUserByWxOpenId(String wxOpenId,String mobile) throws UsernameNotFoundException;
UserDetails loadUserByWxOpenId(String wxOpenId,String mobile,String unionId) throws UsernameNotFoundException;
}
@@ -51,8 +51,8 @@ public class UserDetailServiceImpl implements ZltUserDetailsService {
}
@Override
public UserDetails loadUserByWxOpenId(String wxOpenId,String mobile) throws UsernameNotFoundException {
SysUser sysUser = userService.findByWxOpenId(wxOpenId,mobile);
public UserDetails loadUserByWxOpenId(String wxOpenId,String mobile,String unionId) throws UsernameNotFoundException {
SysUser sysUser = userService.findByWxOpenId(wxOpenId,mobile,unionId);
checkUser(sysUser);
return LoginUserUtils.getLoginAppUser(sysUser);
}
@@ -78,8 +78,9 @@ public class TencentAuthenticationProvider extends BaseAuthenticationProvider {
try {
String openId = wxLoginResult.get("openid").toString();
String sessionKey = wxLoginResult.get("session_key").toString();
String unionId = wxLoginResult.get("unionid").toString();
String mobile = decryptPhoneNumber(encryptedData,sessionKey,iv);
userDetails = userDetailsServiceFactory.getService(authToken).loadUserByWxOpenId(openId,mobile);
userDetails = userDetailsServiceFactory.getService(authToken).loadUserByWxOpenId(openId,mobile, unionId);
} catch (AuthenticationException e) {
throw new CustomOAuth2AuthenticationException(e.getMessage());