mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 12:39:05 +08:00
♻️ Refactoring code. 优化 toc app-server 的相关feignclient 引入逻辑,避免删除 app-server 无法启动单体版本
This commit is contained in:
1 parent
4d653bcc7b
commit
42e79189bf
2 files changed
+13
-12
No files matched your search
+7
-6
@@ -37,10 +37,7 @@ import org.springframework.security.core.authority.AuthorityUtils;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 用户详细信息
|
||||
@@ -53,7 +50,7 @@ public class PigxTocDefaultUserDetailsServiceImpl implements PigxUserDetailsServ
|
||||
|
||||
private final CacheManager cacheManager;
|
||||
|
||||
private final RemoteAppUserService remoteAppUserService;
|
||||
private final Optional<RemoteAppUserService> remoteAppUserServiceOptional;
|
||||
|
||||
/**
|
||||
* 用户密码登录
|
||||
@@ -63,11 +60,15 @@ public class PigxTocDefaultUserDetailsServiceImpl implements PigxUserDetailsServ
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
if (!remoteAppUserServiceOptional.isPresent()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS_MINI);
|
||||
if (cache != null && cache.get(username) != null) {
|
||||
return cache.get(username, PigxUser.class);
|
||||
}
|
||||
R<AppUserInfo> info = remoteAppUserService.info(username, SecurityConstants.FROM_IN);
|
||||
R<AppUserInfo> info = remoteAppUserServiceOptional.get().info(username, SecurityConstants.FROM_IN);
|
||||
UserDetails userDetailsAppUser = this.getUserDetailsAppUser(info);
|
||||
if (cache != null) {
|
||||
cache.put(username, userDetailsAppUser);
|
||||
|
||||
+6
-6
@@ -34,10 +34,7 @@ import org.springframework.security.core.authority.AuthorityUtils;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 用户详细信息
|
||||
@@ -48,7 +45,7 @@ import java.util.Set;
|
||||
@RequiredArgsConstructor
|
||||
public class PigxTocMobileUserDetailsServiceImpl implements PigxUserDetailsService {
|
||||
|
||||
private final RemoteAppUserService remoteAppUserService;
|
||||
private final Optional<RemoteAppUserService> remoteAppUserServiceOptional;
|
||||
|
||||
/**
|
||||
* 用户密码登录
|
||||
@@ -58,7 +55,10 @@ public class PigxTocMobileUserDetailsServiceImpl implements PigxUserDetailsServi
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public UserDetails loadUserByUsername(String phone) {
|
||||
R<AppUserInfo> info = remoteAppUserService.social(phone, SecurityConstants.FROM_IN);
|
||||
if (!remoteAppUserServiceOptional.isPresent()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
R<AppUserInfo> info = remoteAppUserServiceOptional.get().social(phone, SecurityConstants.FROM_IN);
|
||||
return this.getUserDetailsAppUser(info);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user