课程信息删除同时删除学习记录

master
wenyu441069198 5 months ago
parent bf05b81a0b
commit 05897862fa
  1. 6
      src/main/java/com/teaching/backend/controller/records/LearningRecordsController.java
  2. 2
      src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java
  3. 11
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.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<Page> 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<String> saveRecords(@RequestBody LearningRecords learningRecords){
System.out.println(learningRecords);
@ -81,9 +84,8 @@ public class LearningRecordsController {
* @return
*/
@DeleteMapping("/delete")
//@ValidateParams({"ids"})
public BaseResponse<String> deleteRecords(@RequestParam List<Long> ids){
return ResultUtils.success(learningRecordsService.delete(ids));
}
}

@ -173,7 +173,7 @@ public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMappe
break;
case 6 : courseResources.setImg("src\\assets\\images\\audio.png"); //音频
break;
default: courseResources.setImg(""); //暂无默认图片
default: courseResources.setImg("图片丢失!!"); //暂无默认图片
}
this.save(courseResources);
}

@ -11,12 +11,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.courses.*;
import com.teaching.backend.mapper.records.LearningRecordsMapper;
import com.teaching.backend.mapper.umsAdmin.UmsAdminMapper;
import com.teaching.backend.mapper.umsAdmin.UmsAdminRoleRelationMapper;
import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper;
import com.teaching.backend.model.dto.courses.CoursesDTO;
import com.teaching.backend.model.dto.courses.PageDTO;
import com.teaching.backend.model.entity.courses.*;
import com.teaching.backend.model.entity.records.LearningRecords;
import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
import com.teaching.backend.model.entity.umsAdmin.UmsAdminRoleRelation;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
@ -79,6 +81,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
StudentCoursesMapper studentCoursesMapper;
@Autowired
ObjectiveContentKnowMapper objectiveContentKnowMapper;
@Autowired
private LearningRecordsMapper learningRecordsMapper;
@Override
@ -264,6 +268,13 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
courseObjectivesMapper.deleteBatchIds(objectiveIds);
coursesMapper.deleteById(id);
//删除课程的同时删除对应的记录
//先通过id查出对应的记录
LambdaQueryWrapper<LearningRecords> 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

Loading…
Cancel
Save