@Override
public PageResult<DictPageVO> pageDict(DictPageDTO dto) {
IPage<DictPageVO> result = dictService.page(dto.toPage(), Wrappers.<BtDictionaryEntity>query().lambda()
.like(StringUtils.isNotBlank(dto.getDictCode()), BtDictionaryEntity::getDictCode, dto.getDictCode())
.like(StringUtils.isNotBlank(dto.getDictName()), BtDictionaryEntity::getDictName, dto.getDictName())
.eq(ObjectUtil.isNotNull(dto.getDictStatus()), BtDictionaryEntity::getDictStatus, dto.getDictStatus())
.eq(ObjectUtil.isNotNull(dto.getDictType()), BtDictionaryEntity::getDictType, dto.getDictType())
.orderByAsc(BtDictionaryEntity::getDictSort)
.orderByDesc(BtDictionaryEntity::getCreateTime))
.convert(response -> BeanUtil.toBean(response, DictPageVO.class));
return PageResult.toResult(result);
}
@Override
@DictCache(key = KeyEnum.DATA)
public void saveOrUpdateDict(DictSaveOrUpdateDTO dto) {
BtDictionaryEntity dict = BeanUtil.toBean(dto, BtDictionaryEntity.class);
if(dictService.saveOrUpdate(dict)) {
dataService.update(BtDictionaryDataEntity.builder().dataStatus(dto.getDictStatus()).build(), Wrappers.<BtDictionaryDataEntity>lambdaQuery().eq(BtDictionaryDataEntity::getDictId, dict.getId()));
}
}
@Override
@DictCache(key = KeyEnum.DATA)
public void delDicts(IdsDTO dto) {
if(dictService.removeByIds(dto.getIds())) {
dataService.remove(Wrappers.<BtDictionaryDataEntity>lambdaQuery().in(BtDictionaryDataEntity::getDictId, dto.getIds()));
}
}