From 05897862fae2d989895c3987a514cd8625c4a089 Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Sat, 22 Jun 2024 11:05:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BF=A1=E6=81=AF=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=90=8C=E6=97=B6=E5=88=A0=E9=99=A4=E5=AD=A6=E4=B9=A0?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/records/LearningRecordsController.java | 6 ++++-- .../service/impl/CourseResourcesServiceImpl.java | 2 +- .../service/impl/courses/CoursesServiceImpl.java | 11 +++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/teaching/backend/controller/records/LearningRecordsController.java b/src/main/java/com/teaching/backend/controller/records/LearningRecordsController.java index 361f2a7..4f769e5 100644 --- a/src/main/java/com/teaching/backend/controller/records/LearningRecordsController.java +++ b/src/main/java/com/teaching/backend/controller/records/LearningRecordsController.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.ResultUtils; +import com.teaching.backend.filter.ValidateParams; import com.teaching.backend.model.entity.records.LearningRecords; import com.teaching.backend.model.vo.records.LearningRecordsVo; import com.teaching.backend.service.impl.records.LearningRecordsServiceImpl; @@ -31,6 +32,7 @@ public class LearningRecordsController { * @return */ @ApiOperation("根据用户id查询学习记录") + @ValidateParams({"userId"}) @GetMapping("/getall") public BaseResponse getAll(@RequestParam(value = "pagenum", defaultValue = "1") int pagenum, @RequestParam(value = "pagesize", defaultValue = "10") int pagesize, @@ -69,6 +71,7 @@ public class LearningRecordsController { * @return */ @ApiOperation("添加学习记录") + @ValidateParams({"userId","type","coursesId"}) @PostMapping("/saverecords") public BaseResponse saveRecords(@RequestBody LearningRecords learningRecords){ System.out.println(learningRecords); @@ -81,9 +84,8 @@ public class LearningRecordsController { * @return */ @DeleteMapping("/delete") + //@ValidateParams({"ids"}) public BaseResponse deleteRecords(@RequestParam List ids){ - return ResultUtils.success(learningRecordsService.delete(ids)); } - } 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 d55b31b..5340db3 100644 --- a/src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java @@ -173,7 +173,7 @@ public class CourseResourcesServiceImpl extends ServiceImpl impl StudentCoursesMapper studentCoursesMapper; @Autowired ObjectiveContentKnowMapper objectiveContentKnowMapper; + @Autowired + private LearningRecordsMapper learningRecordsMapper; @Override @@ -264,6 +268,13 @@ public class CoursesServiceImpl extends ServiceImpl impl courseObjectivesMapper.deleteBatchIds(objectiveIds); coursesMapper.deleteById(id); + //删除课程的同时删除对应的记录 + //先通过id查出对应的记录 + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + System.out.println("id:"+id); + lambdaQueryWrapper.eq(LearningRecords::getCoursesId, id).eq(LearningRecords::getType, 1);//课程的type为1 + System.out.println("学习记录删除:"+learningRecordsMapper.selectList(lambdaQueryWrapper)); + learningRecordsMapper.delete(lambdaQueryWrapper); } @Override