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