Răsfoiți Sursa

国家地址库 问题处理

yzc 1 an în urmă
părinte
comite
13b4e0473a

+ 19 - 1
hx-area/src/main/java/com/fjhx/area/service/impl/CustomizeAreaServiceImpl.java

@@ -193,13 +193,31 @@ public class CustomizeAreaServiceImpl extends ServiceImpl<CustomizeAreaMapper, C
             throw new ServiceException("层级不能为空");
         }
         this.nameDuplication(CustomizeArea::getName, dto.getName(), "名称已存在请检查!");
+
+        long count = count(q -> q
+                .eq(CustomizeArea::getName, dto.getName())
+                .eq(CustomizeArea::getLevelCode, dto.getLevelCode())
+                .eq(CustomizeArea::getParentId, dto.getParentId())
+        );
+        if (count != 0) {
+            throw new ServiceException("名称已存在请检查!");
+        }
+
         this.save(dto);
     }
 
     @DS(BaseSourceConstant.BASE)
     @Override
     public void edit(CustomizeArea dto) {
-        this.nameDuplication(CustomizeArea::getName, dto.getName(), dto.getId(), "名称已存在请检查!");
+        long count = count(q -> q
+                .eq(CustomizeArea::getName, dto.getName())
+                .eq(CustomizeArea::getLevelCode, dto.getLevelCode())
+                .eq(CustomizeArea::getParentId, dto.getParentId())
+                .ne(CustomizeArea::getId, dto.getId())
+        );
+        if (count != 0) {
+            throw new ServiceException("名称已存在请检查!");
+        }
         this.updateById(dto);
     }