diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/mapper/PlantsPlanProductMapper.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/mapper/PlantsPlanProductMapper.java index 44f2a5bb..c933d2c8 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/mapper/PlantsPlanProductMapper.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/mapper/PlantsPlanProductMapper.java @@ -17,6 +17,7 @@ import java.util.List; public interface PlantsPlanProductMapper extends BaseMapperPlus { void deleteByPlanId(Long planId); + void deleteByPlanIds(List planIds); List queryProductsInfo(Long planId); } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsPlanProductService.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsPlanProductService.java index d7a72d32..50015766 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsPlanProductService.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsPlanProductService.java @@ -67,6 +67,12 @@ public interface IPlantsPlanProductService { */ Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + /** + * 根据方案id删除方案产品 + * @param ids + */ + void deleteByPlanIds(List ids); + /** * 批量保存租赁方案植物 * diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsPlanProductServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsPlanProductServiceImpl.java index 0ea6d4bd..1d6f5474 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsPlanProductServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsPlanProductServiceImpl.java @@ -159,6 +159,7 @@ public class PlantsPlanProductServiceImpl implements IPlantsPlanProductService { /** * 查询租赁方案植物数据 + * * @param planId * @return */ @@ -166,4 +167,17 @@ public class PlantsPlanProductServiceImpl implements IPlantsPlanProductService { public List queryPlanProductsInfo(Long planId) { return baseMapper.queryProductsInfo(planId); } + + /** + * 根据方案id删除方案产品 + * + * @param ids 方案id + * @return + */ + @Override + public void deleteByPlanIds(List ids) { + if (CollectionUtils.isNotEmpty(ids)) { + baseMapper.deleteByPlanIds(ids); + } + } } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsRentalPlanServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsRentalPlanServiceImpl.java index d63c6278..a4947964 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsRentalPlanServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsRentalPlanServiceImpl.java @@ -25,6 +25,7 @@ import org.dromara.property.domain.vo.PlantsRentalPlanVo; import org.dromara.property.domain.PlantsRentalPlan; import org.dromara.property.mapper.PlantsRentalPlanMapper; import org.dromara.property.service.IPlantsRentalPlanService; +import org.springframework.transaction.annotation.Transactional; import java.util.*; @@ -166,6 +167,7 @@ public class PlantsRentalPlanServiceImpl implements IPlantsRentalPlanService { * @return 是否删除成功 */ @Override + @Transactional(rollbackFor = Exception.class) public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { if(isValid){ PlantsRentalOrderBo plantsRentalOrderBo = new PlantsRentalOrderBo(); @@ -174,6 +176,8 @@ public class PlantsRentalPlanServiceImpl implements IPlantsRentalPlanService { if(CollectionUtils.isNotEmpty(plantsRentalOrderVos)){ throw new ServiceException("当前选中租赁方案不可删除"); } + //删除方案产品数据 + planProductService.deleteByPlanIds(ids.stream().toList()); } return baseMapper.deleteByIds(ids) > 0; } diff --git a/ruoyi-modules/Property/src/main/resources/mapper/Property/PlantsPlanProductMapper.xml b/ruoyi-modules/Property/src/main/resources/mapper/Property/PlantsPlanProductMapper.xml index f46532f8..d07caa86 100644 --- a/ruoyi-modules/Property/src/main/resources/mapper/Property/PlantsPlanProductMapper.xml +++ b/ruoyi-modules/Property/src/main/resources/mapper/Property/PlantsPlanProductMapper.xml @@ -26,6 +26,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from plants_plan_product p where p.plan_id=#{planId} + + delete from plants_plan_product p where p.plan_id in + + #{planId} + + +