From ca42e2b52256b02ce93b95d4cb934714335e3371 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Fri, 12 Nov 2021 23:31:33 +0800 Subject: [PATCH] =?UTF-8?q?Feature:=20=E5=AF=B9=E6=8E=A5=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=8F=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/threadpool/ThreadPoolDelReqDTO.java | 29 +++++++++++++++++++ .../config/service/ConfigCacheService.java | 12 ++++++++ .../config/service/biz/ThreadPoolService.java | 8 +++++ .../biz/impl/ThreadPoolServiceImpl.java | 12 +++++++- 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 config/src/main/java/com/github/dynamic/threadpool/config/model/biz/threadpool/ThreadPoolDelReqDTO.java diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/model/biz/threadpool/ThreadPoolDelReqDTO.java b/config/src/main/java/com/github/dynamic/threadpool/config/model/biz/threadpool/ThreadPoolDelReqDTO.java new file mode 100644 index 00000000..156d5551 --- /dev/null +++ b/config/src/main/java/com/github/dynamic/threadpool/config/model/biz/threadpool/ThreadPoolDelReqDTO.java @@ -0,0 +1,29 @@ +package com.github.dynamic.threadpool.config.model.biz.threadpool; + +import lombok.Data; + +/** + * ThreadPool del req dto. + * + * @author chen.ma + * @date 2021/11/11 21:40 + */ +@Data +public class ThreadPoolDelReqDTO { + + /** + * tenantId + */ + private String tenantId; + + /** + * itemId + */ + private String itemId; + + /** + * tpId + */ + private String tpId; + +} diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/service/ConfigCacheService.java b/config/src/main/java/com/github/dynamic/threadpool/config/service/ConfigCacheService.java index 13a10616..cd4e9bfe 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/service/ConfigCacheService.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/service/ConfigCacheService.java @@ -9,9 +9,11 @@ import com.github.dynamic.threadpool.config.event.LocalDataChangeEvent; import com.github.dynamic.threadpool.config.model.CacheItem; import com.github.dynamic.threadpool.config.model.ConfigAllInfo; import com.github.dynamic.threadpool.config.notify.NotifyCenter; +import com.github.dynamic.threadpool.config.toolkit.MapUtil; import com.google.common.collect.Maps; import org.springframework.util.StringUtils; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -82,6 +84,9 @@ public class ConfigCacheService { CacheItem cache = makeSure(groupKey, ip); if (cache.md5 == null || !cache.md5.equals(md5)) { cache.md5 = md5; + String[] split = groupKey.split("\\+"); + ConfigAllInfo config = configService.findConfigAllInfo(split[0], split[1], split[2]); + cache.configAllInfo = config; cache.lastModifiedTs = System.currentTimeMillis(); NotifyCenter.publishEvent(new LocalDataChangeEvent(ip, groupKey)); } @@ -102,4 +107,11 @@ public class ConfigCacheService { return tmp; } + public static Map getContent(String identification) { + List identificationList = MapUtil.parseMapForFilter(CACHE, identification); + Map returnStrCacheItemMap = Maps.newHashMap(); + identificationList.forEach(each -> returnStrCacheItemMap.putAll(CACHE.get(each))); + return returnStrCacheItemMap; + } + } diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ThreadPoolService.java b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ThreadPoolService.java index 2e6864e9..0dc14014 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ThreadPoolService.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ThreadPoolService.java @@ -1,6 +1,7 @@ package com.github.dynamic.threadpool.config.service.biz; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolDelReqDTO; import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolQueryReqDTO; import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolRespDTO; import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO; @@ -47,4 +48,11 @@ public interface ThreadPoolService { */ void saveOrUpdateThreadPoolConfig(String identify, ThreadPoolSaveOrUpdateReqDTO reqDTO); + /** + * Delete pool. + * + * @param reqDTO + */ + void deletePool(ThreadPoolDelReqDTO reqDTO); + } diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ThreadPoolServiceImpl.java b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ThreadPoolServiceImpl.java index 79803949..dd2a7225 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ThreadPoolServiceImpl.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ThreadPoolServiceImpl.java @@ -1,13 +1,13 @@ package com.github.dynamic.threadpool.config.service.biz.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.dynamic.threadpool.config.enums.DelEnum; import com.github.dynamic.threadpool.config.mapper.ConfigInfoMapper; import com.github.dynamic.threadpool.config.model.ConfigAllInfo; +import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolDelReqDTO; import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolQueryReqDTO; import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolRespDTO; import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO; @@ -64,4 +64,14 @@ public class ThreadPoolServiceImpl implements ThreadPoolService { configService.insertOrUpdate(identify, BeanUtil.convert(reqDTO, ConfigAllInfo.class)); } + @Override + public void deletePool(ThreadPoolDelReqDTO reqDTO) { + configInfoMapper.delete( + Wrappers.lambdaUpdate(ConfigAllInfo.class) + .eq(ConfigAllInfo::getTenantId, reqDTO.getTenantId()) + .eq(ConfigAllInfo::getItemId, reqDTO.getItemId()) + .eq(ConfigAllInfo::getTpId, reqDTO.getTpId()) + ); + } + }