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