|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoBa.BaDistrict; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.util.DistrictLevel; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | 
|---|
|  |  |  | List<BaDistrict> list = this.dao.selectByLevel(firstLevel) ; | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | for(BaDistrict po : list){ | 
|---|
|  |  |  | po.canDelete = false ; | 
|---|
|  |  |  | po.canAdd = true ; | 
|---|
|  |  |  | getSubDistrict(po) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public int save(BaDistrict po){ | 
|---|
|  |  |  | return this.dao.insert(po) ; | 
|---|
|  |  |  | return this.dao.putin(po) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | for(BaDistrict subPo : po.subDistricts){ | 
|---|
|  |  |  | getSubDistrict(subPo) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //没有下级了,可以删除 | 
|---|
|  |  |  | po.canDelete = false ; | 
|---|
|  |  |  | if(po.level.code.byteValue() == DistrictLevel.Village.code.byteValue()){ | 
|---|
|  |  |  | //到村级了,不可以再添加行政区了 | 
|---|
|  |  |  | po.canAdd = false ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据级别获取行政区划列表 | 
|---|
|  |  |  | * @param level | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public List<Map<String, Object>> getDistrictgsByLevel(Integer level) { | 
|---|
|  |  |  | return dao.getDistrictgsByLevel(level); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据父ID获取行政区划列表 | 
|---|
|  |  |  | * @param supperId | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public List<Map<String, Object>> getDistrictsBySupperId(Long supperId) { | 
|---|
|  |  |  | return dao.getDistrictsBySupperId(supperId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|