Add condition to update if notification exists (#521)

pull/536/head
小马哥 2 years ago committed by GitHub
parent 02b7c224c7
commit 2d508c0dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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