fix: 删除字典下的字典项方法缺失问题修复

This commit is contained in:
ray
2024-07-10 22:11:05 +08:00
parent f7ccd5f103
commit 16621a4199

View File

@@ -114,14 +114,14 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
public boolean updateDict(Long id, DictForm dictForm) {
// 更新字典
SysDict entity = dictConverter.convertToEntity(dictForm);
// 校验 code 是否唯一
long count = this.count(new LambdaQueryWrapper<SysDict>()
.eq(SysDict::getCode, entity.getCode())
.ne(SysDict::getId, id)
);
Assert.isTrue(count == 0, "字典编码已存在");
boolean result = this.updateById(entity);
if (result) {
@@ -187,7 +187,10 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
boolean result = this.removeById(id);
if (result) {
// 删除字典下的字典项
dictItemService.removeByDictId(Convert.toLong(id));
dictItemService.remove(
new LambdaQueryWrapper<SysDictItem>()
.eq(SysDictItem::getDictId, id)
);
}
}
}
@@ -201,7 +204,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
public List<Option> listDictItemsByCode(String code) {
// 根据字典编码获取字典ID
SysDict dict = this.getOne(new LambdaQueryWrapper<SysDict>()
.eq(SysDict::getCode, code)
.eq(SysDict::getCode, code)
.select(SysDict::getId)
.last("limit 1")
);