diff --git a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java index ca4298d..b193a11 100644 --- a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java +++ b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java @@ -44,21 +44,37 @@ public class CoursesController { +// @ApiOperation("网站首页") +// @GetMapping("/index") +// public BaseResponse> getData(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize) { +// List coursesVo = coursesService.getPagePageSize(page, pageSize); +//// System.out.println(coursesVo); +// long totalcount = coursesService.count(); +// long toatlPages = (int) Math.ceil((double)totalcount / pageSize); +// Map objectMap = new HashMap<>(); +// objectMap.put("content",coursesVo); +// objectMap.put("totalcount", totalcount); +// objectMap.put("totalPages", toatlPages); +// objectMap.put("currentPage", page); +// return ResultUtils.success(objectMap); +// } + @ApiOperation("网站首页") @GetMapping("/index") public BaseResponse> getData(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize) { - List coursesVo = coursesService.getPagePageSize(page, pageSize); -// System.out.println(coursesVo); - long totalcount = coursesService.count(); - long toatlPages = (int) Math.ceil((double)totalcount / pageSize); - Map objectMap = new HashMap<>(); - objectMap.put("content",coursesVo); - objectMap.put("totalcount", totalcount); - objectMap.put("totalPages", toatlPages); - objectMap.put("currentPage", page); + Map result = coursesService.getPagePageSize2(page, pageSize); + + // 将结果放入新的Map对象中返回 + Map objectMap = new HashMap<>(); + objectMap.put("content", result.get("courses")); + objectMap.put("totalcount", result.get("totalcount")); + objectMap.put("totalPages", result.get("totalPages")); + objectMap.put("currentPage", result.get("currentPage")); + return ResultUtils.success(objectMap); } + @ApiOperation("新增课程--同步新增课程的总体目标并同时添加所有的分项目标") @ValidateParams({"teacher","img", "category", "nature","name","code","credit","classhours","assessmenttype","assessmentway"}) // 需要校验的参数 @PostMapping("/addcourse") diff --git a/src/main/java/com/teaching/backend/controller/courses/CoursesController2.java b/src/main/java/com/teaching/backend/controller/courses/CoursesController2.java index 7d8d005..3b4ef97 100644 --- a/src/main/java/com/teaching/backend/controller/courses/CoursesController2.java +++ b/src/main/java/com/teaching/backend/controller/courses/CoursesController2.java @@ -6,7 +6,6 @@ //import com.teaching.backend.exception.BusinessException; //import com.teaching.backend.filter.ValidateParams; //import com.teaching.backend.model.dto.courses.CoursesDTO; -//import com.teaching.backend.model.entity.resource.CourseResources; //import com.teaching.backend.model.entity.courses.Courses; //import com.teaching.backend.service.courses.ICoursesService; //import io.swagger.annotations.ApiOperation; @@ -32,8 +31,6 @@ //public class CoursesController2 { // @Autowired // ICoursesService coursesService; -// @Autowired -// ResourcesRelationshipService resourcesRelationshipService; // // @ApiOperation("网站首页2") // @GetMapping("/index2") @@ -78,6 +75,7 @@ // return ResultUtils.success(relatedResources); // } // +// // } // // diff --git a/src/main/java/com/teaching/backend/model/dto/chapter/ChapterDTO.java b/src/main/java/com/teaching/backend/model/dto/chapter/ChapterDTO.java index bff9e24..9581382 100644 --- a/src/main/java/com/teaching/backend/model/dto/chapter/ChapterDTO.java +++ b/src/main/java/com/teaching/backend/model/dto/chapter/ChapterDTO.java @@ -1,14 +1,10 @@ package com.teaching.backend.model.dto.chapter; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import javax.xml.soap.Text; import java.io.Serializable; import java.time.LocalDateTime; @@ -74,11 +70,6 @@ public class ChapterDTO implements Serializable { @ApiModelProperty(value = "周次") private String zc; - @ApiModelProperty(value = "资源") - private String ziyuan; - - @ApiModelProperty(value = "资源文件") - private String zywj; @ApiModelProperty(value = "内部序号显示") private String numshow; diff --git a/src/main/java/com/teaching/backend/model/entity/chapter/Chapter.java b/src/main/java/com/teaching/backend/model/entity/chapter/Chapter.java index 0606c87..37fb576 100644 --- a/src/main/java/com/teaching/backend/model/entity/chapter/Chapter.java +++ b/src/main/java/com/teaching/backend/model/entity/chapter/Chapter.java @@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; +import com.teaching.backend.model.entity.KnowGraph.Know; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -80,12 +80,6 @@ public class Chapter implements Serializable { @ApiModelProperty(value = "周次") private String zc; - @ApiModelProperty(value = "资源") - private String ziyuan; - - @ApiModelProperty(value = "资源文件") - private String zywj; - @ApiModelProperty(value = "内部序号显示") private String numshow; @@ -93,4 +87,9 @@ public class Chapter implements Serializable { @TableField(exist = false) private List children; // 用于存储子章节 + @ApiModelProperty(value = "知识点") + @TableField(exist = false) + private List knowledgePoints; // 用于存储章节下的知识点 + + } diff --git a/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java index 573f920..153eb8b 100644 --- a/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java @@ -8,8 +8,10 @@ import com.teaching.backend.common.ErrorCode; import com.teaching.backend.exception.BusinessException; import com.teaching.backend.mapper.chapter.ChapterMapper; import com.teaching.backend.model.dto.chapter.ChapterDTO; +import com.teaching.backend.model.entity.KnowGraph.Know; import com.teaching.backend.model.entity.chapter.Chapter; import com.teaching.backend.model.vo.chapter.ChapterVo; +import com.teaching.backend.service.KnowGraph.KnowService; import com.teaching.backend.service.chapter.IChapterService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +33,8 @@ public class ChapterServiceImpl extends ServiceImpl impl // private int count=0; List list=new ArrayList<>(); + @Autowired + private KnowService knowService; @Override public String updateNumShow(Chapter chapter) { @@ -155,7 +159,6 @@ public class ChapterServiceImpl extends ServiceImpl impl @Override public List getChapterTree(String courseId) { - List chapters=baseMapper.selectSectionsByCourseId(courseId); Map chapterMap=new HashMap<>(); @@ -165,6 +168,7 @@ public class ChapterServiceImpl extends ServiceImpl impl for (Chapter chapter:chapters){ chapter.setChildren(new ArrayList<>()); + chapter.setKnowledgePoints(new ArrayList<>()); // 初始化知识点列表 chapterMap.put(chapter.getId(),chapter); } @@ -182,9 +186,23 @@ public class ChapterServiceImpl extends ServiceImpl impl } } - return roots; + for (Chapter root : roots) { + loadKnowledgePointsRecursively(root); } + return roots; + } + + private void loadKnowledgePointsRecursively(Chapter chapter) { + + for (Chapter child : chapter.getChildren()) { + + Set knows = knowService.queryByChapterId(child.getId()); + child.setKnowledgePoints(new ArrayList<>(knows)); + + loadKnowledgePointsRecursively(child); + } + } @Override public void saveChapter(ChapterDTO chapterDTO) { @@ -235,9 +253,16 @@ public class ChapterServiceImpl extends ServiceImpl impl lambdaQueryWrapper.eq(Chapter::getPid,id); Long count= this.count(lambdaQueryWrapper); + if (count>0){ throw new BusinessException(ErrorCode.OPERATION_ERROR,"存在子章节,无法删除"); } + + Set knows = knowService.queryByChapterId(id); + + if (!knows.isEmpty()) { + throw new BusinessException(ErrorCode.OPERATION_ERROR, "子章节下存在知识点,无法删除"); + } this.remove(queryWrapper);