commit
ad1f3f6e69
54 changed files with 1379 additions and 703 deletions
@ -0,0 +1,85 @@ |
|||||||
|
package com.teaching.backend.controller.KnowGraph; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author:youhang |
||||||
|
* @Date:2024-06-09-9:55 |
||||||
|
* @Description: |
||||||
|
*/ |
||||||
|
import com.teaching.backend.common.BaseResponse; |
||||||
|
import com.teaching.backend.common.ResultUtils; |
||||||
|
import com.teaching.backend.model.dto.KnowGraph.*; |
||||||
|
import com.teaching.backend.model.entity.KnowGraph.Know; |
||||||
|
|
||||||
|
import com.teaching.backend.model.entity.KnowGraph.KnowCourse; |
||||||
|
import com.teaching.backend.service.KnowGraph.KnowService; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
|
||||||
|
@RestController |
||||||
|
@RequestMapping("/know") |
||||||
|
public class KnowController { |
||||||
|
|
||||||
|
private KnowService knowService; |
||||||
|
|
||||||
|
public KnowController(KnowService knowService) { |
||||||
|
this.knowService = knowService; |
||||||
|
} |
||||||
|
|
||||||
|
//根据 id查询所关联的所有结点
|
||||||
|
@PostMapping ("/query/{id}") |
||||||
|
public List<Know> queryKnowAllKnowById(@PathVariable Long id) { |
||||||
|
return knowService.queryKnowAllKnowById(id); |
||||||
|
} |
||||||
|
|
||||||
|
//添加知识点
|
||||||
|
@PostMapping("/add") |
||||||
|
public Know createKnow(@RequestBody KnowRequest knowRequest) { |
||||||
|
return knowService.createKnow(knowRequest); |
||||||
|
} |
||||||
|
|
||||||
|
//添加知识点 - 课程
|
||||||
|
@PostMapping("/addKnowCourse") |
||||||
|
public KnowCourse createCourseKnow(@RequestBody KnowCourseCreateRequest knowCourseCreateRequest) { |
||||||
|
return knowService.createCourseKnow(knowCourseCreateRequest); |
||||||
|
} |
||||||
|
|
||||||
|
//修改知识点
|
||||||
|
@PostMapping ("/update") |
||||||
|
public Know updateKnow(@RequestBody KnowUpdateRequest knowUpdateRequest) { |
||||||
|
return knowService.updateKnow(knowUpdateRequest); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//删除知识点
|
||||||
|
@GetMapping ("delete/{id}") |
||||||
|
public void deleteKnow(@PathVariable Long id) { |
||||||
|
knowService.deleteKnow(id); |
||||||
|
} |
||||||
|
|
||||||
|
//添加知识点与知识点的关系 related
|
||||||
|
@PostMapping ("/addKnowRelatedKnow") |
||||||
|
public void addKnowRelatedKnow(@RequestBody RelationshipKnowRequest relationshipKnowRequest) { |
||||||
|
knowService.addKnowRelatedKnow(relationshipKnowRequest); |
||||||
|
} |
||||||
|
|
||||||
|
//添加知识点与知识点的关系 related
|
||||||
|
@PostMapping ("/addKnowFatherAndSonKnow") |
||||||
|
public void addKnowFatherAndSonKnow(@RequestBody RelationshipKnowRequest relationshipKnowRequest) { |
||||||
|
knowService.addKnowFatherAndSonKnow(relationshipKnowRequest); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/all") |
||||||
|
public BaseResponse<BaseKnowReturn> getKnowAll(@RequestParam String id) { |
||||||
|
BaseKnowReturn baseKnowReturn =knowService.getKnowAll(id); |
||||||
|
return ResultUtils.success(baseKnowReturn); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/KnowById") |
||||||
|
public BaseResponse<BaseKnowReturn> getKnowById(@RequestParam Long id) { |
||||||
|
BaseKnowReturn baseKnowReturn =knowService.getKnowById(id); |
||||||
|
return ResultUtils.success(baseKnowReturn); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,40 +0,0 @@ |
|||||||
package com.teaching.backend.controller.know; |
|
||||||
|
|
||||||
import com.teaching.backend.model.dto.know.KnowQueryRequest; |
|
||||||
import com.teaching.backend.model.dto.know.KnowRequest; |
|
||||||
import com.teaching.backend.model.dto.know.KnowupdateRequest; |
|
||||||
import com.teaching.backend.model.entity.know.Know; |
|
||||||
import com.teaching.backend.service.know.KnowService; |
|
||||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||||
import org.springframework.web.bind.annotation.*; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* @Author:youhang |
|
||||||
* @Date:2024-06-21-10:26 |
|
||||||
* @Description: |
|
||||||
*/ |
|
||||||
@RestController |
|
||||||
@RequestMapping("/api/know") |
|
||||||
public class KnowController { |
|
||||||
|
|
||||||
@Autowired |
|
||||||
private KnowService knowService; |
|
||||||
@PostMapping("/add") |
|
||||||
public Boolean add(@RequestBody KnowRequest knowAddRequest) { |
|
||||||
return knowService.add(knowAddRequest); |
|
||||||
} |
|
||||||
@PostMapping("/update") |
|
||||||
public Boolean update(@RequestBody KnowupdateRequest knowAddRequest){ |
|
||||||
return knowService.update(knowAddRequest); |
|
||||||
} |
|
||||||
@PostMapping("/delete") |
|
||||||
public Integer deleteKnow(@RequestBody List<Integer> ids){ |
|
||||||
return knowService.deleteKnow(ids); |
|
||||||
} |
|
||||||
@PostMapping("/query") |
|
||||||
public List<Know> query(@RequestBody KnowQueryRequest knowQueryRequest){ |
|
||||||
return knowService.query(knowQueryRequest); |
|
||||||
} |
|
||||||
} |
|
@ -1,42 +0,0 @@ |
|||||||
package com.teaching.backend.controller.know; |
|
||||||
|
|
||||||
|
|
||||||
import com.teaching.backend.common.BaseResponse; |
|
||||||
import com.teaching.backend.common.ResultUtils; |
|
||||||
import com.teaching.backend.model.entity.know.Know; |
|
||||||
import com.teaching.backend.model.entity.know.KnowRelationship; |
|
||||||
import com.teaching.backend.service.know.IKnowRelationshipService; |
|
||||||
import io.swagger.annotations.Api; |
|
||||||
import io.swagger.annotations.ApiOperation; |
|
||||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||||
import org.springframework.web.bind.annotation.*; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p> |
|
||||||
* 前端控制器 |
|
||||||
* </p> |
|
||||||
* |
|
||||||
* @author author |
|
||||||
* @since 2024-06-20 |
|
||||||
*/ |
|
||||||
@Api(tags = "知识点章节关系") |
|
||||||
@RestController |
|
||||||
@RequestMapping("/know-relationship") |
|
||||||
public class KnowRelationshipController { |
|
||||||
|
|
||||||
@Autowired |
|
||||||
private IKnowRelationshipService knowRelationshipService; |
|
||||||
@ApiOperation("添加课程知识点关系") |
|
||||||
@PostMapping() |
|
||||||
public BaseResponse<Boolean> add(@RequestBody KnowRelationship knowRelationship){ |
|
||||||
boolean save = knowRelationshipService.save(knowRelationship); |
|
||||||
return ResultUtils.success(save); |
|
||||||
} |
|
||||||
@GetMapping() |
|
||||||
public BaseResponse<List<KnowRelationship>> getAll(){ |
|
||||||
List<KnowRelationship> list = knowRelationshipService.list(); |
|
||||||
return ResultUtils.success(list); |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,12 @@ |
|||||||
|
package com.teaching.backend.controller.records; |
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
@RestController |
||||||
|
@RequestMapping("/api/courselearingRecord") |
||||||
|
public class CourseLearningRecordController { |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.teaching.backend.mapper.KnowGraph; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author:youhang |
||||||
|
* @Date:2024-06-09-8:59 |
||||||
|
* @Description: |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
import com.teaching.backend.model.dto.KnowGraph.KnowCourseCreateRequest; |
||||||
|
import com.teaching.backend.model.entity.KnowGraph.Know; |
||||||
|
import com.teaching.backend.model.entity.KnowGraph.KnowCourse; |
||||||
|
import org.springframework.data.neo4j.repository.Neo4jRepository; |
||||||
|
import org.springframework.data.neo4j.repository.query.Query; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public interface KnowRepository extends Neo4jRepository<Know, Long> { |
||||||
|
|
||||||
|
|
||||||
|
@Query("MATCH (p:Know), (c:Know) WHERE ID(p) = $id AND ID(c) IN $KnowIds CREATE (p)-[:related]->(c),(c)-[:related]->(p)") |
||||||
|
void addKnowRelatedKnow(Long id, List<Long> KnowIds); |
||||||
|
|
||||||
|
@Query("MATCH (p:Know), (c:Know) WHERE ID(p) = $id AND ID(c) IN $KnowIds CREATE (p)-[:FatherAndSon]->(c)") |
||||||
|
void addKnowFatherAndSonKnow(Long id, List<Long> KnowIds); |
||||||
|
|
||||||
|
@Query("MATCH(n)-[r:related]->(nn:Know) where ID(nn) = $id RETURN n") |
||||||
|
List<Know> queryKnowAllKnowById(Long id); |
||||||
|
|
||||||
|
|
||||||
|
@Query("CREATE (n:Know {name: $name, courseId: $courseId,info:$info,resourceList:$resourceList}) return n") |
||||||
|
KnowCourse createKnowCourse(String courseId, String name, String info, List<Integer>resourceList); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -1,10 +0,0 @@ |
|||||||
package com.teaching.backend.mapper.know; |
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|
||||||
import com.teaching.backend.model.entity.know.Know; |
|
||||||
import org.apache.ibatis.annotations.Mapper; |
|
||||||
|
|
||||||
@Mapper |
|
||||||
public interface KnowMapper extends BaseMapper<Know> { |
|
||||||
|
|
||||||
} |
|
@ -1,18 +0,0 @@ |
|||||||
package com.teaching.backend.mapper.know; |
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|
||||||
import com.teaching.backend.model.entity.know.KnowRelationship; |
|
||||||
import org.apache.ibatis.annotations.Mapper; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p> |
|
||||||
* Mapper 接口 |
|
||||||
* </p> |
|
||||||
* |
|
||||||
* @author author |
|
||||||
* @since 2024-06-20 |
|
||||||
*/ |
|
||||||
@Mapper |
|
||||||
public interface KnowRelationshipMapper extends BaseMapper<KnowRelationship> { |
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,17 @@ |
|||||||
|
package com.teaching.backend.mapper.records; |
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.teaching.backend.model.entity.records.CourseLearningRecord; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* Mapper 接口 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
public interface CourseLearningRecordMapper extends BaseMapper<CourseLearningRecord> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.teaching.backend.mapper.records; |
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* Mapper 接口 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
public interface KnowledgeLearningRecordMapper extends BaseMapper<KnowledgeLearningRecord> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.teaching.backend.mapper.records; |
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.teaching.backend.model.entity.records.ResourceLearningRecord; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* Mapper 接口 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
public interface ResourceLearningRecordMapper extends BaseMapper<ResourceLearningRecord> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
package com.teaching.backend.model.dto.KnowGraph; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author:youhang |
||||||
|
* @Date:2024-07-23-17:30 |
||||||
|
* @Description: |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
import com.teaching.backend.model.entity.KnowGraph.Links; |
||||||
|
import com.teaching.backend.model.vo.knowGraph.KnowVO; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.NoArgsConstructor; |
||||||
|
|
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author:youhang |
||||||
|
* @Date:2024-07-22-5:01 |
||||||
|
* @Description: |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@AllArgsConstructor |
||||||
|
@NoArgsConstructor |
||||||
|
public class BaseKnowReturn { |
||||||
|
|
||||||
|
private Set<KnowVO> knowList; |
||||||
|
|
||||||
|
private Set<Links>linksList; |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
package com.teaching.backend.model.dto.KnowGraph; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import org.springframework.data.neo4j.core.schema.Property; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class KnowCourseCreateRequest implements Serializable { |
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点名称 |
||||||
|
*/ |
||||||
|
private String courseId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点名称 |
||||||
|
*/ |
||||||
|
private String name; |
||||||
|
|
||||||
|
/** |
||||||
|
* 信息 |
||||||
|
*/ |
||||||
|
|
||||||
|
private String info; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点所关联的资源 |
||||||
|
*/ |
||||||
|
@Property |
||||||
|
private List<Integer> resourceList; |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,34 @@ |
|||||||
|
package com.teaching.backend.model.dto.KnowGraph; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import org.springframework.data.neo4j.core.schema.Property; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class KnowRequest implements Serializable { |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点名称 |
||||||
|
*/ |
||||||
|
private String name; |
||||||
|
|
||||||
|
/** |
||||||
|
* 信息 |
||||||
|
*/ |
||||||
|
|
||||||
|
private String info; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点所关联的资源 |
||||||
|
*/ |
||||||
|
@Property |
||||||
|
private List<Integer> resourceList; |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,37 @@ |
|||||||
|
package com.teaching.backend.model.dto.KnowGraph; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import org.springframework.data.neo4j.core.schema.Property; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class KnowUpdateRequest implements Serializable { |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* id |
||||||
|
*/ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点名称 |
||||||
|
*/ |
||||||
|
private String name; |
||||||
|
|
||||||
|
/** |
||||||
|
* 信息 |
||||||
|
*/ |
||||||
|
|
||||||
|
private String info; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点所关联的资源 |
||||||
|
*/ |
||||||
|
@Property |
||||||
|
private List<Integer> resourceList; |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,22 @@ |
|||||||
|
package com.teaching.backend.model.dto.KnowGraph; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class RelationshipKnowRequest implements Serializable { |
||||||
|
|
||||||
|
/** |
||||||
|
* knowid |
||||||
|
*/ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 课程id |
||||||
|
*/ |
||||||
|
private List<Long> KnowIds; |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -1,19 +0,0 @@ |
|||||||
package com.teaching.backend.model.dto.know; |
|
||||||
|
|
||||||
import lombok.Data; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
import java.math.BigDecimal; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点请求 |
|
||||||
*/ |
|
||||||
@Data |
|
||||||
public class KnowQueryRequest implements Serializable { |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点名称 |
|
||||||
*/ |
|
||||||
private String name; |
|
||||||
|
|
||||||
} |
|
@ -1,48 +0,0 @@ |
|||||||
package com.teaching.backend.model.dto.know; |
|
||||||
|
|
||||||
import lombok.Data; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
import java.math.BigDecimal; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点请求 |
|
||||||
*/ |
|
||||||
@Data |
|
||||||
public class KnowRequest implements Serializable { |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点名称 |
|
||||||
*/ |
|
||||||
private String name; |
|
||||||
|
|
||||||
/** |
|
||||||
* 简介 |
|
||||||
*/ |
|
||||||
private String info; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点内容 |
|
||||||
*/ |
|
||||||
private String content; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点图片 |
|
||||||
*/ |
|
||||||
private String img; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点学时 |
|
||||||
*/ |
|
||||||
private BigDecimal hour; |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* 资源id 运用json |
|
||||||
*/ |
|
||||||
private String resourceid; |
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -1,54 +0,0 @@ |
|||||||
package com.teaching.backend.model.dto.know; |
|
||||||
|
|
||||||
import lombok.Data; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
import java.math.BigDecimal; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点请求 |
|
||||||
*/ |
|
||||||
@Data |
|
||||||
public class KnowupdateRequest implements Serializable { |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点id |
|
||||||
*/ |
|
||||||
private Integer id; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点名称 |
|
||||||
*/ |
|
||||||
private String name; |
|
||||||
|
|
||||||
/** |
|
||||||
* 简介 |
|
||||||
*/ |
|
||||||
private String info; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点内容 |
|
||||||
*/ |
|
||||||
private String content; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点图片 |
|
||||||
*/ |
|
||||||
private String img; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点学时 |
|
||||||
*/ |
|
||||||
private BigDecimal hour; |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* 资源id 运用json |
|
||||||
*/ |
|
||||||
private String resourceid; |
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,45 @@ |
|||||||
|
package com.teaching.backend.model.entity.KnowGraph; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import org.springframework.data.neo4j.core.schema.GeneratedValue; |
||||||
|
import org.springframework.data.neo4j.core.schema.Id; |
||||||
|
import org.springframework.data.neo4j.core.schema.Node; |
||||||
|
import org.springframework.data.neo4j.core.schema.Property; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Node |
||||||
|
@Data |
||||||
|
public class Know implements Serializable { |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* id |
||||||
|
*/ |
||||||
|
@Id |
||||||
|
@GeneratedValue |
||||||
|
private Long id; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点名称 |
||||||
|
*/ |
||||||
|
@Property |
||||||
|
private String name; |
||||||
|
|
||||||
|
/** |
||||||
|
* 信息 |
||||||
|
*/ |
||||||
|
@Property |
||||||
|
private String info; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点所关联的资源 |
||||||
|
*/ |
||||||
|
@Property |
||||||
|
private List<Integer> resourceList; |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,50 @@ |
|||||||
|
package com.teaching.backend.model.entity.KnowGraph; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import org.springframework.data.neo4j.core.schema.GeneratedValue; |
||||||
|
import org.springframework.data.neo4j.core.schema.Id; |
||||||
|
import org.springframework.data.neo4j.core.schema.Node; |
||||||
|
import org.springframework.data.neo4j.core.schema.Property; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Node |
||||||
|
@Data |
||||||
|
public class KnowCourse implements Serializable { |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* id |
||||||
|
*/ |
||||||
|
@Id |
||||||
|
@GeneratedValue |
||||||
|
private Long id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点名称 |
||||||
|
*/ |
||||||
|
private String courseId; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点名称 |
||||||
|
*/ |
||||||
|
@Property |
||||||
|
private String name; |
||||||
|
|
||||||
|
/** |
||||||
|
* 信息 |
||||||
|
*/ |
||||||
|
@Property |
||||||
|
private String info; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点所关联的资源 |
||||||
|
*/ |
||||||
|
@Property |
||||||
|
private List<Integer> resourceList; |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,32 @@ |
|||||||
|
package com.teaching.backend.model.entity.KnowGraph; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import org.springframework.data.neo4j.core.schema.GeneratedValue; |
||||||
|
import org.springframework.data.neo4j.core.schema.Id; |
||||||
|
import org.springframework.data.neo4j.core.schema.Node; |
||||||
|
import org.springframework.data.neo4j.core.schema.Property; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author:youhang |
||||||
|
* @Date:2024-07-21-16:32 |
||||||
|
* @Description: |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@Node |
||||||
|
public class Links { |
||||||
|
|
||||||
|
@Id |
||||||
|
@GeneratedValue |
||||||
|
private Long id; |
||||||
|
|
||||||
|
@Property |
||||||
|
private Long source; |
||||||
|
|
||||||
|
@Property |
||||||
|
private Long target; |
||||||
|
|
||||||
|
@Property |
||||||
|
private String label; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,168 @@ |
|||||||
|
package com.teaching.backend.model.entity.courses; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author:youhang |
||||||
|
* @Date:2024-07-07-21:21 |
||||||
|
* @Description: |
||||||
|
*/ |
||||||
|
|
||||||
|
import java.util.Scanner; |
||||||
|
|
||||||
|
class Num { |
||||||
|
public int Zero = 0; |
||||||
|
|
||||||
|
public int One = 0; |
||||||
|
|
||||||
|
public int getZero() { |
||||||
|
return Zero; |
||||||
|
} |
||||||
|
|
||||||
|
public void setZero(int zero) { |
||||||
|
Zero = zero; |
||||||
|
} |
||||||
|
|
||||||
|
public int getOne() { |
||||||
|
return One; |
||||||
|
} |
||||||
|
|
||||||
|
public void setOne(int one) { |
||||||
|
One = one; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 注意类名必须为 Main, 不要有任何 package xxx 信息
|
||||||
|
public class Main { |
||||||
|
public static void main(String[] args) { |
||||||
|
Scanner in = new Scanner(System.in); |
||||||
|
int n = in.nextInt(); |
||||||
|
String[] arr = new String[n]; |
||||||
|
int counts = 0; |
||||||
|
Num num = new Num(); |
||||||
|
for (int i = 0; i < n; i++) { |
||||||
|
arr[i] = in.next(); |
||||||
|
} |
||||||
|
|
||||||
|
int p = 1, q = 1; |
||||||
|
while (p < n) { |
||||||
|
if (arr[0].charAt(0) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
for (int i = 0; i <= p; i++) { |
||||||
|
if (arr[i].charAt(p) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
if (arr[p].charAt(i) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
} |
||||||
|
if (arr[p].charAt(p) == '1') { |
||||||
|
num.One -= 1; |
||||||
|
} else { |
||||||
|
num.Zero -= 1; |
||||||
|
} |
||||||
|
if(num.Zero == num.One){ |
||||||
|
counts++; |
||||||
|
} |
||||||
|
num.One = 0; |
||||||
|
num.Zero = 0; |
||||||
|
|
||||||
|
if (arr[0].charAt(n-1) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
for (int i = 0; i <= p; i++) { |
||||||
|
if (arr[i].charAt(n-1-p) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
if (arr[p].charAt(n-i-1) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
} |
||||||
|
if (arr[p].charAt(n-p-1) == '1') { |
||||||
|
num.One -= 1; |
||||||
|
} else { |
||||||
|
num.Zero -= 1; |
||||||
|
} |
||||||
|
if(num.Zero == num.One){ |
||||||
|
counts++; |
||||||
|
} |
||||||
|
//左下
|
||||||
|
num.One = 0; |
||||||
|
num.Zero = 0; |
||||||
|
|
||||||
|
if (arr[n-1].charAt(0) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
for (int i = 0; i <= p; i++) { |
||||||
|
if (arr[n-1-i].charAt(p) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
if (arr[n-p-1].charAt(i) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
} |
||||||
|
if (arr[n-p-1].charAt(p) == '1') { |
||||||
|
num.One -= 1; |
||||||
|
} else { |
||||||
|
num.Zero -= 1; |
||||||
|
} |
||||||
|
if(num.Zero == num.One){ |
||||||
|
counts++; |
||||||
|
} |
||||||
|
|
||||||
|
//右下
|
||||||
|
num.One = 0; |
||||||
|
num.Zero = 0; |
||||||
|
|
||||||
|
if (arr[n-1].charAt(n-1) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
for (int i = 0; i <= p; i++) { |
||||||
|
if (arr[n-1-i].charAt(n-p-1) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
if (arr[n-p-1].charAt(n-1-i) == '1') { |
||||||
|
num.One += 1; |
||||||
|
} else { |
||||||
|
num.Zero += 1; |
||||||
|
} |
||||||
|
} |
||||||
|
if (arr[n-p-1].charAt(n-1-p) == '1') { |
||||||
|
num.One -= 1; |
||||||
|
} else { |
||||||
|
num.Zero -= 1; |
||||||
|
} |
||||||
|
if(num.Zero == num.One){ |
||||||
|
counts++; |
||||||
|
} |
||||||
|
|
||||||
|
p++; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
@ -1,66 +0,0 @@ |
|||||||
package com.teaching.backend.model.entity.know; |
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType; |
|
||||||
import com.baomidou.mybatisplus.annotation.TableId; |
|
||||||
import com.baomidou.mybatisplus.annotation.TableName; |
|
||||||
import io.swagger.annotations.Api; |
|
||||||
import lombok.AllArgsConstructor; |
|
||||||
import lombok.Data; |
|
||||||
import lombok.EqualsAndHashCode; |
|
||||||
import lombok.NoArgsConstructor; |
|
||||||
import lombok.experimental.Accessors; |
|
||||||
|
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.time.LocalDateTime; |
|
||||||
|
|
||||||
@Data |
|
||||||
@EqualsAndHashCode(callSuper = false) |
|
||||||
@Accessors(chain = true) |
|
||||||
@TableName("know") |
|
||||||
public class Know implements Serializable { |
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L; |
|
||||||
|
|
||||||
/** |
|
||||||
* id |
|
||||||
*/ |
|
||||||
@TableId(value = "id", type = IdType.AUTO) |
|
||||||
private Long id; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点名称 |
|
||||||
*/ |
|
||||||
private String name; |
|
||||||
|
|
||||||
/** |
|
||||||
* 简介 |
|
||||||
*/ |
|
||||||
private String info; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点内容 |
|
||||||
*/ |
|
||||||
private String content; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点图片 |
|
||||||
*/ |
|
||||||
private String img; |
|
||||||
|
|
||||||
/** |
|
||||||
* 知识点学时 |
|
||||||
*/ |
|
||||||
private BigDecimal hour; |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* 资源id 运用json |
|
||||||
*/ |
|
||||||
private String resourceid; |
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
|
|
@ -1,46 +0,0 @@ |
|||||||
package com.teaching.backend.model.entity.know; |
|
||||||
|
|
||||||
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 io.swagger.annotations.ApiModelProperty; |
|
||||||
import lombok.Data; |
|
||||||
import lombok.EqualsAndHashCode; |
|
||||||
import lombok.experimental.Accessors; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p> |
|
||||||
* |
|
||||||
* </p> |
|
||||||
* |
|
||||||
* @author author |
|
||||||
* @since 2024-06-20 |
|
||||||
*/ |
|
||||||
@Data |
|
||||||
@EqualsAndHashCode(callSuper = false) |
|
||||||
@Accessors(chain = true) |
|
||||||
@TableName("know_relationship") |
|
||||||
@ApiModel(value="KnowRelationship对象", description="") |
|
||||||
public class KnowRelationship implements Serializable { |
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L; |
|
||||||
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "章节id") |
|
||||||
@TableField("chapterId") |
|
||||||
private String chapterId; |
|
||||||
|
|
||||||
@ApiModelProperty(value = "课程id") |
|
||||||
@TableField("courseId") |
|
||||||
private String courseId; |
|
||||||
|
|
||||||
@ApiModelProperty(value = "知识点id") |
|
||||||
@TableField("knowId") |
|
||||||
private int knowId; |
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,57 @@ |
|||||||
|
package com.teaching.backend.model.entity.records; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import java.time.LocalDateTime; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import java.io.Serializable; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = false) |
||||||
|
@Accessors(chain = true) |
||||||
|
@TableName("course_learning_record") |
||||||
|
@ApiModel(value="CourseLearningRecord对象", description="") |
||||||
|
public class CourseLearningRecord implements Serializable { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@ApiModelProperty(value = " 课程记录id") |
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private String id; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "课程id") |
||||||
|
@TableField("course_id") |
||||||
|
private String courseId; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户id") |
||||||
|
@TableField("user_id") |
||||||
|
private String userId; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "观看人数") |
||||||
|
@TableField("number") |
||||||
|
private Integer number; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "记录封面") |
||||||
|
@TableField("img") |
||||||
|
private String img; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "最近学习时间") |
||||||
|
@TableField("time") |
||||||
|
private LocalDateTime time; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
package com.teaching.backend.model.entity.records; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import java.time.LocalDateTime; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import java.io.Serializable; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = false) |
||||||
|
@Accessors(chain = true) |
||||||
|
@TableName("knowledge_learning_record") |
||||||
|
@ApiModel(value="KnowledgeLearningRecord对象", description="") |
||||||
|
public class KnowledgeLearningRecord implements Serializable { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "知识点学习记录id") |
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private String id; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "知识点id") |
||||||
|
@TableField("knowledge_id") |
||||||
|
private String knowledgeId; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户id") |
||||||
|
@TableField("user_id") |
||||||
|
private String userId; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "观看人数") |
||||||
|
@TableField("number") |
||||||
|
private Integer number; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "记录封面") |
||||||
|
@TableField("img") |
||||||
|
private String img; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "最近访问时间") |
||||||
|
@TableField("time") |
||||||
|
private LocalDateTime time; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,73 @@ |
|||||||
|
package com.teaching.backend.model.entity.records; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import java.time.LocalDateTime; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import java.io.Serializable; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = false) |
||||||
|
@Accessors(chain = true) |
||||||
|
@TableName("resource_learning_record") |
||||||
|
@ApiModel(value="ResourceLearningRecord对象", description="") |
||||||
|
public class ResourceLearningRecord implements Serializable { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "资源学习记录id") |
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private String id; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "资源id") |
||||||
|
@TableField("resource_id") |
||||||
|
private String resourceId; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户id") |
||||||
|
@TableField("user_id") |
||||||
|
private String userId; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "观看人数") |
||||||
|
@TableField("number") |
||||||
|
private Integer number; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否打开, 1:开打了; 2:未打开;") |
||||||
|
@TableField("open") |
||||||
|
private Integer open; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否下载, 1:下载了; 2:未下载;") |
||||||
|
@TableField(" download") |
||||||
|
private Integer download; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "学习时长") |
||||||
|
@TableField("duration") |
||||||
|
private Integer duration; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否完成观看") |
||||||
|
@TableField("finish") |
||||||
|
private Integer finish; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "记录封面") |
||||||
|
@TableField("img") |
||||||
|
private String img; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "最近学习时间") |
||||||
|
@TableField("time") |
||||||
|
private LocalDateTime time; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
package com.teaching.backend.model.vo.knowGraph; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
|
||||||
|
@Data |
||||||
|
public class KnowVO implements Serializable { |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* id |
||||||
|
*/ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 知识点名称 |
||||||
|
*/ |
||||||
|
private String label; |
||||||
|
|
||||||
|
/** |
||||||
|
* 信息 |
||||||
|
*/ |
||||||
|
private String color; |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,172 @@ |
|||||||
|
package com.teaching.backend.service.KnowGraph; |
||||||
|
|
||||||
|
import com.teaching.backend.mapper.KnowGraph.KnowRepository; |
||||||
|
import com.teaching.backend.model.dto.KnowGraph.*; |
||||||
|
import com.teaching.backend.model.entity.KnowGraph.Know; |
||||||
|
import com.teaching.backend.model.entity.KnowGraph.KnowCourse; |
||||||
|
import com.teaching.backend.model.entity.KnowGraph.Links; |
||||||
|
import com.teaching.backend.model.vo.knowGraph.KnowVO; |
||||||
|
import org.neo4j.driver.internal.InternalRelationship; |
||||||
|
import org.neo4j.driver.types.Node; |
||||||
|
import org.springframework.beans.BeanUtils; |
||||||
|
import org.springframework.data.neo4j.core.Neo4jClient; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author:youhang |
||||||
|
* @Date:2024-07-21-14:46 |
||||||
|
* @Description: |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class KnowService { |
||||||
|
|
||||||
|
private KnowRepository knowRepository; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private Neo4jClient neo4jClient; |
||||||
|
|
||||||
|
public KnowService(KnowRepository knowRepository) { |
||||||
|
this.knowRepository = knowRepository; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public List<Know> queryKnowAllKnowById(Long id) { |
||||||
|
return knowRepository.queryKnowAllKnowById(id); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public Know createKnow(KnowRequest knowRequest ) { |
||||||
|
Know know = new Know(); |
||||||
|
BeanUtils.copyProperties(knowRequest,know); |
||||||
|
return knowRepository.save(know); |
||||||
|
} |
||||||
|
|
||||||
|
public KnowCourse createCourseKnow(KnowCourseCreateRequest knowCourseCreateRequest ) { |
||||||
|
return knowRepository.createKnowCourse(knowCourseCreateRequest.getCourseId(),knowCourseCreateRequest.getName(),knowCourseCreateRequest.getInfo(),knowCourseCreateRequest.getResourceList()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void deleteKnow(Long id) { |
||||||
|
knowRepository.deleteById(id); |
||||||
|
} |
||||||
|
|
||||||
|
public Know updateKnow(KnowUpdateRequest knowUpdateRequest ) { |
||||||
|
Know know = new Know(); |
||||||
|
know = knowRepository.findById(knowUpdateRequest.getId()).orElseThrow(() -> new RuntimeException("知识点 not found")); |
||||||
|
BeanUtils.copyProperties(knowUpdateRequest,know); |
||||||
|
return knowRepository.save(know); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void addKnowRelatedKnow( RelationshipKnowRequest relationshipKnowRequest) { |
||||||
|
knowRepository.addKnowRelatedKnow(relationshipKnowRequest.getId(),relationshipKnowRequest.getKnowIds()); |
||||||
|
} |
||||||
|
public void addKnowFatherAndSonKnow( RelationshipKnowRequest relationshipKnowRequest) { |
||||||
|
knowRepository.addKnowFatherAndSonKnow(relationshipKnowRequest.getId(),relationshipKnowRequest.getKnowIds()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public BaseKnowReturn getKnowAll(String id) { |
||||||
|
Collection<Map<String, Object>> all = |
||||||
|
neo4jClient.query( "match(n:Know)-[r*0..]->(p:Know) where n.courseId = '"+id+"' return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all(); |
||||||
|
|
||||||
|
Map<Long,String>colorChoose = new HashMap<>(); |
||||||
|
String color[] = new String[10]; |
||||||
|
String[] colorList = {"#91CC75", "#5470C6", "#FAC858", "#EE6666", "#73C0DE", "#EA7CCC", "#5577FF", "#5577FF", "#9DBFFF", "#78A7FF"}; |
||||||
|
for (int i = 0; i < 10; i++) { |
||||||
|
colorChoose.put((long) i,colorList[i]); |
||||||
|
} |
||||||
|
|
||||||
|
Iterator<Map<String, Object>> iterator = all.iterator(); |
||||||
|
Set<KnowVO> knowList = new HashSet<>(); |
||||||
|
Set<Links>linksList = new HashSet<>(); |
||||||
|
KnowVO knowVO; |
||||||
|
List node2 = new ArrayList<>(); |
||||||
|
Links links; |
||||||
|
int p = 0; |
||||||
|
while (iterator.hasNext()) { |
||||||
|
Map<String, Object> element = iterator.next(); |
||||||
|
knowVO = new KnowVO(); |
||||||
|
Node node1 = (Node) element.get("p"); |
||||||
|
|
||||||
|
Long group = (Long) element.get("d"); |
||||||
|
knowVO.setColor(colorChoose.get(group)); |
||||||
|
|
||||||
|
Long id1 = node1.id(); |
||||||
|
String name1 = node1.get("name").asString(); |
||||||
|
knowVO.setId(id1); |
||||||
|
knowVO.setLabel(name1); |
||||||
|
|
||||||
|
knowList.add(knowVO); |
||||||
|
|
||||||
|
node2 = (List) element.get("r"); |
||||||
|
for (int i = 0; i < node2.size(); i++) { |
||||||
|
InternalRelationship e = (InternalRelationship) node2.get(i); |
||||||
|
links = new Links(); |
||||||
|
links.setId(e.id()); |
||||||
|
links.setSource(e.startNodeId()); |
||||||
|
links.setTarget(e.endNodeId()); |
||||||
|
links.setLabel(e.type()); |
||||||
|
linksList.add(links); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
BaseKnowReturn baseKnowReturn = new BaseKnowReturn(knowList,linksList); |
||||||
|
System.out.println(baseKnowReturn); |
||||||
|
return baseKnowReturn; |
||||||
|
} |
||||||
|
|
||||||
|
public BaseKnowReturn getKnowById(Long id) { |
||||||
|
Collection<Map<String, Object>> all = |
||||||
|
neo4jClient.query( "match(n:Know)-[r*0..2]->(p:Know) where ID(n) = "+id+" return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all(); |
||||||
|
Map<Long,String>colorChoose = new HashMap<>(); |
||||||
|
String color[] = new String[10]; |
||||||
|
String[] colorList = {"#91CC75", "#5470C6", "#FAC858", "#EE6666", "#73C0DE", "#EA7CCC", "#5577FF", "#5577FF", "#9DBFFF", "#78A7FF"}; |
||||||
|
for (int i = 0; i < 10; i++) { |
||||||
|
colorChoose.put((long) i,colorList[i]); |
||||||
|
} |
||||||
|
|
||||||
|
Iterator<Map<String, Object>> iterator = all.iterator(); |
||||||
|
Set<KnowVO> knowList = new HashSet<>(); |
||||||
|
Set<Links>linksList = new HashSet<>(); |
||||||
|
KnowVO knowVO; |
||||||
|
List node2 = new ArrayList<>(); |
||||||
|
Links links; |
||||||
|
int p = 0; |
||||||
|
while (iterator.hasNext()) { |
||||||
|
Map<String, Object> element = iterator.next(); |
||||||
|
|
||||||
|
knowVO = new KnowVO(); |
||||||
|
Node node1 = (Node) element.get("p"); |
||||||
|
Long group = (Long) element.get("d"); |
||||||
|
knowVO.setColor(colorChoose.get(group)); |
||||||
|
Long id1 = node1.id(); |
||||||
|
String name1 = node1.get("name").asString(); |
||||||
|
knowVO.setId(id1); |
||||||
|
knowVO.setLabel(name1); |
||||||
|
knowList.add(knowVO); |
||||||
|
|
||||||
|
node2 = (List) element.get("r"); |
||||||
|
for (int i = 0; i < node2.size(); i++) { |
||||||
|
InternalRelationship e = (InternalRelationship) node2.get(i); |
||||||
|
links = new Links(); |
||||||
|
links.setId(e.id()); |
||||||
|
links.setSource(e.startNodeId()); |
||||||
|
links.setTarget(e.endNodeId()); |
||||||
|
links.setLabel(e.type()); |
||||||
|
linksList.add(links); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
BaseKnowReturn baseKnowReturn = new BaseKnowReturn(knowList,linksList); |
||||||
|
System.out.println(baseKnowReturn); |
||||||
|
return baseKnowReturn; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,21 +0,0 @@ |
|||||||
package com.teaching.backend.service.impl.know; |
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
||||||
import com.teaching.backend.mapper.know.KnowRelationshipMapper; |
|
||||||
import com.teaching.backend.model.entity.know.KnowRelationship; |
|
||||||
import com.teaching.backend.service.know.IKnowRelationshipService; |
|
||||||
import org.springframework.stereotype.Service; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p> |
|
||||||
* 服务实现类 |
|
||||||
* </p> |
|
||||||
* |
|
||||||
* @author author |
|
||||||
* @since 2024-06-20 |
|
||||||
*/ |
|
||||||
@Service |
|
||||||
public class KnowRelationshipServiceImpl extends ServiceImpl<KnowRelationshipMapper, KnowRelationship> implements IKnowRelationshipService { |
|
||||||
|
|
||||||
} |
|
@ -1,50 +0,0 @@ |
|||||||
package com.teaching.backend.service.impl.know; |
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
||||||
import com.teaching.backend.mapper.know.KnowMapper; |
|
||||||
import com.teaching.backend.model.dto.know.KnowQueryRequest; |
|
||||||
import com.teaching.backend.model.dto.know.KnowRequest; |
|
||||||
import com.teaching.backend.model.dto.know.KnowupdateRequest; |
|
||||||
import com.teaching.backend.model.entity.know.Know; |
|
||||||
import com.teaching.backend.service.know.KnowService; |
|
||||||
import org.springframework.beans.BeanUtils; |
|
||||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||||
import org.springframework.stereotype.Service; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
@Service |
|
||||||
public class KnowServiceimpl extends ServiceImpl<KnowMapper,Know> implements KnowService { |
|
||||||
@Autowired |
|
||||||
private KnowMapper knowMapper; |
|
||||||
@Override |
|
||||||
public Boolean add(KnowRequest knowAddRequest) { |
|
||||||
Know know = new Know(); |
|
||||||
BeanUtils.copyProperties(knowAddRequest,know); |
|
||||||
return save(know); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Boolean update(KnowupdateRequest knowAddRequest) { |
|
||||||
Know know = new Know(); |
|
||||||
BeanUtils.copyProperties(knowAddRequest,know); |
|
||||||
return (updateById(know)); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Integer deleteKnow(List<Integer> ids) { |
|
||||||
Integer result = knowMapper.deleteBatchIds(ids); |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public List<Know> query(KnowQueryRequest knowQueryRequest) { |
|
||||||
String name = knowQueryRequest.getName(); |
|
||||||
QueryWrapper<Know> knowQueryWrapper = new QueryWrapper<>(); |
|
||||||
knowQueryWrapper.eq("name",name); |
|
||||||
List<Know> knows = knowMapper.selectList(knowQueryWrapper); |
|
||||||
return knows; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,22 @@ |
|||||||
|
package com.teaching.backend.service.impl.records; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.teaching.backend.mapper.records.CourseLearningRecordMapper; |
||||||
|
import com.teaching.backend.model.entity.records.CourseLearningRecord; |
||||||
|
import com.teaching.backend.service.records.ICourseLearningRecordService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* 服务实现类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class CourseLearningRecordServiceImpl extends ServiceImpl<CourseLearningRecordMapper, CourseLearningRecord> implements ICourseLearningRecordService { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package com.teaching.backend.service.impl.records; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper; |
||||||
|
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; |
||||||
|
import com.teaching.backend.service.records.IKnowledgeLearningRecordService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* 服务实现类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLearningRecordMapper, KnowledgeLearningRecord> implements IKnowledgeLearningRecordService { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
package com.teaching.backend.service.impl.records; |
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.teaching.backend.mapper.records.ResourceLearningRecordMapper; |
||||||
|
import com.teaching.backend.model.entity.records.ResourceLearningRecord; |
||||||
|
import com.teaching.backend.service.records.IResourceLearningRecordService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* 服务实现类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearningRecordMapper, ResourceLearningRecord> implements IResourceLearningRecordService { |
||||||
|
|
||||||
|
} |
@ -1,16 +0,0 @@ |
|||||||
package com.teaching.backend.service.know; |
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService; |
|
||||||
import com.teaching.backend.model.entity.know.KnowRelationship; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p> |
|
||||||
* 服务类 |
|
||||||
* </p> |
|
||||||
* |
|
||||||
* @author author |
|
||||||
* @since 2024-06-20 |
|
||||||
*/ |
|
||||||
public interface IKnowRelationshipService extends IService<KnowRelationship> { |
|
||||||
} |
|
@ -1,23 +0,0 @@ |
|||||||
package com.teaching.backend.service.know; |
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService; |
|
||||||
import com.teaching.backend.model.dto.favour.knowFavour.KnowFavourAddRequest; |
|
||||||
|
|
||||||
import com.teaching.backend.model.dto.know.KnowQueryRequest; |
|
||||||
import com.teaching.backend.model.dto.know.KnowRequest; |
|
||||||
import com.teaching.backend.model.dto.know.KnowupdateRequest; |
|
||||||
import com.teaching.backend.model.entity.know.Know; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
|
|
||||||
public interface KnowService extends IService<Know> { |
|
||||||
public Boolean add(KnowRequest knowAddRequest); |
|
||||||
|
|
||||||
public Boolean update(KnowupdateRequest knowAddRequest); |
|
||||||
|
|
||||||
public Integer deleteKnow(List<Integer> ids); |
|
||||||
|
|
||||||
public List<Know> query(KnowQueryRequest knowQueryRequest); |
|
||||||
} |
|
||||||
|
|
@ -0,0 +1,17 @@ |
|||||||
|
package com.teaching.backend.service.records; |
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.teaching.backend.model.entity.records.CourseLearningRecord; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* 服务类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
public interface ICourseLearningRecordService extends IService<CourseLearningRecord> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.teaching.backend.service.records; |
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* 服务类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
public interface IKnowledgeLearningRecordService extends IService<KnowledgeLearningRecord> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.teaching.backend.service.records; |
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.teaching.backend.model.entity.records.ResourceLearningRecord; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* 服务类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-24 |
||||||
|
*/ |
||||||
|
public interface IResourceLearningRecordService extends IService<ResourceLearningRecord> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
package com.teaching.backend.utils; |
||||||
|
|
||||||
|
import org.springframework.beans.BeanWrapper; |
||||||
|
import org.springframework.beans.BeanWrapperImpl; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author:youhang |
||||||
|
* @Date:2024-06-23-12:45 |
||||||
|
* @Description: |
||||||
|
*/ |
||||||
|
public class getNullPropertyNamesUtil { |
||||||
|
|
||||||
|
public static String[] getNullPropertyNames (Object source) { |
||||||
|
final BeanWrapper src = new BeanWrapperImpl(source); |
||||||
|
java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors(); |
||||||
|
|
||||||
|
Set<String> emptyNames = new HashSet<String>(); |
||||||
|
for(java.beans.PropertyDescriptor pd : pds) { |
||||||
|
Class<?> propertyType = src.getPropertyType(pd.getName()); |
||||||
|
Object srcValue = src.getPropertyValue(pd.getName()); |
||||||
|
// if ("Integer".equals(propertyType.getName()) || "Long".equals(propertyType.getName())){
|
||||||
|
// Integer value = (Integer) srcValue;
|
||||||
|
// if (value == 0) emptyNames.add(pd.getName());
|
||||||
|
// }
|
||||||
|
if ("BigDecimal".equals(propertyType.getName())){ |
||||||
|
BigDecimal value =(BigDecimal)srcValue; |
||||||
|
if (value == null || (BigDecimal.ZERO).equals(0)) emptyNames.add(pd.getName()); |
||||||
|
} |
||||||
|
if (srcValue == null || srcValue == "") emptyNames.add(pd.getName()); |
||||||
|
} |
||||||
|
String[] result = new String[emptyNames.size()]; |
||||||
|
return emptyNames.toArray(result); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue