diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ConfigServiceImpl.java b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ConfigServiceImpl.java index aba12baa..84343a0e 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ConfigServiceImpl.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ConfigServiceImpl.java @@ -11,11 +11,10 @@ import com.github.dynamic.threadpool.config.event.LocalDataChangeEvent; import com.github.dynamic.threadpool.config.mapper.ConfigInfoMapper; import com.github.dynamic.threadpool.config.model.ConfigAllInfo; import com.github.dynamic.threadpool.config.service.ConfigChangePublisher; +import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import javax.annotation.Resource; - /** * Config service impl. * @@ -24,10 +23,10 @@ import javax.annotation.Resource; */ @Slf4j @Service +@AllArgsConstructor public class ConfigServiceImpl implements ConfigService { - @Resource - private ConfigInfoMapper configInfoMapper; + private final ConfigInfoMapper configInfoMapper; @Override public ConfigAllInfo findConfigAllInfo(String tpId, String itemId, String tenantId) { @@ -47,8 +46,7 @@ public class ConfigServiceImpl implements ConfigService { updateConfigInfo(configAllInfo); } - ConfigChangePublisher - .notifyConfigChange(new LocalDataChangeEvent(ContentUtil.getGroupKey(configAllInfo))); + ConfigChangePublisher.notifyConfigChange(new LocalDataChangeEvent(ContentUtil.getGroupKey(configAllInfo))); } private Integer addConfigInfo(ConfigAllInfo config) { @@ -74,6 +72,7 @@ public class ConfigServiceImpl implements ConfigService { config.setGmtCreate(null); config.setContent(ContentUtil.getPoolContent(config)); config.setMd5(Md5Util.getTpContentMd5(config)); + try { configInfoMapper.update(config, wrapper); } catch (Exception ex) { diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ItemServiceImpl.java b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ItemServiceImpl.java index e8df8d74..62d00995 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ItemServiceImpl.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ItemServiceImpl.java @@ -6,20 +6,19 @@ 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.config.enums.DelEnum; +import com.github.dynamic.threadpool.config.mapper.ItemInfoMapper; +import com.github.dynamic.threadpool.config.model.ItemInfo; import com.github.dynamic.threadpool.config.model.biz.item.ItemQueryReqDTO; import com.github.dynamic.threadpool.config.model.biz.item.ItemRespDTO; import com.github.dynamic.threadpool.config.model.biz.item.ItemSaveReqDTO; import com.github.dynamic.threadpool.config.model.biz.item.ItemUpdateReqDTO; import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolRespDTO; -import com.github.dynamic.threadpool.config.enums.DelEnum; -import com.github.dynamic.threadpool.config.mapper.ItemInfoMapper; -import com.github.dynamic.threadpool.config.model.ItemInfo; import com.github.dynamic.threadpool.config.toolkit.BeanUtil; +import lombok.AllArgsConstructor; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.List; /** @@ -29,13 +28,12 @@ import java.util.List; * @date 2021/6/29 21:58 */ @Service +@AllArgsConstructor public class ItemServiceImpl implements ItemService { - @Resource - private ItemInfoMapper itemInfoMapper; + private final ItemInfoMapper itemInfoMapper; - @Autowired - private ThreadPoolService threadPoolService; + private final ThreadPoolService threadPoolService; @Override public IPage queryItemPage(ItemQueryReqDTO reqDTO) { @@ -108,6 +106,7 @@ public class ItemServiceImpl implements ItemService { .eq(ItemInfo::getTenantId, namespace) .eq(ItemInfo::getItemId, itemId) .set(ItemInfo::getDelFlag, DelEnum.DELETE.getIntCode())); + boolean retBool = SqlHelper.retBool(updateResult); if (!retBool) { throw new RuntimeException("Delete error."); diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/TenantServiceImpl.java b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/TenantServiceImpl.java index 5fbcef1b..03369f41 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/TenantServiceImpl.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/TenantServiceImpl.java @@ -6,21 +6,20 @@ 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.config.enums.DelEnum; +import com.github.dynamic.threadpool.config.mapper.TenantInfoMapper; +import com.github.dynamic.threadpool.config.model.TenantInfo; import com.github.dynamic.threadpool.config.model.biz.item.ItemQueryReqDTO; import com.github.dynamic.threadpool.config.model.biz.item.ItemRespDTO; import com.github.dynamic.threadpool.config.model.biz.tenant.TenantQueryReqDTO; import com.github.dynamic.threadpool.config.model.biz.tenant.TenantRespDTO; import com.github.dynamic.threadpool.config.model.biz.tenant.TenantSaveReqDTO; import com.github.dynamic.threadpool.config.model.biz.tenant.TenantUpdateReqDTO; -import com.github.dynamic.threadpool.config.enums.DelEnum; -import com.github.dynamic.threadpool.config.mapper.TenantInfoMapper; -import com.github.dynamic.threadpool.config.model.TenantInfo; import com.github.dynamic.threadpool.config.toolkit.BeanUtil; +import lombok.AllArgsConstructor; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.List; /** @@ -30,13 +29,12 @@ import java.util.List; * @date 2021/6/29 21:12 */ @Service +@AllArgsConstructor public class TenantServiceImpl implements TenantService { - @Autowired - private ItemService itemService; + private final ItemService itemService; - @Resource - private TenantInfoMapper tenantInfoMapper; + private final TenantInfoMapper tenantInfoMapper; @Override public TenantRespDTO getTenantById(String tenantId) { @@ -75,6 +73,7 @@ public class TenantServiceImpl implements TenantService { TenantInfo tenantInfo = BeanUtil.convert(reqDTO, TenantInfo.class); int updateResult = tenantInfoMapper.update(tenantInfo, Wrappers .lambdaUpdate(TenantInfo.class).eq(TenantInfo::getTenantId, reqDTO.getTenantId())); + boolean retBool = SqlHelper.retBool(updateResult); if (!retBool) { throw new RuntimeException("Update Error."); @@ -94,6 +93,7 @@ public class TenantServiceImpl implements TenantService { Wrappers.lambdaUpdate(TenantInfo.class) .eq(TenantInfo::getTenantId, tenantId) .set(TenantInfo::getDelFlag, DelEnum.DELETE.getIntCode())); + boolean retBool = SqlHelper.retBool(updateResult); if (!retBool) { throw new RuntimeException("Delete error."); diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ThreadPoolServiceImpl.java b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ThreadPoolServiceImpl.java index 16fa4e34..314cc111 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ThreadPoolServiceImpl.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/service/biz/ThreadPoolServiceImpl.java @@ -4,16 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.mapper.ConfigInfoMapper; +import com.github.dynamic.threadpool.config.model.ConfigAllInfo; 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; -import com.github.dynamic.threadpool.config.mapper.ConfigInfoMapper; -import com.github.dynamic.threadpool.config.model.ConfigAllInfo; import com.github.dynamic.threadpool.config.toolkit.BeanUtil; -import org.springframework.beans.factory.annotation.Autowired; +import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.List; /** @@ -23,13 +22,12 @@ import java.util.List; * @date 2021/6/30 21:26 */ @Service +@AllArgsConstructor public class ThreadPoolServiceImpl implements ThreadPoolService { - @Autowired - private ConfigService configService; + private final ConfigService configService; - @Resource - private ConfigInfoMapper configInfoMapper; + private final ConfigInfoMapper configInfoMapper; @Override public IPage queryThreadPoolPage(ThreadPoolQueryReqDTO reqDTO) { diff --git a/config/src/main/java/com/github/dynamic/threadpool/config/toolkit/ConfigExecutor.java b/config/src/main/java/com/github/dynamic/threadpool/config/toolkit/ConfigExecutor.java index ba4b0af6..473080b3 100644 --- a/config/src/main/java/com/github/dynamic/threadpool/config/toolkit/ConfigExecutor.java +++ b/config/src/main/java/com/github/dynamic/threadpool/config/toolkit/ConfigExecutor.java @@ -15,8 +15,7 @@ import java.util.concurrent.TimeUnit; public class ConfigExecutor { private static final ScheduledExecutorService LONG_POLLING_EXECUTOR = ExecutorFactory.Managed - .newSingleScheduledExecutorService("default group", - r -> new Thread(r, "long-polling")); + .newSingleScheduledExecutorService("default group", r -> new Thread(r, "long-polling")); public static void executeLongPolling(Runnable runnable) { LONG_POLLING_EXECUTOR.execute(runnable);