diff --git a/src/main/java/com/teaching/backend/controller/Know/KnowController.java b/src/main/java/com/teaching/backend/controller/Know/KnowController.java index 7fcce7d..2ec254d 100644 --- a/src/main/java/com/teaching/backend/controller/Know/KnowController.java +++ b/src/main/java/com/teaching/backend/controller/Know/KnowController.java @@ -51,7 +51,7 @@ public class KnowController { return knowService.knowLearnPath(corseId); } //生成知识点学习路径 默认从第一个知识点到第最后个知识点 - @ApiOperation(value = "生成知识点学习路径") + @ApiOperation(value = "生成知识点学习路径-图信息") @GetMapping("/knowLearnPathGraph") BaseResponse knowLearnPathGraph(@RequestParam String corseId){ return knowService.knowLearnPathGraph(corseId); @@ -74,9 +74,12 @@ public class KnowController { //返回课程下指定关系的知识图谱 @ApiOperation(value = "返回课程下指定关系的知识图谱") - @GetMapping("/getRelsNodesByCourseId") - BaseResponse getRelsNodesByCourseId(@RequestParam String courseId,@RequestParam Integer level,@RequestParam Listtypes){ - return knowService.getRelsNodesByCourseId(courseId, level,types); + @PostMapping("/getRelsNodesByCourseId") + BaseResponse getRelsNodesByCourseId(@RequestBody RelsNodesVO relsNodesVO){ + String courseId = relsNodesVO.getCourseId(); + Integer level = relsNodesVO.getLevel(); + List types = relsNodesVO.getTypes(); + return knowService.getRelsNodesByCourseId(courseId, level,types); } //返回知识点的前后知识点 diff --git a/src/main/java/com/teaching/backend/controller/Know/RelsNodesVO.java b/src/main/java/com/teaching/backend/controller/Know/RelsNodesVO.java new file mode 100644 index 0000000..3609edd --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/Know/RelsNodesVO.java @@ -0,0 +1,24 @@ +package com.teaching.backend.controller.Know; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @Author:youhang + * @Date:2024-09-02-9:47 + * @Description: + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class RelsNodesVO { + @NonNull + private String courseId; + private Integer level; + private List types; +} diff --git a/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java index b36f89d..2266643 100644 --- a/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java @@ -833,16 +833,33 @@ public class knowServiceImpl implements KnowService { @Override public BaseResponse getRelsNodesByCourseId(String courseId, Integer level,List types) { + List typesTemp = new ArrayList<>(); + String str; + if(types == null || types.size() <= 0){ + typesTemp.add("contain"); + typesTemp.add("orer"); + typesTemp.add("dependent"); + str = "match(n:Know)-[r:"; + for (int i = 0; i < typesTemp.size(); i++) { + if (i == typesTemp.size() - 1) { + str = str + typesTemp.get(i) + "*"; + } else { + str = str + typesTemp.get(i) + "|"; + } - String str = "match(n:Know)-[r:"; - for (int i = 0; i < types.size(); i++) { - if (i == types.size() - 1) { - str = str + types.get(i) + "*"; - } else { - str = str + types.get(i) + "|"; } + }else{ + str = "match(n:Know)-[r:"; + for (int i = 0; i < types.size(); i++) { + if (i == types.size() - 1) { + str = str + types.get(i) + "*"; + } else { + str = str + types.get(i) + "|"; + } + } } + if(level == null || level <= 0){ str = str +"]->(p:Know) where n.courseId = '" + courseId + "' return n as `n`,r as `r`,p as `p`,length(r) as `d`"; }else{