From 9f8be2bd6f78ec95e1b3b750be57755d865f646f Mon Sep 17 00:00:00 2001 From: aeizzz <1129603149@qq.com> Date: Fri, 23 Dec 2022 14:52:24 +0800 Subject: [PATCH] =?UTF-8?q?:recycle:=20Refactoring=20code.=20=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PigRemoteRegisteredClientRepository.java | 2 +- .../service/PigUserDetailsServiceImpl.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigRemoteRegisteredClientRepository.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigRemoteRegisteredClientRepository.java index 41047136..ee44bae1 100644 --- a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigRemoteRegisteredClientRepository.java +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigRemoteRegisteredClientRepository.java @@ -84,7 +84,7 @@ public class PigRemoteRegisteredClientRepository implements RegisteredClientRepo */ @Override @SneakyThrows -// @Cacheable(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#clientId", unless = "#result == null") + @Cacheable(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#clientId", unless = "#result == null") public RegisteredClient findByClientId(String clientId) { SysOauthClientDetails clientDetails = RetOps.of(clientDetailsService.getClientDetailsById(clientId)).getData() diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigUserDetailsServiceImpl.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigUserDetailsServiceImpl.java index 5e42728c..0eb0b862 100755 --- a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigUserDetailsServiceImpl.java +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigUserDetailsServiceImpl.java @@ -50,16 +50,16 @@ public class PigUserDetailsServiceImpl implements PigUserDetailsService { @Override @SneakyThrows public UserDetails loadUserByUsername(String username) { -// Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS); -// if (cache != null && cache.get(username) != null) { -// return (PigUser) cache.get(username).get(); -// } + Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS); + if (cache != null && cache.get(username) != null) { + return (PigUser) cache.get(username).get(); + } R result = remoteUserService.info(username); UserDetails userDetails = getUserDetails(result); -// if (cache != null) { -// cache.put(username, userDetails); -// } + if (cache != null) { + cache.put(username, userDetails); + } return userDetails; }