diff --git a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/util/cache/CacheUtils.java b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/util/cache/CacheUtils.java index 1e0994115..185b7f2fe 100644 --- a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/util/cache/CacheUtils.java +++ b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/util/cache/CacheUtils.java @@ -1,12 +1,10 @@ package com.cf.imes.framework.common.util.cache; -import com.alibaba.ttl.threadpool.TtlExecutors; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import java.time.Duration; -import java.util.concurrent.Executor; import java.util.concurrent.Executors; /** diff --git a/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/core/service/OrganFrameworkServiceImpl.java b/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/core/service/OrganFrameworkServiceImpl.java index 0ff9debf4..bb15ebce8 100644 --- a/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/core/service/OrganFrameworkServiceImpl.java +++ b/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/core/service/OrganFrameworkServiceImpl.java @@ -41,7 +41,7 @@ public class OrganFrameworkServiceImpl implements OrganFrameworkService { /** * 针对 {@link #validOrgan(Long)} 的缓存 */ - private final LoadingCache> validOrganCache = CacheUtils.buildAsyncReloadingCache( + private final LoadingCache> validOrganCache = CacheUtils.buildCache( Duration.ofMinutes(1L), // 过期时间 1 分钟 new CacheLoader<>() { @@ -55,7 +55,7 @@ public class OrganFrameworkServiceImpl implements OrganFrameworkService { /** * 针对 {@link #validDept(Long)} 的缓存 */ - private final LoadingCache> validOrganDept = CacheUtils.buildAsyncReloadingCache( + private final LoadingCache> validOrganDept = CacheUtils.buildCache( Duration.ofMinutes(1L), // 过期时间 1 分钟 new CacheLoader<>() { @@ -81,6 +81,6 @@ public class OrganFrameworkServiceImpl implements OrganFrameworkService { @Override @SneakyThrows public void validDept(Long id) { - deptApi.validateDept(id).checkError(); + validOrganDept.get(id).checkError(); } } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java index 207479e7a..4fb384db8 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java @@ -12,6 +12,8 @@ import com.cf.imes.framework.common.util.servlet.ServletUtils; import com.cf.imes.framework.common.util.validation.ValidationUtils; import com.cf.imes.framework.ip.core.service.IPQueryService; import com.cf.imes.framework.ip.core.service.dto.IPQueryDataRespDTO; +import com.cf.imes.framework.organ.core.context.OrganContextHolder; +import com.cf.imes.framework.organ.core.service.OrganFrameworkService; import com.cf.imes.module.system.api.logger.dto.LoginLogCreateReqDTO; import com.cf.imes.module.system.api.sms.SmsCodeApi; import com.cf.imes.module.system.api.social.dto.SocialUserRespDTO; @@ -29,7 +31,6 @@ import com.cf.imes.module.system.enums.logger.LoginLogTypeEnum; import com.cf.imes.module.system.enums.logger.LoginResultEnum; import com.cf.imes.module.system.enums.oauth2.OAuth2ClientConstants; import com.cf.imes.module.system.enums.sms.SmsSceneEnum; -import com.cf.imes.module.system.service.dept.DeptService; import com.cf.imes.module.system.service.logger.LoginLogService; import com.cf.imes.module.system.service.member.MemberService; import com.cf.imes.module.system.service.oauth2.OAuth2TokenService; @@ -85,7 +86,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { @Resource private OrganService organService; @Resource - private DeptService deptService; + private OrganFrameworkService organFrameworkService; @Resource private SmsCodeService smsCodeService; @@ -122,9 +123,10 @@ public class AdminAuthServiceImpl implements AdminAuthService { } Long organId = user.getOrganId(); // 校验机构有效性 - organService.validOrgan(organId); + organFrameworkService.validOrgan(organId); // 校验部门有效性 - deptService.validUserLoginDept(user.getDeptId()); + OrganContextHolder.setOrganId(organId); + organFrameworkService.validDept(user.getDeptId()); // 校验密码 if (!userService.isPasswordMatch(password, user.getPassword())) { createLoginLog(user.getId(), username, organId, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);