From bd563bebae7b472fadbf348ec85367bbda3f3193 Mon Sep 17 00:00:00 2001
From: huanghongfa <huanghongfa123456>
Date: 星期二, 30 三月 2021 10:32:06 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
index 4748672..c9ca2ba 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
@@ -12,6 +12,7 @@
 import com.panzhihua.common.model.vos.community.ComStreetVO;
 import com.panzhihua.service_community.dao.ComActDAO;
 import com.panzhihua.service_community.dao.ComStreetDAO;
+import com.panzhihua.service_community.model.dos.ComActDO;
 import com.panzhihua.service_community.model.dos.ComStreetDO;
 import com.panzhihua.service_community.service.ComStreetService;
 import org.springframework.beans.BeanUtils;
@@ -74,14 +75,18 @@
      */
     @Override
     public R listStreet(ComStreetVO comStreetVO) {
-        List<ComStreetVO> vos = Lists.newArrayList();
         LambdaQueryWrapper<ComStreetDO> param = new QueryWrapper<ComStreetDO>().lambda();
-        param.eq(ComStreetDO::getProvinceCode, comStreetVO.getProvinceCode());
-        param.eq(ComStreetDO::getCityCode, comStreetVO.getCityCode());
-        param.eq(ComStreetDO::getAreaCode, comStreetVO.getCityCode());
-        List<ComStreetDO> ComStreetDOS = comStreetDAO.selectList(param);
-        BeanUtils.copyProperties(vos, ComStreetDOS);
-        return R.ok(comStreetVO);
+        if (comStreetVO.getProvinceCode() != null) {
+            param.eq(ComStreetDO::getProvinceCode, comStreetVO.getProvinceCode());
+        }
+        if (comStreetVO.getCityCode() != null) {
+            param.eq(ComStreetDO::getCityCode, comStreetVO.getCityCode());
+        }
+        if (comStreetVO.getAreaCode() != null) {
+            param.eq(ComStreetDO::getAreaCode, comStreetVO.getAreaCode());
+        }
+        List<ComStreetDO> comStreetDOS = comStreetDAO.selectList(param);
+        return R.ok(comStreetDOS);
     }
 
     /**
@@ -122,7 +127,7 @@
         page.setSize(pageSize);
         page.setCurrent(pageNum);
         LambdaQueryWrapper<ComStreetDO> userLambdaQueryWrapper = Wrappers.lambdaQuery();
-        if (!pageComStreetDTO.getName().isEmpty()) {
+        if (pageComStreetDTO.getName() != null) {
             userLambdaQueryWrapper.like(ComStreetDO::getName, pageComStreetDTO.getName());
         }
         Page userPage = new Page(pageNum, pageSize);
@@ -132,13 +137,18 @@
 
 
     /**
-     * 批量删除社区
-     *
+     * 批量删除街道
      * @param streetIds 社区id
      * @return 删除结果
      */
     @Override
     public R delectStreat(List<Long> streetIds) {
+        //不能删除,已经绑定了社区的街道
+        LambdaQueryWrapper<ComActDO> comActDOParam = new QueryWrapper<ComActDO>().lambda().in(ComActDO::getStreetId, streetIds);
+        List<ComActDO> comActDOS = comActDAO.selectList(comActDOParam);
+        if (comActDOS != null && comActDOS.size() > 0) {
+            return R.fail("删除失败,批量删除街道中,街道下有社区无法删除!");
+        }
         int delete = comStreetDAO.deleteBatchIds(streetIds);
         if (delete > 0) {
             return R.ok();

--
Gitblit v1.7.1