diff --git a/adc-da-report/src/main/java/com/adc/da/report/service/IReportLabelService.java b/adc-da-report/src/main/java/com/adc/da/report/service/IReportLabelService.java index fb57539..0192326 100644 --- a/adc-da-report/src/main/java/com/adc/da/report/service/IReportLabelService.java +++ b/adc-da-report/src/main/java/com/adc/da/report/service/IReportLabelService.java @@ -3,6 +3,8 @@ package com.adc.da.report.service; import com.adc.da.report.eo.ReportLabelEntity; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** * @author ThinkBook * @description 针对表【ts_report_label】的数据库操作Service @@ -10,4 +12,9 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface IReportLabelService extends IService { + /** + * 根据报表Id删除所有报表标签关系 + * @param reportIds 报表id + */ + void deleteReportLabelByReportId(List reportIds); } diff --git a/adc-da-report/src/main/java/com/adc/da/report/service/impl/IReportServiceImpl.java b/adc-da-report/src/main/java/com/adc/da/report/service/impl/IReportServiceImpl.java index 8c47661..8ccadd2 100644 --- a/adc-da-report/src/main/java/com/adc/da/report/service/impl/IReportServiceImpl.java +++ b/adc-da-report/src/main/java/com/adc/da/report/service/impl/IReportServiceImpl.java @@ -151,7 +151,8 @@ public class IReportServiceImpl extends ServiceImpl }); //修改报表标签关系表(先删后增) - reportLabelDao.deleteById(entity.getId()); + iReportLabelService.deleteReportLabelByReportId(Collections.singletonList(entity.getId())); + //插入报表标签关系表 labelList.forEach((label) -> { ReportLabelEntity reportLabelEntity = new ReportLabelEntity(UUID.randomUUID10(), entity.getId(), label); @@ -284,6 +285,8 @@ public class IReportServiceImpl extends ServiceImpl public List delete(String ids) { List nameList = new ArrayList<>(); String[] idList = ids.split(","); + //删除所有报表标签关系记录 + iReportLabelService.deleteReportLabelByReportId(Collections.singletonList(Arrays.toString(idList))); for (String id : idList) { ReportEntity entity = reportDao.selectById(id); entity.setDelFlag("1"); diff --git a/adc-da-report/src/main/java/com/adc/da/report/service/impl/ReportLabelServiceImpl.java b/adc-da-report/src/main/java/com/adc/da/report/service/impl/ReportLabelServiceImpl.java index 05752d9..2e56309 100644 --- a/adc-da-report/src/main/java/com/adc/da/report/service/impl/ReportLabelServiceImpl.java +++ b/adc-da-report/src/main/java/com/adc/da/report/service/impl/ReportLabelServiceImpl.java @@ -1,11 +1,15 @@ package com.adc.da.report.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.adc.da.report.eo.ReportLabelEntity; import com.adc.da.report.service.IReportLabelService; import com.adc.da.report.dao.mysql.ReportLabelDao; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.List; + /** * @author ThinkBook * @description 针对表【ts_report_label】的数据库操作Service实现 @@ -15,6 +19,15 @@ import org.springframework.stereotype.Service; public class ReportLabelServiceImpl extends ServiceImpl implements IReportLabelService { + @Resource + private ReportLabelDao reportLabelDao; + + @Override + public void deleteReportLabelByReportId(List reportId) { + LambdaQueryWrapper reportLabelWrapper = new LambdaQueryWrapper<>(); + reportLabelWrapper.in(ReportLabelEntity::getReportId, reportId); + reportLabelDao.delete(reportLabelWrapper); + } }