学习记录-课程资源的新增

master
wenyu441069198 5 months ago
parent 0d4ec1803b
commit 0178bde490
  1. 5
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  2. 11
      src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java

@ -37,6 +37,7 @@ import org.springframework.util.ResourceUtils;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
@ -322,6 +323,10 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
public void down(HttpServletResponse response, String id) throws Exception {
File rootPath = new File(ResourceUtils.getURL("classpath:").getPath()); //SpringBoot项目获取根目录的方式
File templatePath = new File(rootPath.getAbsolutePath(),"/templates/courses.docx");//------------------需要模板的地址
// 加载Word模板
FileInputStream template = new FileInputStream("/templates/courses.docx");
XWPFDocument document = new XWPFDocument(template);
//准备导出数据
//查询课程通过课程id查--课程简介
Courses courses = this.getById(id);

@ -9,6 +9,7 @@ import com.teaching.backend.mapper.records.LearningRecordsMapper;
import com.teaching.backend.model.entity.records.LearningRecords;
import com.teaching.backend.model.vo.records.LearningRecordsVo;
import com.teaching.backend.service.impl.CourseResourcesServiceImpl;
import com.teaching.backend.service.impl.chapter.ChapterServiceImpl;
import com.teaching.backend.service.impl.courses.CoursesServiceImpl;
import com.teaching.backend.service.impl.know.KnowServiceimpl;
@ -31,8 +32,8 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
private CoursesServiceImpl coursesService;
@Autowired
private LearningRecordsMapper learningRecordsMapper;
// @Autowired
// private LearningResourceServiceImpl learningResourceService;
@Autowired
private CourseResourcesServiceImpl courseResourcesService;
@Autowired
private KnowServiceimpl knowledgePointService;
@Autowired
@ -91,7 +92,7 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
//添加课程名称
switch (learningRecords.getType()) {
case "4": //如果是资源学习
learningRecordsVo.setCoursesName("学习资源");//设置名称 --------------------------------------------待完善
learningRecordsVo.setCoursesName(courseResourcesService.getById(learningRecords.getCoursesId()).getName());//设置名称 --------------------------------------------待完善
break;
case "3": //如果是知识点学习记录
@ -106,7 +107,6 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
System.out.println();
learningRecordsVo.setCoursesName(coursesService.getById(learningRecords.getCoursesId()).getName());
break;
}
//添加观看人数
//统计记录表里有多少人查看过这门资源
@ -129,6 +129,9 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
public String saveRecords(LearningRecords learningRecords) {
String userId = learningRecords.getUserId();
String coursesId = learningRecords.getCoursesId();
//如果userId或者coursesId为空就抛出异常事务回滚----------------------------
System.out.println("学习记录:"+learningRecords);
//查找该用户是否观看过该学习资源
LambdaQueryWrapper<LearningRecords> lambdaQueryWrapper = new LambdaQueryWrapper<>();

Loading…
Cancel
Save