yanghui
2022-10-13 f1bcbc43e988d0d1a91bea66a9ebbf6d601e48c0
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ComAreaTownCommunityApi.java
@@ -1,17 +1,21 @@
package com.panzhihua.service_community.api;
import cn.hutool.core.util.ArrayUtil;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.service_community.dao.ComAreaTownCommunityDao;
import com.panzhihua.common.model.vos.community.acid.ComAreaCounty;
import com.panzhihua.service_community.entity.ComAreaTownCommunity;
import com.panzhihua.service_community.service.ComAreaTownCommunityService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -89,13 +93,26 @@
    }
    @GetMapping("/areaTownCommunity")
    public R test(@RequestParam("name")String name){
    public R test(@RequestParam("name")String name,@RequestParam("userId")Long userId){
        Long[] idArray={4L,17959L,16522L,16196L,16214L,17949L,89234L};
        if("panzhihua".equals(name)){
            List<ComAreaCounty> list=comAreaTownCommunityDao.selectArea();
            list.forEach(lis->{
                List<ComAreaCounty> townList=comAreaTownCommunityDao.selectTown(lis.getValue());
                townList.forEach(tow->{
                    tow.setChildren(comAreaTownCommunityDao.selectCommunity(tow.getValue()));
                    List<ComAreaCounty> list1=new ArrayList<>();
                    if(ArrayUtil.contains(idArray,userId)){
                        list1=comAreaTownCommunityDao.selectCommunity(tow.getValue(),"学园社区");
                    }
                    else {
                        list1=comAreaTownCommunityDao.selectCommunity(tow.getValue(),"");
                    }
                    if("大渡口街道".equals(tow.getValue())){
                        ComAreaCounty comAreaCounty=list1.get(0);
                        list1.remove(0);
                        list1.add(2,comAreaCounty);
                    }
                    tow.setChildren(list1);
                });
                lis.setChildren(townList);
            });
@@ -105,13 +122,26 @@
            List<ComAreaCounty> townList=comAreaTownCommunityDao.selectTown(name);
            if(!CollectionUtils.isEmpty(townList)){
                townList.forEach(tow->{
                    tow.setChildren(comAreaTownCommunityDao.selectCommunity(tow.getValue()));
                    List<ComAreaCounty> list1=new ArrayList<>();
                    if(ArrayUtil.contains(idArray,userId)){
                        list1=comAreaTownCommunityDao.selectCommunity(tow.getValue(),"学园社区");
                    }
                    else {
                        list1=comAreaTownCommunityDao.selectCommunity(tow.getValue(),"");
                    }
                    tow.setChildren(list1);
                });
                return R.ok(townList);
            }
            else {
                List<ComAreaCounty> list=comAreaTownCommunityDao.selectCommunity(name);
                return R.ok(list);
                List<ComAreaCounty> list1=new ArrayList<>();
                if(ArrayUtil.contains(idArray,userId)){
                    list1=comAreaTownCommunityDao.selectCommunity(name,"学园社区");
                }
                else {
                    list1=comAreaTownCommunityDao.selectCommunity(name,"");
                }
                return R.ok(list1);
            }
        }