liurunyu
2023-11-12 1ff17fd97a85cd191467b4a2ffe0e4b7b1959af5
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java
@@ -12,16 +12,38 @@
@Service
public class DistrictSv {
    private BaDistrictMapper baDistrictMapper ;
    private BaDistrictMapper dao;
    @Autowired
    private void setBaDistrictMapper(BaDistrictMapper baDistrictMapper){
        this.baDistrictMapper = baDistrictMapper ;
    private void setDao(BaDistrictMapper dao){
        this.dao = dao;
    }
    /**
     * 保存实体
     * @param po 实体
     * @return 数量
     */
    public int save(BaDistrict po){
        return this.baDistrictMapper.insert(po) ;
        return this.dao.insert(po) ;
    }
    /**
     * 保存修改实体
     * @param po 实体
     * @return 数量
     */
    public int update(BaDistrict po){
        return this.dao.updateByPrimaryKeySelective(po) ;
    }
    /**
     * 保存修改实体
     * @param id 实体ID
     * @return 数量
     */
    public int delete(Long id){
        return this.dao.deleteLogicById(id) ;
    }
    /**
@@ -29,8 +51,8 @@
     * @param firstLevel 第一级行下区 level
     * @return 所有行政区划集合
     */
    public List<BaDistrict> getAll(byte firstLevel){
        List<BaDistrict> list = this.baDistrictMapper.selectByLevel(firstLevel) ;
    public List<BaDistrict> selectAllByLevel(byte firstLevel){
        List<BaDistrict> list = this.dao.selectByLevel(firstLevel) ;
        if(list != null && list.size() > 0){
            for(BaDistrict po : list){
                getSubDistrict(po) ;
@@ -40,12 +62,21 @@
    }
    /**
     * 得到一个行政区
     * @param id 行政区ID
     * @return 行政区实体
     */
    public BaDistrict selectById(Long id){
        return this.dao.selectByPrimaryKey(id) ;
    }
    /**
     * 得到下级行政区划
     * @param po 上级行政区划
     */
    private void getSubDistrict(BaDistrict po){
        if(po != null && po.id != null){
            po.subDistricts = this.baDistrictMapper.selectBySupperId(po.id) ;
            po.subDistricts = this.dao.selectBySupperId(po.id) ;
            if(po.subDistricts != null && po.subDistricts.size() > 0){
                for(BaDistrict subPo : po.subDistricts){
                    getSubDistrict(subPo) ;