Browse Source

修改活动校验名字不能重复

luyanwen-001 3 years ago
parent
commit
f142bcdf8a

+ 14 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/ActiveServiceImpl.java

@@ -36,6 +36,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import java.time.LocalDateTime;
 import java.util.List;
@@ -111,7 +112,19 @@ public class ActiveServiceImpl implements ActiveService {
         AssertUtil.isNull(active, "活动不存在");
 
         //校验活动名称是否存在
-        checkActiveName(req.getActiveName());
+//        checkActiveName(req.getActiveName());
+        QueryWrapper<BaseActive> qw = new QueryWrapper<>();
+        qw.eq("active_name", req.getActiveName());
+        qw.eq("is_delete", 0);
+        List<BaseActive> activeList = baseActiveMapper.selectList(qw);
+        if(!CollectionUtils.isEmpty(activeList) && activeList.size()>=2){
+            throw new BusinessException("活动名称已存在。");
+        }
+        if(!CollectionUtils.isEmpty(activeList) && activeList.size()==1){
+            if(!activeList.get(0).getId().equals(active.getId())){
+                throw new BusinessException("活动名称已存在。");
+            }
+        }
 
         if (ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())) {
             throw new BusinessException("该数据已审核通过,请调用码活动申请单的接口。");