设备类型可修改相同名称bug解决

This commit is contained in:
liang.chao 2024-10-15 17:17:49 +08:00
parent 1581d47cc9
commit 849c4bddf6
2 changed files with 7 additions and 1 deletions

View File

@ -268,6 +268,12 @@ public class MaTypeController extends BaseController {
@Log(title = "机具类型管理ma_type", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MaType maType) {
Long parentId = maType.getParentId();
List<MaType> subMas = maTypeMapper.getListByParentId(parentId, null);
boolean containsSameBrother = subMas.stream().anyMatch(o -> o.getTypeName().equals(maType.getTypeName()));
if (containsSameBrother) {
return AjaxResult.error("修改失败,同级存在相同名称");
}
return toAjax(iTypeService.updateMaType(maType));
}

View File

@ -53,7 +53,7 @@ public class MaTypeServiceImpl implements ITypeService {
public int insertMaType(MaType maType) {
Long parentId = maType.getParentId();
List<MaType> subMas = maTypeMapper.getListByParentId(parentId, null);
boolean containsSameBrother = subMas.stream().anyMatch(o -> o.getTypeName().contains(maType.getTypeName()));
boolean containsSameBrother = subMas.stream().anyMatch(o -> o.getTypeName().equals(maType.getTypeName()));
if (containsSameBrother) {
return 0;
}