From 60cdfefbddc187fc13096ce952df7ccbe176ce0a Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Sat, 6 Nov 2021 23:11:15 +0800 Subject: [PATCH] =?UTF-8?q?Optimize:=20=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E4=BC=98=E5=8C=96.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dynamic/threadpool/common/toolkit/ConditionUtil.java | 3 +-- .../threadpool/config/controller/ConfigController.java | 8 ++++---- .../threadpool/config/notify/DefaultPublisher.java | 1 + .../config/service/biz/impl/ConfigServiceImpl.java | 1 + .../config/service/biz/impl/ItemServiceImpl.java | 4 ++-- .../config/service/biz/impl/LogRecordServiceImpl.java | 2 +- .../config/service/biz/impl/TenantServiceImpl.java | 5 +++-- .../config/service/biz/impl/ThreadPoolServiceImpl.java | 8 ++++++-- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/com/github/dynamic/threadpool/common/toolkit/ConditionUtil.java b/common/src/main/java/com/github/dynamic/threadpool/common/toolkit/ConditionUtil.java index b016647b..a59f9dd8 100644 --- a/common/src/main/java/com/github/dynamic/threadpool/common/toolkit/ConditionUtil.java +++ b/common/src/main/java/com/github/dynamic/threadpool/common/toolkit/ConditionUtil.java @@ -16,11 +16,10 @@ public class ConditionUtil { } } - public interface NoArgsConsumer { /** - * 执行方法 + * 方法执行 */ void accept(); diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/controller/ConfigController.java b/config/src/main/java/com/github/dynamic/threadpool/config/controller/ConfigController.java index 518821e6..f59dfc48 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/controller/ConfigController.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/controller/ConfigController.java @@ -8,6 +8,7 @@ import com.github.dynamic.threadpool.config.model.ConfigAllInfo; import com.github.dynamic.threadpool.config.model.ConfigInfoBase; import com.github.dynamic.threadpool.config.service.ConfigServletInner; import com.github.dynamic.threadpool.config.toolkit.Md5ConfigUtil; +import lombok.AllArgsConstructor; import lombok.SneakyThrows; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; @@ -25,14 +26,13 @@ import java.util.Map; * @date 2021/6/20 13:53 */ @RestController +@AllArgsConstructor @RequestMapping(Constants.CONFIG_CONTROLLER_PATH) public class ConfigController { - @Autowired - private ConfigService configService; + private final ConfigService configService; - @Autowired - private ConfigServletInner configServletInner; + private final ConfigServletInner configServletInner; @GetMapping public Result detailConfigInfo( diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/notify/DefaultPublisher.java b/config/src/main/java/com/github/dynamic/threadpool/config/notify/DefaultPublisher.java index ec6f2b1b..5a16ffdc 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/notify/DefaultPublisher.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/notify/DefaultPublisher.java @@ -131,4 +131,5 @@ public class DefaultPublisher extends Thread implements EventPublisher { notifySubscriber(subscriber, event); } } + } diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ConfigServiceImpl.java b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ConfigServiceImpl.java index 372c6b24..7b4748ed 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ConfigServiceImpl.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ConfigServiceImpl.java @@ -70,6 +70,7 @@ public class ConfigServiceImpl implements ConfigService { private Integer addConfigInfo(ConfigAllInfo config) { config.setContent(ContentUtil.getPoolContent(config)); config.setMd5(Md5Util.getTpContentMd5(config)); + try { if (SqlHelper.retBool(configInfoMapper.insert(config))) { return config.getId(); diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ItemServiceImpl.java b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ItemServiceImpl.java index cc7e03d8..57edd700 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ItemServiceImpl.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/ItemServiceImpl.java @@ -44,8 +44,8 @@ public class ItemServiceImpl implements ItemService { .eq(!StringUtils.isEmpty(reqDTO.getItemName()), ItemInfo::getItemName, reqDTO.getItemName()) .eq(!StringUtils.isEmpty(reqDTO.getTenantId()), ItemInfo::getTenantId, reqDTO.getTenantId()) .eq(!StringUtils.isEmpty(reqDTO.getOwner()), ItemInfo::getOwner, reqDTO.getOwner()); - Page resultPage = itemInfoMapper.selectPage(reqDTO, wrapper); + Page resultPage = itemInfoMapper.selectPage(reqDTO, wrapper); return resultPage.convert(each -> BeanUtil.convert(each, ItemRespDTO.class)); } @@ -55,8 +55,8 @@ public class ItemServiceImpl implements ItemService { .lambdaQuery(ItemInfo.class) .eq(ItemInfo::getTenantId, tenantId) .eq(ItemInfo::getItemId, itemId); - ItemInfo itemInfo = itemInfoMapper.selectOne(queryWrapper); + ItemInfo itemInfo = itemInfoMapper.selectOne(queryWrapper); ItemRespDTO result = BeanUtil.convert(itemInfo, ItemRespDTO.class); return result; } diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/LogRecordServiceImpl.java b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/LogRecordServiceImpl.java index b9360832..ac307674 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/LogRecordServiceImpl.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/LogRecordServiceImpl.java @@ -16,7 +16,7 @@ import org.springframework.stereotype.Service; @AllArgsConstructor public class LogRecordServiceImpl implements LogRecordService { - private LogRecordMapper logRecordMapper; + private final LogRecordMapper logRecordMapper; @Override public void record(LogRecordInfo logRecordInfo) { diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/TenantServiceImpl.java b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/TenantServiceImpl.java index ccbe7af4..b58e9b10 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/TenantServiceImpl.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/impl/TenantServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; +import com.github.dynamic.threadpool.common.toolkit.Assert; import com.github.dynamic.threadpool.config.enums.DelEnum; import com.github.dynamic.threadpool.config.mapper.TenantInfoMapper; import com.github.dynamic.threadpool.config.model.TenantInfo; @@ -48,8 +49,8 @@ public class TenantServiceImpl implements TenantService { public TenantRespDTO getTenantByTenantId(String tenantId) { LambdaQueryWrapper queryWrapper = Wrappers .lambdaQuery(TenantInfo.class).eq(TenantInfo::getTenantId, tenantId); - TenantInfo tenantInfo = tenantInfoMapper.selectOne(queryWrapper); + TenantInfo tenantInfo = tenantInfoMapper.selectOne(queryWrapper); TenantRespDTO result = BeanUtil.convert(tenantInfo, TenantRespDTO.class); return result; } @@ -60,8 +61,8 @@ public class TenantServiceImpl implements TenantService { .eq(!StringUtils.isEmpty(reqDTO.getTenantId()), TenantInfo::getTenantId, reqDTO.getTenantId()) .eq(!StringUtils.isEmpty(reqDTO.getTenantName()), TenantInfo::getTenantName, reqDTO.getTenantName()) .eq(!StringUtils.isEmpty(reqDTO.getOwner()), TenantInfo::getOwner, reqDTO.getOwner()); - Page resultPage = tenantInfoMapper.selectPage(reqDTO, wrapper); + Page resultPage = tenantInfoMapper.selectPage(reqDTO, wrapper); return resultPage.convert(each -> BeanUtil.convert(each, TenantRespDTO.class)); } 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 c3ec1a72..79803949 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,6 +1,7 @@ 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; @@ -39,6 +40,7 @@ public class ThreadPoolServiceImpl implements ThreadPoolService { .eq(!StringUtils.isBlank(reqDTO.getItemId()), ConfigAllInfo::getItemId, reqDTO.getItemId()) .eq(!StringUtils.isBlank(reqDTO.getTpId()), ConfigAllInfo::getTpId, reqDTO.getTpId()) .eq(ConfigAllInfo::getDelFlag, DelEnum.NORMAL); + return configInfoMapper.selectPage(reqDTO, wrapper).convert(each -> BeanUtil.convert(each, ThreadPoolRespDTO.class)); } @@ -50,8 +52,10 @@ public class ThreadPoolServiceImpl implements ThreadPoolService { @Override public List getThreadPoolByItemId(String itemId) { - List selectList = configInfoMapper - .selectList(Wrappers.lambdaUpdate(ConfigAllInfo.class).eq(ConfigAllInfo::getItemId, itemId)); + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(ConfigAllInfo.class) + .eq(ConfigAllInfo::getItemId, itemId); + + List selectList = configInfoMapper.selectList(queryWrapper); return BeanUtil.convert(selectList, ThreadPoolRespDTO.class); }