diff --git a/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java b/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java index 2a6e1a1..650af6a 100644 --- a/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java +++ b/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java @@ -67,7 +67,7 @@ public class CourseObjectivesController { @ApiOperation("查询课程目标内容") @GetMapping("/list/{id}") public BaseResponse> queryCourseObjectivesTree(@PathVariable String id){ - List courseObjectivesTreeVO = courseObjectivesService.queryCourseObjectivesTree(id); + List courseObjectivesTreeVO = courseObjectivesService.queryCourseObjectivesTree(id); return ResultUtils.success(courseObjectivesTreeVO); } 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 9a7d330..5aad33f 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 @@ -41,6 +41,7 @@ import org.springframework.util.ResourceUtils; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -56,6 +57,9 @@ import java.util.stream.Collectors; @Service public class CoursesServiceImpl extends ServiceImpl implements ICoursesService { + @Autowired + private CourseObjectivesServiceImpl objectivesService; + @Autowired CoursesMapper coursesMapper; @@ -286,15 +290,70 @@ public class CoursesServiceImpl extends ServiceImpl impl //查询课程通过课程id查--课程简介 Courses courses = this.getById(id); System.out.println("课程:"+courses); - Map params = new HashMap(); - params.put("name",courses.getName()); - params.put("code",courses.getCode()); - params.put("nature",courses.getNature()); - params.put("credit",courses.getCredit()); - params.put("classhour",courses.getClasshours()); - params.put("description",courses.getDescription()); + //准备数据 + String course_name = courses.getName(); + String course_code = courses.getCode(); + String course_nature = courses.getNature(); + BigDecimal course_credit = courses.getCredit(); + Integer course_classhour = courses.getClasshours(); + String course_description = courses.getDescription(); + //查询课程目标 + List courseObjectivesTreeVO = objectivesService.queryCourseObjectivesTree(id); + System.out.println("课程目标:"+courseObjectivesTreeVO); + //准备数据 + //总目标 + StringBuilder overall_goal = new StringBuilder(); + for (ObjectiveContents content : courseObjectivesTreeVO.get(0).getContents()) { + overall_goal.append(content.getContent()); + } + System.out.println(overall_goal); + + //分项目标 + //知识目标 + StringBuilder knowledge_goals = new StringBuilder(); + StringBuilder political_goals = new StringBuilder(); + StringBuilder value_goals = new StringBuilder(); + for (int i = 0; i < courseObjectivesTreeVO.get(0).getCourseObjectivesTrees().size(); i++){ + CourseObjectivesTreeVO content = courseObjectivesTreeVO.get(0).getCourseObjectivesTrees().get(i); + //知识目标 + if (i == 0){ + for (ObjectiveContents c : content.getContents()) { + knowledge_goals.append(c.getContent()).append("\n"); + } + } + //思政目标 + if (i == 1){ + for (ObjectiveContents c : content.getContents()) { + political_goals.append(c.getContent()).append("\n"); + } + } + //价值目标 + if (i == 2){ + for (ObjectiveContents c : content.getContents()) { + value_goals.append(c.getContent()).append("\n"); + } + } + } + System.out.println("知识目标:"+knowledge_goals); + System.out.println("思政目标:"+political_goals); + System.out.println("价值目标:"+value_goals); + + Map params = new HashMap(); + params.put("course_name",course_name); + params.put("course_code",course_code); + params.put("course_nature",course_nature); + params.put("course_credit",course_credit); + params.put("course_classhour",course_classhour); + params.put("course_description",course_description); + + //课程目标 + params.put("overall_goal", overall_goal); + params.put("knowledge_goals", knowledge_goals); + params.put("political_goals", political_goals); + params.put("value_goals", value_goals); + //根据模板+数据 导出文档 XWPFDocument xwpfDocument = WordExportUtil.exportWord07(templatePath.getPath(), params); diff --git a/src/main/resources/templates/courses.docx b/src/main/resources/templates/courses.docx index 1500516..b0f71c2 100644 Binary files a/src/main/resources/templates/courses.docx and b/src/main/resources/templates/courses.docx differ