From 025beffb2f11ee696caa2771ac799890308dc58e Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期四, 16 十一月 2023 11:12:51 +0800 Subject: [PATCH] 行政区划Ctrl,接收前端提交的form为json类型 --- pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java | 57 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 46 insertions(+), 11 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java index 27c5a85..ff2cfeb 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java @@ -5,6 +5,7 @@ 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; @@ -12,16 +13,11 @@ @Service public class DistrictSv { - private BaDistrictMapper baDistrictMapper ; + private BaDistrictMapper dao; @Autowired - private void setBaDistrictMapper(BaDistrictMapper baDistrictMapper){ - this.baDistrictMapper = baDistrictMapper ; - } - - - public int save(BaDistrict po){ - return this.baDistrictMapper.insert(po) ; + private void setDao(BaDistrictMapper dao){ + this.dao = dao; } /** @@ -29,8 +25,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 +36,51 @@ } /** + * 寰楀埌涓�涓鏀垮尯 + * @param id 琛屾斂鍖篒D + * @return 琛屾斂鍖哄疄浣� + */ + public BaDistrict selectById(Long id){ + return this.dao.selectByPrimaryKey(id) ; + } + + /** + * 淇濆瓨瀹炰綋 + * @param po 瀹炰綋 + * @return 鏁伴噺 + */ + @Transactional + public int save(BaDistrict po){ + return this.dao.insert(po) ; + } + + /** + * 淇濆瓨淇敼瀹炰綋 + * @param po 瀹炰綋 + * @return 鏁伴噺 + */ + @Transactional + public int update(BaDistrict po){ + return this.dao.updateByPrimaryKeySelective(po) ; + } + + /** + * 淇濆瓨淇敼瀹炰綋 + * @param id 瀹炰綋ID + * @return 鏁伴噺 + */ + @Transactional + public int delete(Long id){ + return this.dao.deleteLogicById(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) ; -- Gitblit v1.8.0