use of com.hccake.ballcat.system.model.entity.SysDict in project ballcat by ballcat-projects.
the class SysDictManager method queryDictDataAndHashVO.
/**
* 查询字典数据
* @param dictCodes 字典标识
* @return DictDataAndHashVO
*/
public List<DictDataVO> queryDictDataAndHashVO(String[] dictCodes) {
List<DictDataVO> list = new ArrayList<>();
// 查询对应hash值,以及字典项数据
List<SysDict> sysDictList = sysDictService.listByCodes(dictCodes);
if (CollectionUtil.isNotEmpty(sysDictList)) {
for (SysDict sysDict : sysDictList) {
List<SysDictItem> dictItems = sysDictItemService.listByDictCode(sysDict.getCode());
// 排序并转换为VO
List<DictItemVO> setDictItems = dictItems.stream().sorted(Comparator.comparingInt(SysDictItem::getSort)).map(SysDictItemConverter.INSTANCE::poToItemVo).collect(Collectors.toList());
// 组装DataVO
DictDataVO dictDataVO = new DictDataVO();
dictDataVO.setValueType(sysDict.getValueType());
dictDataVO.setDictCode(sysDict.getCode());
dictDataVO.setHashCode(sysDict.getHashCode());
dictDataVO.setDictItems(setDictItems);
list.add(dictDataVO);
}
}
return list;
}
use of com.hccake.ballcat.system.model.entity.SysDict 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.model.entity.SysDict in project ballcat by ballcat-projects.
the class SysDictManager method removeDictById.
/**
* 删除字典
* @param id 字典id
*/
@Transactional(rollbackFor = Exception.class)
public void removeDictById(Integer id) {
// 查询现有数据
SysDict dict = sysDictService.getById(id);
// 字典标识
String dictCode = dict.getCode();
// 有关联字典项则不允许删除
Assert.isFalse(sysDictItemService.exist(dictCode), () -> new BusinessException(BaseResultCode.LOGIC_CHECK_ERROR.getCode(), "该字典下存在字典项,不允许删除!"));
// 删除字典
Assert.isTrue(sysDictService.removeById(id), () -> new BusinessException(BaseResultCode.UPDATE_DATABASE_ERROR.getCode(), "字典删除异常"));
}
Aggregations