mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-22 12:48:58 +08:00
refactor(sa-token): 优化 sa-token 细节
This commit is contained in:
parent
dc73679935
commit
62461e0717
@ -5,9 +5,11 @@ import cn.dev33.satoken.oauth2.data.model.loader.SaClientModel;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysOauthClientDetails;
|
||||
import com.pig4cloud.pig.admin.api.feign.RemoteClientDetailsService;
|
||||
import com.pig4cloud.pig.common.core.constant.CacheConstants;
|
||||
import com.pig4cloud.pig.common.core.util.R;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -33,6 +35,7 @@ public class SaOAuth2ClientDataLoaderImpl implements SaOAuth2DataLoader {
|
||||
* @return ClientModel
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#clientId", unless = "#result == null")
|
||||
public SaClientModel getClientModel(String clientId) {
|
||||
R<SysOauthClientDetails> clientDetailsById = remoteClientDetailsService.getClientDetailsById(clientId);
|
||||
|
||||
|
@ -176,6 +176,14 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- sa-token version-->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-bom</artifactId>
|
||||
<version>${sa-token.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!--web 模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -44,10 +44,6 @@ public class SecurityUtils {
|
||||
*/
|
||||
public PigUser getUser() {
|
||||
Object loginId = StpUtil.getLoginId();
|
||||
if (ObjectUtil.isNull(loginId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String username = loginId.toString();
|
||||
Cache cache = SpringUtil.getBean(CacheManager.class).getCache(CacheConstants.USER_DETAILS);
|
||||
PigUser pigUser = getCachedPigUser(cache, username);
|
||||
@ -65,10 +61,6 @@ public class SecurityUtils {
|
||||
*/
|
||||
public List<Long> getRoles() {
|
||||
Object loginId = StpUtil.getLoginId();
|
||||
if (ObjectUtil.isNull(loginId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String username = loginId.toString();
|
||||
Cache cache = SpringUtil.getBean(CacheManager.class).getCache(CacheConstants.USER_DETAILS);
|
||||
List<Long> roles = getCachedRoles(cache, username);
|
||||
|
Loading…
Reference in New Issue
Block a user