From bbb9e7153ee97aaf2a5fa9819bab028bd5a71472 Mon Sep 17 00:00:00 2001
From: fengjin <1435304038@qq.com>
Date: 星期三, 16 十一月 2022 16:05:24 +0800
Subject: [PATCH] 1.增加删除评论功能 2.修改根据办事指南id获取所属地区 3.修改接口文档

---
 flower_city/src/main/java/com/dg/core/service/impl/AreaCodeServiceImpl.java |   61 +++++++++++++++---------------
 1 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/flower_city/src/main/java/com/dg/core/service/impl/AreaCodeServiceImpl.java b/flower_city/src/main/java/com/dg/core/service/impl/AreaCodeServiceImpl.java
index 7fd2db9..ae227e7 100644
--- a/flower_city/src/main/java/com/dg/core/service/impl/AreaCodeServiceImpl.java
+++ b/flower_city/src/main/java/com/dg/core/service/impl/AreaCodeServiceImpl.java
@@ -13,6 +13,7 @@
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 
@@ -26,52 +27,52 @@
     private TransactionEventMapper transactionEventMapper;
 
     @Override
-    public List<AreaCode2022> getAreaCodeByTransactionId(Integer transactionId){
-//        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
+    public List<AreaCode2022> getAreaCodeByTransactionId(Integer transactionId) {
+        List<String> areaCodes = new ArrayList<>();
         TransactionEvent transactionEvent = transactionEventMapper.selectOne(new QueryWrapper<TransactionEvent>().lambda().
                 eq(TransactionEvent::getId, transactionId));
-        OrganizationChartEntity organizationChartEntity = organizationChartMapper.selectOne(new QueryWrapper<OrganizationChartEntity>().lambda()
-                .eq(OrganizationChartEntity::getId, transactionEvent.getDepartmentId()));
-        List<String> areaCodes=new ArrayList<>();
-        if (organizationChartEntity!=null){
-           if (organizationChartEntity.getCity()!=null)
-             areaCodes.add(organizationChartEntity.getCity());
-           if (organizationChartEntity.getDistrict()!=null)
-             areaCodes.add(organizationChartEntity.getDistrict());
-           if (organizationChartEntity.getVillage()!=null)
-             areaCodes.add(organizationChartEntity.getVillage());
-           getAreaCodeIds(areaCodes,organizationChartEntity);
+        List<String> departmentIds = new ArrayList<>(Arrays.asList(transactionEvent.getDepartmentIds().split(",")));
+        departmentIds.add(transactionEvent.getDepartmentId());
+        for (String departmentId : departmentIds) {
+            OrganizationChartEntity organizationChartEntity = organizationChartMapper.selectOne(new QueryWrapper<OrganizationChartEntity>().lambda()
+                    .eq(OrganizationChartEntity::getId, departmentId));
+            if (organizationChartEntity != null) {
+                if (organizationChartEntity.getCity() != null)
+                    areaCodes.add(organizationChartEntity.getCity());
+                if (organizationChartEntity.getDistrict() != null)
+                    areaCodes.add(organizationChartEntity.getDistrict());
+                if (organizationChartEntity.getVillage() != null)
+                    areaCodes.add(organizationChartEntity.getVillage());
+            }
+
         }
-        if (areaCodes.size()==0)
-            return null;
-        else
-           return baseMapper.selectByIdSet(areaCodes);
+        return baseMapper.selectByIdSet(areaCodes);
     }
 
 
-    public  List<String> getAreaCodeIds(List<String> areaCodes, OrganizationChartEntity organizationChartEntity){
-       List<OrganizationChartEntity>  organizationChartEntitys= organizationChartMapper.selectList(new QueryWrapper<OrganizationChartEntity>().lambda()
+    public List<String> getAreaCodeIds(List<String> areaCodes, OrganizationChartEntity organizationChartEntity) {
+        List<OrganizationChartEntity> organizationChartEntitys = organizationChartMapper.selectList(new QueryWrapper<OrganizationChartEntity>().lambda()
                 .eq(OrganizationChartEntity::getParentId, organizationChartEntity.getId()));
-        for (OrganizationChartEntity organizationChart:organizationChartEntitys) {
-            if (organizationChart.getCity()!=null)
+        for (OrganizationChartEntity organizationChart : organizationChartEntitys) {
+            if (organizationChart.getCity() != null)
                 areaCodes.add(organizationChart.getCity());
-            if (organizationChart.getDistrict()!=null)
+            if (organizationChart.getDistrict() != null)
                 areaCodes.add(organizationChart.getDistrict());
-            if (organizationChart.getVillage()!=null)
+            if (organizationChart.getVillage() != null)
                 areaCodes.add(organizationChart.getVillage());
-            getAreaCodeIds(areaCodes,organizationChart);
+            getAreaCodeIds(areaCodes, organizationChart);
         }
-        return  areaCodes;
+        return areaCodes;
     }
 
     @Override
-    public  List<AreaCode2022> getListByPCode(String id){
+    public List<AreaCode2022> getListByPCode(String id) {
         List<AreaCode2022> areaCode2022s = baseMapper.selectList(new QueryWrapper<AreaCode2022>().lambda().eq(AreaCode2022::getPcode, id));
-        for (AreaCode2022 areaCode2022:areaCode2022s) {
-            if (areaCode2022.getLevel()!=3)
-              areaCode2022.setChild(this.getListByPCode(areaCode2022.getCode().toString()));
+        for (AreaCode2022 areaCode2022 : areaCode2022s) {
+            if (areaCode2022.getLevel() != 3)
+                areaCode2022.setChild(this.getListByPCode(areaCode2022.getCode().toString()));
         }
-      return  areaCode2022s;
+        return areaCode2022s;
     }
 
 

--
Gitblit v1.7.1