package com.thhy.engineering.modules.biz.engineering.service.impl; import com.thhy.engineering.modules.biz.engineering.entity.CityPullDown; import com.thhy.engineering.modules.biz.engineering.mapper.SysDictMapper; import com.thhy.engineering.modules.biz.engineering.service.CityService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service public class CityServiceImpl implements CityService { @Autowired private SysDictMapper sysDictMapper; @Override public List cityPull() { List cityPullDownList = sysDictMapper.queryCity(100000); city(cityPullDownList); return cityPullDownList; } public void city(List cityPullDownList){ for(CityPullDown cityPullDown : cityPullDownList){ List cityPullDowns = sysDictMapper.queryCity(cityPullDown.getId()); if(cityPullDowns.size()>0){ city(cityPullDowns); cityPullDown.setHasChild(true); cityPullDown.setChilds(cityPullDowns); }else{ cityPullDown.setHasChild(false); } } } }