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
*/
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

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

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

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

Loading…
Cancel
Save