浏览代码

添加建筑加上条件判断

lin 4 年之前
父节点
当前提交
6df018a09b

+ 7 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/BuildingServiceImpl.java

@@ -1020,6 +1020,10 @@ public class BuildingServiceImpl implements BuildingService {
         if (nameResult > 0) {
             throw new ServiceException(-900, "建筑名称已经存在");
         }
+
+        if(building.getProvince() == null || building.getProvince() == 0){
+            throw new ServiceException(-900, "获取省市区编码错误,请重新输入");
+        }
         building.setSiteId(loginUser.getSiteId());
         building.setStatus(1);
         int result = this.insert(building);
@@ -1074,6 +1078,9 @@ public class BuildingServiceImpl implements BuildingService {
         if (nameResult > 0) {
             throw new ServiceException(-900, "建筑名称已经存在");
         }
+        if(building.getProvince() == null || building.getProvince() == 0){
+            throw new ServiceException(-900, "获取省市区编码错误,请重新输入");
+        }
         int result = this.updateByPrimaryKeySelective(building);
         //添加建筑