|
|
|
@ -1,21 +1,26 @@
|
|
|
|
|
package com.github.dynamic.threadpool.config.service.biz.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
|
|
|
import com.github.dynamic.threadpool.common.toolkit.ConditionUtil;
|
|
|
|
|
import com.github.dynamic.threadpool.common.toolkit.ContentUtil;
|
|
|
|
|
import com.github.dynamic.threadpool.common.toolkit.Md5Util;
|
|
|
|
|
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.model.ConfigInfoBase;
|
|
|
|
|
import com.github.dynamic.threadpool.config.service.ConfigChangePublisher;
|
|
|
|
|
import com.github.dynamic.threadpool.config.service.biz.ConfigService;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Config service impl.
|
|
|
|
|
*
|
|
|
|
@ -35,19 +40,31 @@ public class ConfigServiceImpl implements ConfigService {
|
|
|
|
|
.eq(!StringUtils.isBlank(tpId), ConfigAllInfo::getTpId, tpId)
|
|
|
|
|
.eq(!StringUtils.isBlank(itemId), ConfigAllInfo::getItemId, itemId)
|
|
|
|
|
.eq(!StringUtils.isBlank(tenantId), ConfigAllInfo::getTenantId, tenantId);
|
|
|
|
|
|
|
|
|
|
ConfigAllInfo configAllInfo = configInfoMapper.selectOne(wrapper);
|
|
|
|
|
return configAllInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void insertOrUpdate(String identify, ConfigAllInfo configAllInfo) {
|
|
|
|
|
public void insertOrUpdate(String identify, ConfigAllInfo configInfo) {
|
|
|
|
|
LambdaQueryWrapper<ConfigAllInfo> queryWrapper = Wrappers.lambdaQuery(ConfigAllInfo.class)
|
|
|
|
|
.eq(ConfigAllInfo::getTenantId, configInfo.getTenantId())
|
|
|
|
|
.eq(ConfigInfoBase::getItemId, configInfo.getItemId())
|
|
|
|
|
.eq(ConfigInfoBase::getTpId, configInfo.getTpId());
|
|
|
|
|
ConfigAllInfo existConfig = configInfoMapper.selectOne(queryWrapper);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
addConfigInfo(configAllInfo);
|
|
|
|
|
ConditionUtil
|
|
|
|
|
.condition(
|
|
|
|
|
existConfig == null,
|
|
|
|
|
() -> addConfigInfo(configInfo),
|
|
|
|
|
() -> updateConfigInfo(configInfo)
|
|
|
|
|
);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
updateConfigInfo(configAllInfo);
|
|
|
|
|
updateConfigInfo(configInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConfigChangePublisher.notifyConfigChange(new LocalDataChangeEvent(identify, ContentUtil.getGroupKey(configAllInfo)));
|
|
|
|
|
ConfigChangePublisher.notifyConfigChange(new LocalDataChangeEvent(identify, ContentUtil.getGroupKey(configInfo)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Integer addConfigInfo(ConfigAllInfo config) {
|
|
|
|
@ -61,6 +78,7 @@ public class ConfigServiceImpl implements ConfigService {
|
|
|
|
|
log.error("[db-error] message :: {}", ex.getMessage(), ex);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|