Merge branch 'master' of 39.106.16.162:/home/git/teaching-backend/teaching-backend

master
youhang 5 months ago
commit 2cd9bbe1d7
  1. 54
      src/main/java/com/teaching/backend/controller/courseResource/CourseResourceController.java
  2. 12
      src/main/java/com/teaching/backend/controller/records/LearningRecordsController.java
  3. 9
      src/main/java/com/teaching/backend/model/entity/CourseResources.java
  4. 2
      src/main/java/com/teaching/backend/model/entity/records/LearningRecords.java
  5. 25
      src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java
  6. 20
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  7. 3
      src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java
  8. 4
      src/main/java/com/teaching/backend/service/resource/CourseResourcesService.java
  9. BIN
      src/main/resources/img/v2-c57eb7863ec4233f503176ca3f90f8d5_1440w.png
  10. BIN
      src/main/resources/templates/courses.docx

@ -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<List<CourseResources>> All(){
System.out.println("学习记录:"+courseResourcesService.list());
return ResultUtils.success(courseResourcesService.list());
}
@GetMapping("/getall")
public BaseResponse<Page> getAll(@RequestParam(value = "pagenum", defaultValue = "1") int pagenum,
@RequestParam(value = "pagesize", defaultValue = "10") int pagesize,
String type) {
List<CourseResources> cs = courseResourcesService.getByType(type);
List<CourseResources> 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<CourseResources> 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<String> deleteRecords(@RequestParam List<Long> ids){
courseResourcesService.removeCourseResources(ids);
return ResultUtils.success("删除成功!!");
}
}

@ -43,13 +43,13 @@ public class LearningRecordsController {
long total = cs.size(); // 总记录数 long total = cs.size(); // 总记录数
Page<LearningRecordsVo> pageInfo = new Page<>(pagenum,pagesize,total); Page<LearningRecordsVo> pageInfo = new Page<>(pagenum,pagesize,total);
pageInfo.setRecords(pageCs); pageInfo.setRecords(pageCs);
System.out.println("总记录数"+pageInfo.getTotal()); // System.out.println("总记录数"+pageInfo.getTotal());
System.out.println("当前页面:"+pagenum); // System.out.println("当前页面:"+pagenum);
System.out.println("当前页面大小:"+pagesize); // System.out.println("当前页面大小:"+pagesize);
System.out.println("当前页面内容:"+pageCs); // System.out.println("当前页面内容:"+pageCs);
System.out.println("页面数:"+pageInfo.getPages()); // System.out.println("页面数:"+pageInfo.getPages());
pageInfo.setPages((int)(Math.ceil((double) total / pagesize)));//设置总页数 pageInfo.setPages((int)(Math.ceil((double) total / pagesize)));//设置总页数
System.out.println(pageInfo.getPages()); // System.out.println(pageInfo.getPages());
return ResultUtils.success(pageInfo); return ResultUtils.success(pageInfo);
} }

@ -33,4 +33,13 @@ public class CourseResources {
private String tags; private String tags;
private String path; private String path;
/**
* 简介
*/
private String description;
/**
* 封面
*/
private String img;
} }

@ -60,7 +60,7 @@ public class LearningRecords {
private String download; private String download;
/** /**
*视频学习时长 *视频学习时长
*/ *
private String videoDuration; private String videoDuration;
/** /**

@ -13,6 +13,7 @@ import com.teaching.backend.model.entity.ResourceRelationship;
import com.teaching.backend.service.resource.CourseResourcesService; import com.teaching.backend.service.resource.CourseResourcesService;
import com.teaching.backend.service.resource.ResourcesRelationshipService; import com.teaching.backend.service.resource.ResourcesRelationshipService;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -35,6 +36,9 @@ import java.util.List;
public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMapper, CourseResources> implements CourseResourcesService { public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMapper, CourseResources> implements CourseResourcesService {
@Resource @Resource
ResourcesRelationshipService resourcesRelationshipService; ResourcesRelationshipService resourcesRelationshipService;
@Autowired
private CourseResourcesMapper courseResourcesMapper;
@Override @Override
public void updateFile(Integer type, String fileName, String filePath) { public void updateFile(Integer type, String fileName, String filePath) {
@ -115,6 +119,27 @@ public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMappe
return key; return key;
} }
@Override
public List<CourseResources> getByType(String type) {
LambdaQueryWrapper<CourseResources> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CourseResources::getType, type);
List<CourseResources> list = this.list(lambdaQueryWrapper);
return list;
}
@Override
public void removeCourseResources(List<Long> ids) {
LambdaQueryWrapper<CourseResources> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CourseResources::getId, ids);
List<CourseResources> list = this.list(lambdaQueryWrapper);
courseResourcesMapper.deleteBatchIds(list);
// System.out.println(this.updateBatchById(list));
// this.remove(lambdaQueryWrapper);
}
} }

@ -26,6 +26,8 @@ import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.service.courses.ICoursesService; import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.utils.CourseCode; import com.teaching.backend.utils.CourseCode;
import org.apache.poi.xwpf.usermodel.XWPFDocument; 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.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -123,7 +125,6 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
} else { } else {
throw new BusinessException(ErrorCode.OPERATION_ERROR, "这个课程已经存在了!请联系系统相关人员为您导入课程数据!"); throw new BusinessException(ErrorCode.OPERATION_ERROR, "这个课程已经存在了!请联系系统相关人员为您导入课程数据!");
} }
} }
@Override @Override
@ -341,7 +342,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
//总目标 //总目标
StringBuilder overall_goal = new StringBuilder(); StringBuilder overall_goal = new StringBuilder();
for (ObjectiveContents content : courseObjectivesTreeVO.get(0).getContents()) { 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); System.out.println(overall_goal);
@ -350,24 +351,26 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
StringBuilder knowledge_goals = new StringBuilder(); StringBuilder knowledge_goals = new StringBuilder();
StringBuilder political_goals = new StringBuilder(); StringBuilder political_goals = new StringBuilder();
StringBuilder value_goals = new StringBuilder(); StringBuilder value_goals = new StringBuilder();
for (int i = 0; i < courseObjectivesTreeVO.get(0).getCourseObjectivesTrees().size(); i++){ for (int i = 0; i < courseObjectivesTreeVO.get(0).getCourseObjectivesTrees().size(); i++){
CourseObjectivesTreeVO content = courseObjectivesTreeVO.get(0).getCourseObjectivesTrees().get(i); CourseObjectivesTreeVO content = courseObjectivesTreeVO.get(0).getCourseObjectivesTrees().get(i);
//知识目标 //知识目标
if (i == 0){ if (i == 0){
for (ObjectiveContents c : content.getContents()) { for (ObjectiveContents c : content.getContents()) {
knowledge_goals.append(c.getContent()).append("\n"); knowledge_goals.append("\r\n").append(c.getContent());
} }
} }
//思政目标 //思政目标
if (i == 1){ if (i == 1){
for (ObjectiveContents c : content.getContents()) { for (ObjectiveContents c : content.getContents()) {
political_goals.append(c.getContent()).append("\n"); political_goals.append("\r\n").append(c.getContent());
} }
} }
//价值目标 //价值目标
if (i == 2){ if (i == 2){
for (ObjectiveContents c : content.getContents()) { 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<CoursesMapper, Courses> impl
params.put("political_goals", political_goals); params.put("political_goals", political_goals);
params.put("value_goals", value_goals); params.put("value_goals", value_goals);
//导出图片
params.put("img","wyii\t");
//根据模板+数据 导出文档 //根据模板+数据 导出文档
XWPFDocument xwpfDocument = WordExportUtil.exportWord07(templatePath.getPath(), params); XWPFDocument xwpfDocument = WordExportUtil.exportWord07(templatePath.getPath(), params);

@ -106,6 +106,7 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
System.out.println(); System.out.println();
learningRecordsVo.setCoursesName(coursesService.getById(learningRecords.getCoursesId()).getName()); learningRecordsVo.setCoursesName(coursesService.getById(learningRecords.getCoursesId()).getName());
break; break;
} }
//添加观看人数 //添加观看人数
//统计记录表里有多少人查看过这门资源 //统计记录表里有多少人查看过这门资源
@ -142,7 +143,7 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
learningRecords.setAccessTime(LocalDateTime.now()); learningRecords.setAccessTime(LocalDateTime.now());
//设置默认封面 //设置默认封面
if (learningRecords.getContent() == null || learningRecords.getContent().equals("")){ if (learningRecords.getContent() == null || learningRecords.getContent().equals("")){
learningRecords.setContent("https://teaching-edu123.oss-cn-beijing.aliyuncs.com/Borovets_ZH-CN5914681811_UHD.jpg"); learningRecords.setContent("img/v2-c57eb7863ec4233f503176ca3f90f8d5_1440w.png");
} }
// //添加记录封面 // //添加记录封面
// switch (learningRecords.getType()) { // switch (learningRecords.getType()) {

@ -24,4 +24,8 @@ public interface CourseResourcesService extends IService<CourseResources> {
Page<CourseResources> getresourceRecords(Integer type, List<Integer> resourceIdList, int page, int pageSize); Page<CourseResources> getresourceRecords(Integer type, List<Integer> resourceIdList, int page, int pageSize);
public List<CourseResources> getByType(String type);
public void removeCourseResources(List<Long> ids);
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Loading…
Cancel
Save