diff --git a/zt-module-databus/zt-module-databus-server/src/main/java/com/zt/plat/module/databus/service/gateway/impl/ApiClientCredentialServiceImpl.java b/zt-module-databus/zt-module-databus-server/src/main/java/com/zt/plat/module/databus/service/gateway/impl/ApiClientCredentialServiceImpl.java index 415684fb..6f2f580a 100644 --- a/zt-module-databus/zt-module-databus-server/src/main/java/com/zt/plat/module/databus/service/gateway/impl/ApiClientCredentialServiceImpl.java +++ b/zt-module-databus/zt-module-databus-server/src/main/java/com/zt/plat/module/databus/service/gateway/impl/ApiClientCredentialServiceImpl.java @@ -1,7 +1,5 @@ package com.zt.plat.module.databus.service.gateway.impl; -import com.github.benmanes.caffeine.cache.Caffeine; -import com.github.benmanes.caffeine.cache.LoadingCache; import com.zt.plat.framework.common.exception.util.ServiceExceptionUtil; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.util.object.BeanUtils; @@ -11,14 +9,12 @@ import com.zt.plat.module.databus.dal.dataobject.gateway.ApiClientCredentialDO; import com.zt.plat.module.databus.dal.mysql.gateway.ApiClientCredentialMapper; import com.zt.plat.module.databus.service.gateway.ApiAnonymousUserService; import com.zt.plat.module.databus.service.gateway.ApiClientCredentialService; -import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; -import java.time.Duration; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -36,16 +32,6 @@ public class ApiClientCredentialServiceImpl implements ApiClientCredentialServic private final ApiClientCredentialMapper credentialMapper; private final ApiAnonymousUserService anonymousUserService; - private LoadingCache> credentialCache; - - @PostConstruct - public void initCache() { - credentialCache = Caffeine.newBuilder() - .maximumSize(256) - .expireAfterWrite(Duration.ofMinutes(5)) - .build(this::loadCredentialSync); - } - @Override public PageResult getPage(ApiClientCredentialPageReqVO reqVO) { return credentialMapper.selectPage(reqVO); @@ -67,7 +53,6 @@ public class ApiClientCredentialServiceImpl implements ApiClientCredentialServic credential.setAnonymousUserId(null); } credentialMapper.insert(credential); - invalidateCache(credential.getAppId()); return credential.getId(); } @@ -86,8 +71,6 @@ public class ApiClientCredentialServiceImpl implements ApiClientCredentialServic updateObj.setAnonymousUserId(null); } credentialMapper.updateById(updateObj); - invalidateCache(existing.getAppId()); - invalidateCache(updateObj.getAppId()); if (!Objects.equals(existing.getAnonymousUserId(), updateObj.getAnonymousUserId())) { anonymousUserService.invalidate(existing.getAnonymousUserId()); anonymousUserService.invalidate(updateObj.getAnonymousUserId()); @@ -99,7 +82,6 @@ public class ApiClientCredentialServiceImpl implements ApiClientCredentialServic public void delete(Long id) { ApiClientCredentialDO existing = ensureExists(id); credentialMapper.deleteById(id); - invalidateCache(existing.getAppId()); anonymousUserService.invalidate(existing.getAnonymousUserId()); } @@ -118,11 +100,7 @@ public class ApiClientCredentialServiceImpl implements ApiClientCredentialServic if (!StringUtils.hasText(appId)) { return Optional.empty(); } - return credentialCache.get(appId.trim()); - } - - private Optional loadCredentialSync(String appId) { - Optional credential = credentialMapper.selectByAppId(appId) + Optional credential = credentialMapper.selectByAppId(appId.trim()) .filter(item -> Boolean.TRUE.equals(item.getEnabled())); if (credential.isEmpty()) { log.debug("[API-PORTAL] 未找到 appId={} 的有效凭证", appId); @@ -147,13 +125,6 @@ public class ApiClientCredentialServiceImpl implements ApiClientCredentialServic return credential; } - private void invalidateCache(String appId) { - if (!StringUtils.hasText(appId)) { - return; - } - credentialCache.invalidate(appId.trim()); - } - private void normalizeAnonymousSettings(ApiClientCredentialSaveReqVO reqVO) { if (Boolean.TRUE.equals(reqVO.getAllowAnonymous())) { if (reqVO.getAnonymousUserId() == null) { diff --git a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkSyncProcessorImpl.java b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkSyncProcessorImpl.java index 5547d727..c49f1b63 100644 --- a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkSyncProcessorImpl.java +++ b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkSyncProcessorImpl.java @@ -782,14 +782,11 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor { if (user == null) { return null; } - String workcode = resolveWorkcode(user); - if (StrUtil.isNotBlank(workcode)) { - return workcode; - } if (StrUtil.isNotBlank(user.getLoginid())) { return user.getLoginid().trim(); } - return null; + String workcode = resolveWorkcode(user); + return StrUtil.isNotBlank(workcode) ? workcode : null; } /**