diff --git a/src/main/java/com/teaching/backend/controller/courseResource/CourseResourceController.java b/src/main/java/com/teaching/backend/controller/courseResource/CourseResourceController.java new file mode 100644 index 0000000..af7f8ae --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/courseResource/CourseResourceController.java @@ -0,0 +1,54 @@ +package com.teaching.backend.controller.courseResource; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.teaching.backend.common.BaseResponse; +import com.teaching.backend.common.ResultUtils; + +import com.teaching.backend.model.entity.CourseResources; +import com.teaching.backend.service.impl.CourseResourcesServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; + +@RestController +@RequestMapping("/courses") +public class CourseResourceController { + @Autowired + private CourseResourcesServiceImpl courseResourcesService; + @GetMapping("/all") + public BaseResponse> All(){ + System.out.println("学习记录:"+courseResourcesService.list()); + return ResultUtils.success(courseResourcesService.list()); + } + + @GetMapping("/getall") + public BaseResponse getAll(@RequestParam(value = "pagenum", defaultValue = "1") int pagenum, + @RequestParam(value = "pagesize", defaultValue = "10") int pagesize, + String type) { + + List cs = courseResourcesService.getByType(type); + List pageCs = new ArrayList<>(); + //当前页面 + for(int i = (pagenum - 1) * pagesize; i < cs.size() && i < (pagenum) * pagesize; i++){ + pageCs.add(cs.get(i)); + } + long total = cs.size(); // 总记录数 + Page pageInfo = new Page<>(pagenum,pagesize,total); + pageInfo.setRecords(pageCs); + pageInfo.setPages((int)(Math.ceil((double) total / pagesize)));//设置总页数 + return ResultUtils.success(pageInfo); + } + + /** + * 根据id删除 + * @param ids + * @return + */ + @DeleteMapping("/delete") + public BaseResponse deleteRecords(@RequestParam List ids){ + courseResourcesService.removeCourseResources(ids); + return ResultUtils.success("删除成功!!"); + } +} 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 2e5248d..0dc4fc0 100644 --- a/src/main/java/com/teaching/backend/controller/records/LearningRecordsController.java +++ b/src/main/java/com/teaching/backend/controller/records/LearningRecordsController.java @@ -43,13 +43,13 @@ public class LearningRecordsController { long total = cs.size(); // 总记录数 Page pageInfo = new Page<>(pagenum,pagesize,total); pageInfo.setRecords(pageCs); - System.out.println("总记录数"+pageInfo.getTotal()); - System.out.println("当前页面:"+pagenum); - System.out.println("当前页面大小:"+pagesize); - System.out.println("当前页面内容:"+pageCs); - System.out.println("页面数:"+pageInfo.getPages()); +// System.out.println("总记录数"+pageInfo.getTotal()); +// System.out.println("当前页面:"+pagenum); +// System.out.println("当前页面大小:"+pagesize); +// System.out.println("当前页面内容:"+pageCs); +// System.out.println("页面数:"+pageInfo.getPages()); pageInfo.setPages((int)(Math.ceil((double) total / pagesize)));//设置总页数 - System.out.println(pageInfo.getPages()); +// System.out.println(pageInfo.getPages()); return ResultUtils.success(pageInfo); } diff --git a/src/main/java/com/teaching/backend/model/entity/CourseResources.java b/src/main/java/com/teaching/backend/model/entity/CourseResources.java index 40809da..e1819c4 100644 --- a/src/main/java/com/teaching/backend/model/entity/CourseResources.java +++ b/src/main/java/com/teaching/backend/model/entity/CourseResources.java @@ -33,4 +33,13 @@ public class CourseResources { private String tags; private String path; + /** + * 简介 + */ + private String description; + + /** + * 封面 + */ + private String img; } diff --git a/src/main/java/com/teaching/backend/model/entity/records/LearningRecords.java b/src/main/java/com/teaching/backend/model/entity/records/LearningRecords.java index 69842e1..067e2e8 100644 --- a/src/main/java/com/teaching/backend/model/entity/records/LearningRecords.java +++ b/src/main/java/com/teaching/backend/model/entity/records/LearningRecords.java @@ -60,7 +60,7 @@ public class LearningRecords { private String download; /** *视频学习时长 - */ + * private String videoDuration; /** 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 5751c4c..e107b1e 100644 --- a/src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java @@ -13,6 +13,7 @@ import com.teaching.backend.model.entity.ResourceRelationship; import com.teaching.backend.service.resource.CourseResourcesService; import com.teaching.backend.service.resource.ResourcesRelationshipService; import org.apache.commons.io.FileUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -35,6 +36,9 @@ import java.util.List; public class CourseResourcesServiceImpl extends ServiceImpl implements CourseResourcesService { @Resource ResourcesRelationshipService resourcesRelationshipService; + + @Autowired + private CourseResourcesMapper courseResourcesMapper; @Override public void updateFile(Integer type, String fileName, String filePath) { @@ -115,6 +119,27 @@ public class CourseResourcesServiceImpl extends ServiceImpl getByType(String type) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(CourseResources::getType, type); + + List list = this.list(lambdaQueryWrapper); + + return list; + } + + + @Override + public void removeCourseResources(List ids) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.in(CourseResources::getId, ids); + List list = this.list(lambdaQueryWrapper); + courseResourcesMapper.deleteBatchIds(list); +// System.out.println(this.updateBatchById(list)); +// this.remove(lambdaQueryWrapper); + } + } 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 f5157b6..912d839 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 @@ -26,6 +26,8 @@ import com.teaching.backend.model.vo.courses.CoursesVO; import com.teaching.backend.service.courses.ICoursesService; import com.teaching.backend.utils.CourseCode; import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFParagraph; +import org.apache.poi.xwpf.usermodel.XWPFRun; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -123,7 +125,6 @@ public class CoursesServiceImpl extends ServiceImpl impl } else { throw new BusinessException(ErrorCode.OPERATION_ERROR, "这个课程已经存在了!请联系系统相关人员为您导入课程数据!"); } - } @Override @@ -341,7 +342,7 @@ public class CoursesServiceImpl extends ServiceImpl impl //总目标 StringBuilder overall_goal = new StringBuilder(); for (ObjectiveContents content : courseObjectivesTreeVO.get(0).getContents()) { - overall_goal.append(content.getContent()); + overall_goal.append("\r\n").append(content.getContent()); } System.out.println(overall_goal); @@ -350,24 +351,26 @@ public class CoursesServiceImpl extends ServiceImpl impl 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"); + knowledge_goals.append("\r\n").append(c.getContent()); } } //思政目标 if (i == 1){ for (ObjectiveContents c : content.getContents()) { - political_goals.append(c.getContent()).append("\n"); + political_goals.append("\r\n").append(c.getContent()); } } //价值目标 if (i == 2){ for (ObjectiveContents c : content.getContents()) { - value_goals.append(c.getContent()).append("\n"); + value_goals.append("\r\n").append(c.getContent()); } } } @@ -389,8 +392,13 @@ public class CoursesServiceImpl extends ServiceImpl impl params.put("political_goals", political_goals); params.put("value_goals", value_goals); - + //导出图片 + params.put("img","wyii\t"); //根据模板+数据 导出文档 + + + + XWPFDocument xwpfDocument = WordExportUtil.exportWord07(templatePath.getPath(), params); 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 9da33fe..c27b144 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 @@ -106,6 +106,7 @@ public class LearningRecordsServiceImpl extends ServiceImpl { Page getresourceRecords(Integer type, List resourceIdList, int page, int pageSize); + + + public List getByType(String type); + public void removeCourseResources(List ids); } diff --git a/src/main/resources/img/v2-c57eb7863ec4233f503176ca3f90f8d5_1440w.png b/src/main/resources/img/v2-c57eb7863ec4233f503176ca3f90f8d5_1440w.png new file mode 100644 index 0000000..7e074bc Binary files /dev/null and b/src/main/resources/img/v2-c57eb7863ec4233f503176ca3f90f8d5_1440w.png differ diff --git a/src/main/resources/templates/courses.docx b/src/main/resources/templates/courses.docx index b0f71c2..2662b01 100644 Binary files a/src/main/resources/templates/courses.docx and b/src/main/resources/templates/courses.docx differ