Procházet zdrojové kódy

台区新增重复提示添加

jichaobo před 3 roky
rodič
revize
3021c584b2

+ 10 - 2
fiveep-service/src/main/java/com/bizmatics/service/impl/PlatformAreaServiceImpl.java

@@ -3,6 +3,7 @@ package com.bizmatics.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.bizmatics.common.core.bean.CommonPage;
+import com.bizmatics.common.core.exception.BusinessException;
 import com.bizmatics.common.mvc.base.AbstractCrudService;
 import com.bizmatics.model.Device;
 import com.bizmatics.model.DeviceAttribute;
@@ -42,8 +43,15 @@ public class PlatformAreaServiceImpl extends AbstractCrudService<PlatformAreaMap
 
     @Override
     public void platformAreaAdd(PlatformArea platformArea){
-        platformArea.setEnable(1);
-        this.save(platformArea);
+        LambdaQueryWrapper<PlatformArea> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PlatformArea::getEnable, 1).eq(PlatformArea::getPlatformAreaName, platformArea.getPlatformAreaName());
+        List<PlatformArea> platformAreaList = this.list(queryWrapper);
+        if (platformAreaList!=null&&!platformAreaList.isEmpty()){
+            throw new BusinessException("台区名称重复,不可重复添加台区");
+        }{
+            platformArea.setEnable(1);
+            this.save(platformArea);
+        }
     }
 
     @Override