| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package com.seeckg.knowledgegraph_backend.pojo;
- 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 lombok.Builder;
- import lombok.Data;
- import org.springframework.data.neo4j.core.schema.Relationship;
- import java.util.HashSet;
- import java.util.Set;
- @Node
- @Builder
- @Data
- public class Knowledge {
- @Id
- @GeneratedValue
- private Long id;
- /**
- * 绑定的课程id,0代表全局知识点
- */
- private long bindClassId;
- /**
- * 创建人id
- */
- private long creatorId;
- /**
- * 知识点名称
- */
- private String name;
- /**
- * 知识点内容
- */
- private String context;
- /**
- * Neo4j doesn't REALLY have bi-directional relationships. It just means when querying
- * to ignore the direction of the relationship.
- * https://dzone.com/articles/modelling-data-neo4j
- */
- //定义关系
- @Relationship(type = "DEFINE")
- public Set<Knowledge> define;
- public void defineRelationship(Knowledge knowledge) {
- if (define == null) {
- define = new HashSet<>();
- }
- define.add(knowledge);
- }
- //相似关系
- @Relationship(type = "SIMILAR")
- public Set<Knowledge> similar;
- public void similarRelationship(Knowledge knowledge) {
- if (similar == null) {
- similar = new HashSet<>();
- }
- similar.add(knowledge);
- }
- //子知识点关系
- @Relationship(type = "SUB")
- public Set<Knowledge> sub;
- public void subRelationship(Knowledge knowledge) {
- if (sub == null) {
- sub = new HashSet<>();
- }
- sub.add(knowledge);
- }
- }
|