Add condition to update if notification exists

pull/521/head
chen.ma 2 years ago
parent 97fb1deb74
commit 568fc56fd8

@ -55,7 +55,12 @@ public class DynamicThreadPoolRegisterWrapper {
/** /**
* Update if exists * Update if exists
*/ */
private Boolean updateIfExists = Boolean.TRUE; private Boolean updateIfExists = Boolean.FALSE;
/**
* Notify update if exists
*/
private Boolean notifyUpdateIfExists = Boolean.FALSE;
/** /**
* Dynamic thread-pool server notify parameter * Dynamic thread-pool server notify parameter

@ -63,9 +63,10 @@ public interface NotifyService {
/** /**
* Save or update. * Save or update.
* *
* @param notifyUpdateIfExists
* @param reqDTO * @param reqDTO
*/ */
void saveOrUpdate(NotifyReqDTO reqDTO); void saveOrUpdate(boolean notifyUpdateIfExists, NotifyReqDTO reqDTO);
/** /**
* Delete. * Delete.

@ -27,10 +27,7 @@ import cn.hippo4j.common.web.exception.ServiceException;
import cn.hippo4j.config.event.LocalDataChangeEvent; import cn.hippo4j.config.event.LocalDataChangeEvent;
import cn.hippo4j.config.mapper.ConfigInfoMapper; import cn.hippo4j.config.mapper.ConfigInfoMapper;
import cn.hippo4j.config.mapper.ConfigInstanceMapper; import cn.hippo4j.config.mapper.ConfigInstanceMapper;
import cn.hippo4j.config.model.ConfigAllInfo; import cn.hippo4j.config.model.*;
import cn.hippo4j.config.model.ConfigInfoBase;
import cn.hippo4j.config.model.ConfigInstanceInfo;
import cn.hippo4j.config.model.LogRecordInfo;
import cn.hippo4j.config.model.biz.notify.NotifyReqDTO; import cn.hippo4j.config.model.biz.notify.NotifyReqDTO;
import cn.hippo4j.config.service.ConfigCacheService; import cn.hippo4j.config.service.ConfigCacheService;
import cn.hippo4j.config.service.ConfigChangePublisher; import cn.hippo4j.config.service.ConfigChangePublisher;
@ -172,7 +169,7 @@ public class ConfigServiceImpl implements ConfigService {
} else { } else {
notifyReqDTO.setConfigType(true); notifyReqDTO.setConfigType(true);
} }
notifyService.saveOrUpdate(notifyReqDTO); notifyService.saveOrUpdate(registerWrapper.getNotifyUpdateIfExists(), notifyReqDTO);
}); });
} }
} }

@ -120,11 +120,14 @@ public class NotifyServiceImpl implements NotifyService {
} }
@Override @Override
public void saveOrUpdate(NotifyReqDTO reqDTO) { public void saveOrUpdate(boolean notifyUpdateIfExists, NotifyReqDTO reqDTO) {
try { try {
existNotify(reqDTO.getType(), reqDTO); existNotify(reqDTO.getType(), reqDTO);
save(reqDTO); save(reqDTO);
} catch (Exception ignored) { } catch (Exception ignored) {
if (!notifyUpdateIfExists) {
return;
}
LambdaQueryWrapper<NotifyInfo> queryWrapper = Wrappers.lambdaQuery(NotifyInfo.class) LambdaQueryWrapper<NotifyInfo> queryWrapper = Wrappers.lambdaQuery(NotifyInfo.class)
.eq(NotifyInfo::getTenantId, reqDTO.getTenantId()) .eq(NotifyInfo::getTenantId, reqDTO.getTenantId())
.eq(NotifyInfo::getItemId, reqDTO.getItemId()) .eq(NotifyInfo::getItemId, reqDTO.getItemId())

Loading…
Cancel
Save