mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
登录恢复guava cache同步缓存
This commit is contained in:
Vendored
-2
@@ -1,12 +1,10 @@
|
|||||||
package com.cf.imes.framework.common.util.cache;
|
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.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+3
-3
@@ -41,7 +41,7 @@ public class OrganFrameworkServiceImpl implements OrganFrameworkService {
|
|||||||
/**
|
/**
|
||||||
* 针对 {@link #validOrgan(Long)} 的缓存
|
* 针对 {@link #validOrgan(Long)} 的缓存
|
||||||
*/
|
*/
|
||||||
private final LoadingCache<Long, CommonResult<Boolean>> validOrganCache = CacheUtils.buildAsyncReloadingCache(
|
private final LoadingCache<Long, CommonResult<Boolean>> validOrganCache = CacheUtils.buildCache(
|
||||||
Duration.ofMinutes(1L), // 过期时间 1 分钟
|
Duration.ofMinutes(1L), // 过期时间 1 分钟
|
||||||
new CacheLoader<>() {
|
new CacheLoader<>() {
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public class OrganFrameworkServiceImpl implements OrganFrameworkService {
|
|||||||
/**
|
/**
|
||||||
* 针对 {@link #validDept(Long)} 的缓存
|
* 针对 {@link #validDept(Long)} 的缓存
|
||||||
*/
|
*/
|
||||||
private final LoadingCache<Long, CommonResult<Boolean>> validOrganDept = CacheUtils.buildAsyncReloadingCache(
|
private final LoadingCache<Long, CommonResult<Boolean>> validOrganDept = CacheUtils.buildCache(
|
||||||
Duration.ofMinutes(1L), // 过期时间 1 分钟
|
Duration.ofMinutes(1L), // 过期时间 1 分钟
|
||||||
new CacheLoader<>() {
|
new CacheLoader<>() {
|
||||||
|
|
||||||
@@ -81,6 +81,6 @@ public class OrganFrameworkServiceImpl implements OrganFrameworkService {
|
|||||||
@Override
|
@Override
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void validDept(Long id) {
|
public void validDept(Long id) {
|
||||||
deptApi.validateDept(id).checkError();
|
validOrganDept.get(id).checkError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-4
@@ -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.common.util.validation.ValidationUtils;
|
||||||
import com.cf.imes.framework.ip.core.service.IPQueryService;
|
import com.cf.imes.framework.ip.core.service.IPQueryService;
|
||||||
import com.cf.imes.framework.ip.core.service.dto.IPQueryDataRespDTO;
|
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.logger.dto.LoginLogCreateReqDTO;
|
||||||
import com.cf.imes.module.system.api.sms.SmsCodeApi;
|
import com.cf.imes.module.system.api.sms.SmsCodeApi;
|
||||||
import com.cf.imes.module.system.api.social.dto.SocialUserRespDTO;
|
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.logger.LoginResultEnum;
|
||||||
import com.cf.imes.module.system.enums.oauth2.OAuth2ClientConstants;
|
import com.cf.imes.module.system.enums.oauth2.OAuth2ClientConstants;
|
||||||
import com.cf.imes.module.system.enums.sms.SmsSceneEnum;
|
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.logger.LoginLogService;
|
||||||
import com.cf.imes.module.system.service.member.MemberService;
|
import com.cf.imes.module.system.service.member.MemberService;
|
||||||
import com.cf.imes.module.system.service.oauth2.OAuth2TokenService;
|
import com.cf.imes.module.system.service.oauth2.OAuth2TokenService;
|
||||||
@@ -85,7 +86,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
@Resource
|
@Resource
|
||||||
private OrganService organService;
|
private OrganService organService;
|
||||||
@Resource
|
@Resource
|
||||||
private DeptService deptService;
|
private OrganFrameworkService organFrameworkService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SmsCodeService smsCodeService;
|
private SmsCodeService smsCodeService;
|
||||||
@@ -122,9 +123,10 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
}
|
}
|
||||||
Long organId = user.getOrganId();
|
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())) {
|
if (!userService.isPasswordMatch(password, user.getPassword())) {
|
||||||
createLoginLog(user.getId(), username, organId, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
|
createLoginLog(user.getId(), username, organId, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
|
||||||
|
|||||||
Reference in New Issue
Block a user