完善[删除报表]接口,删除报表的同时会删除所有关联标签

This commit is contained in:
2023-04-21 13:47:43 +08:00
parent 40f780f7d8
commit 8fd3079588
3 changed files with 24 additions and 1 deletions
@@ -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<ReportLabelEntity> {
/**
* 根据报表Id删除所有报表标签关系
* @param reportIds 报表id
*/
void deleteReportLabelByReportId(List<String> reportIds);
}
@@ -151,7 +151,8 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
});
//修改报表标签关系表(先删后增)
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<ReportDao, ReportEntity>
public List<String> delete(String ids) {
List<String> 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");
@@ -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<ReportLabelDao, ReportLabelEntity>
implements IReportLabelService {
@Resource
private ReportLabelDao reportLabelDao;
@Override
public void deleteReportLabelByReportId(List<String> reportId) {
LambdaQueryWrapper<ReportLabelEntity> reportLabelWrapper = new LambdaQueryWrapper<>();
reportLabelWrapper.in(ReportLabelEntity::getReportId, reportId);
reportLabelDao.delete(reportLabelWrapper);
}
}