From bf05b81a0b00779f12ce3747493f805bf0cfa673 Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Sat, 22 Jun 2024 10:32:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CourseResourceController.java | 4 +-- .../impl/CourseResourcesServiceImpl.java | 35 +++++++++++++------ .../records/LearningRecordsServiceImpl.java | 29 ++++++++++++--- 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/teaching/backend/controller/courseResource/CourseResourceController.java b/src/main/java/com/teaching/backend/controller/courseResource/CourseResourceController.java index adc5c82..6abf652 100644 --- a/src/main/java/com/teaching/backend/controller/courseResource/CourseResourceController.java +++ b/src/main/java/com/teaching/backend/controller/courseResource/CourseResourceController.java @@ -52,8 +52,8 @@ public class CourseResourceController { @ApiOperation("根据ids删除") @DeleteMapping("/delete") public BaseResponse deleteRecords(@RequestParam List ids){ -// courseResourcesService.removeCourseResources(ids); - courseResourcesService.removeBatchByIds(ids); + courseResourcesService.removeCourseResources(ids); +// courseResourcesService.removeBatchByIds(ids); return ResultUtils.success("删除成功!!"); } diff --git a/src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java index 0dca631..d55b31b 100644 --- a/src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java @@ -7,9 +7,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.teaching.backend.mapper.records.LearningRecordsMapper; import com.teaching.backend.mapper.resource.CourseResourcesMapper; import com.teaching.backend.model.entity.CourseResources; import com.teaching.backend.model.entity.ResourceRelationship; +import com.teaching.backend.model.entity.records.LearningRecords; +import com.teaching.backend.service.impl.records.LearningRecordsServiceImpl; import com.teaching.backend.service.resource.CourseResourcesService; import com.teaching.backend.service.resource.ResourcesRelationshipService; import org.apache.commons.io.FileUtils; @@ -21,7 +24,9 @@ import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; /** * ClassName: FileTableImpl @@ -39,6 +44,8 @@ public class CourseResourcesServiceImpl extends ServiceImpl ids) { - LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(CourseResources::getId, ids); - List list = this.list(lambdaQueryWrapper); - courseResourcesMapper.deleteBatchIds(list); -// System.out.println(this.updateBatchById(list)); -// this.remove(lambdaQueryWrapper); + //删除资源在记录表里对应的记录 + List list = new ArrayList<>(); + for (Long id: ids) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + //System.out.println("id:"+id); + lambdaQueryWrapper.eq(LearningRecords::getCoursesId, id).eq(LearningRecords::getType, 4); + //System.out.println("资源对应的记录:"+learningRecordsMapper.selectList(lambdaQueryWrapper)); + list.addAll(learningRecordsMapper.selectList(lambdaQueryWrapper)); + //System.out.println("添加完后的集合:"+list); + } + learningRecordsMapper.deleteBatchIds(list); + //System.out.println(list); + //删除课程资源 + courseResourcesMapper.deleteBatchIds(ids); } @Override @@ -148,8 +163,8 @@ public class CourseResourcesServiceImpl extends ServiceImpl