[feat]:用户微信登录模块

This commit is contained in:
李世琳
2024-12-16 17:00:32 +08:00
parent 6d27d59050
commit 0a99d1c2c8
14 changed files with 279 additions and 16 deletions
@@ -0,0 +1,32 @@
package com.central.oauth2.common.token;
import lombok.Getter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import java.util.Collection;
/**
* @author: lsl
* @date: 2024/12/16
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@Getter
public class TencentAuthenticationToken extends BaseAuthenticationToken {
public static final AuthorizationGrantType GRANT_TYPE = new AuthorizationGrantType("tencent");
private final Object principal;
public TencentAuthenticationToken(String code) {
super(GRANT_TYPE);
this.principal = code;
super.setAuthenticated(true);
}
public TencentAuthenticationToken(UserDetails user, Collection<? extends GrantedAuthority> authorities) {
super(authorities);
this.principal = user;
}
}
@@ -51,6 +51,14 @@ public interface UserService {
@GetMapping(value = "/users-anon/openId", params = "openId")
SysUser findByOpenId(@RequestParam("openId") String openId);
/**
* 根据OpenId查询用户信息
*
* @param openId openId
*/
@GetMapping(value = "/users-anon/wxOpenId", params = "openId")
SysUser findByWxOpenId(@RequestParam("openId") String openId);
/**
* 获取带角色的用户信息
@@ -44,6 +44,12 @@ public class UserServiceFallbackFactory implements FallbackFactory<UserService>
return new SysUser();
}
@Override
public SysUser findByWxOpenId(String openId) {
log.error("通过wxOpenId查询用户异常:{}", openId, throwable);
return new SysUser();
}
/**
* 获取带角色的用户信息
*
@@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
/**
* @author zlt
* 用户实体
* 系统用户实体
*/
@Data
@EqualsAndHashCode(callSuper = false)