use of com.hccake.ballcat.system.event.DictChangeEvent in project ballcat by ballcat-projects.
the class SysDictManager method removeDictItemById.
/**
* 删除字典项
* @param id 字典项
* @return 执行是否成功
*/
@Transactional(rollbackFor = Exception.class)
public boolean removeDictItemById(Integer id) {
// 根据ID查询字典
SysDictItem dictItem = sysDictItemService.getById(id);
String dictCode = dictItem.getDictCode();
// 更新字典项Hash值
if (!sysDictService.updateHashCode(dictCode)) {
return false;
}
boolean result = sysDictItemService.removeById(id);
if (result) {
eventPublisher.publishEvent(new DictChangeEvent(dictCode));
}
return true;
}
use of com.hccake.ballcat.system.event.DictChangeEvent in project ballcat by ballcat-projects.
the class SysDictManager method updateDictById.
/**
* 更新字典
* @param sysDict 字典对象
* @return 执行是否成功
*/
public boolean updateDictById(SysDict sysDict) {
// 查询现有数据
SysDict dict = sysDictService.getById(sysDict.getId());
sysDict.setHashCode(IdUtil.fastSimpleUUID());
boolean result = sysDictService.updateById(sysDict);
if (result) {
eventPublisher.publishEvent(new DictChangeEvent(dict.getCode()));
}
return result;
}
use of com.hccake.ballcat.system.event.DictChangeEvent in project ballcat by ballcat-projects.
the class SysDictManager method saveDictItem.
/**
* 新增字典项
* @param sysDictItem 字典项
* @return 执行是否成功
*/
@Transactional(rollbackFor = Exception.class)
public boolean saveDictItem(SysDictItem sysDictItem) {
// 更新字典项Hash值
String dictCode = sysDictItem.getDictCode();
if (!sysDictService.updateHashCode(dictCode)) {
return false;
}
boolean result = sysDictItemService.save(sysDictItem);
if (result) {
eventPublisher.publishEvent(new DictChangeEvent(dictCode));
}
return result;
}
use of com.hccake.ballcat.system.event.DictChangeEvent in project ballcat by ballcat-projects.
the class SysDictManager method updateDictItemStatusById.
/**
* 更新字典项状态
* @param itemId 字典项id
*/
@Transactional(rollbackFor = Exception.class)
public void updateDictItemStatusById(Integer itemId, Integer status) {
// 获取字典项
SysDictItem dictItem = sysDictItemService.getById(itemId);
Assert.notNull(dictItem, () -> new BusinessException(BaseResultCode.LOGIC_CHECK_ERROR.getCode(), "错误的字典项 id:" + itemId));
// 更新字典项状态
SysDictItem entity = new SysDictItem();
entity.setId(itemId);
entity.setStatus(status);
Assert.isTrue(sysDictItemService.updateById(entity), () -> new BusinessException(BaseResultCode.UPDATE_DATABASE_ERROR.getCode(), "字典项状态更新异常"));
// 更新字典 hash
String dictCode = dictItem.getDictCode();
Assert.isTrue(sysDictService.updateHashCode(dictCode), () -> new BusinessException(BaseResultCode.UPDATE_DATABASE_ERROR.getCode(), "字典 Hash 更新异常"));
// 发布字典更新事件
eventPublisher.publishEvent(new DictChangeEvent(dictCode));
}
use of com.hccake.ballcat.system.event.DictChangeEvent in project ballcat by ballcat-projects.
the class SysDictManager method updateDictItemById.
/**
* 更新字典项
* @param sysDictItem 字典项
* @return 执行是否成功
*/
@Transactional(rollbackFor = Exception.class)
public boolean updateDictItemById(SysDictItem sysDictItem) {
// 根据ID查询字典
String dictCode = sysDictItem.getDictCode();
// 更新字典项Hash值
if (!sysDictService.updateHashCode(dictCode)) {
return false;
}
boolean result = sysDictItemService.updateById(sysDictItem);
if (result) {
eventPublisher.publishEvent(new DictChangeEvent(dictCode));
}
return result;
}
Aggregations