fix: 删除字典下的字典项方法缺失问题修复
This commit is contained in:
@@ -114,14 +114,14 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||||||
public boolean updateDict(Long id, DictForm dictForm) {
|
public boolean updateDict(Long id, DictForm dictForm) {
|
||||||
// 更新字典
|
// 更新字典
|
||||||
SysDict entity = dictConverter.convertToEntity(dictForm);
|
SysDict entity = dictConverter.convertToEntity(dictForm);
|
||||||
|
|
||||||
// 校验 code 是否唯一
|
// 校验 code 是否唯一
|
||||||
long count = this.count(new LambdaQueryWrapper<SysDict>()
|
long count = this.count(new LambdaQueryWrapper<SysDict>()
|
||||||
.eq(SysDict::getCode, entity.getCode())
|
.eq(SysDict::getCode, entity.getCode())
|
||||||
.ne(SysDict::getId, id)
|
.ne(SysDict::getId, id)
|
||||||
);
|
);
|
||||||
Assert.isTrue(count == 0, "字典编码已存在");
|
Assert.isTrue(count == 0, "字典编码已存在");
|
||||||
|
|
||||||
boolean result = this.updateById(entity);
|
boolean result = this.updateById(entity);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -187,7 +187,10 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||||||
boolean result = this.removeById(id);
|
boolean result = this.removeById(id);
|
||||||
if (result) {
|
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) {
|
public List<Option> listDictItemsByCode(String code) {
|
||||||
// 根据字典编码获取字典ID
|
// 根据字典编码获取字典ID
|
||||||
SysDict dict = this.getOne(new LambdaQueryWrapper<SysDict>()
|
SysDict dict = this.getOne(new LambdaQueryWrapper<SysDict>()
|
||||||
.eq(SysDict::getCode, code)
|
.eq(SysDict::getCode, code)
|
||||||
.select(SysDict::getId)
|
.select(SysDict::getId)
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user