use of com.hccake.ballcat.common.core.exception.BusinessException 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));
}
Aggregations