use of com.albedo.java.common.event.listener.ParameterUpdateEvent in project albedo by somowhere.
the class ParameterServiceImpl method updateById.
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateById(ParameterDo model) {
long count = count(Wraps.<ParameterDo>lbQ().eq(ParameterDo::getKey, model.getKey()).ne(ParameterDo::getId, model.getId()));
ArgumentAssert.isFalse(count > 0, StrUtil.format("参数key[{}]已经存在,请勿重复创建", model.getKey()));
boolean bool = SqlHelper.retBool(getBaseMapper().updateById(model));
if (bool) {
CacheKey cacheKey = new ParameterKeyCacheKeyBuilder().key(model.getKey());
cacheOps.set(cacheKey, model.getValue());
SpringContextHolder.publishEvent(new ParameterUpdateEvent(new ParameterUpdate(model.getKey(), model.getValue(), null, ContextUtil.getTenant())));
}
return bool;
}
use of com.albedo.java.common.event.listener.ParameterUpdateEvent in project albedo by somowhere.
the class ParameterServiceImpl method removeByIds.
@Override
@Transactional(rollbackFor = Exception.class)
public boolean removeByIds(Collection<?> idList) {
if (CollectionUtils.isEmpty(idList)) {
return true;
}
List<ParameterDo> parameterDoList = super.listByIds((Collection<? extends Serializable>) idList);
if (parameterDoList.isEmpty()) {
return true;
}
boolean bool = SqlHelper.retBool(getBaseMapper().deleteBatchIds(idList));
CacheKey[] keys = parameterDoList.stream().map(item -> new ParameterKeyCacheKeyBuilder().key(item.getKey())).toArray(CacheKey[]::new);
cacheOps.del(keys);
parameterDoList.forEach(model -> SpringContextHolder.publishEvent(new ParameterUpdateEvent(new ParameterUpdate(model.getKey(), model.getValue(), null, ContextUtil.getTenant()))));
return bool;
}
Aggregations