From 0178bde490e297f9490f2cbc3d9f7d5792eaedb2 Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Wed, 19 Jun 2024 14:34:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E4=B9=A0=E8=AE=B0=E5=BD=95-=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E8=B5=84=E6=BA=90=E7=9A=84=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/courses/CoursesServiceImpl.java | 5 +++++ .../impl/records/LearningRecordsServiceImpl.java | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java index 326939e..d4e4a57 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.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 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); diff --git a/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java index c27b144..59e6607 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java @@ -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 lambdaQueryWrapper = new LambdaQueryWrapper<>();