GraphNodeService.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. package com.lingyue.graph.service;
  2. import com.lingyue.graph.dto.BatchCreateNodesRequest;
  3. import com.lingyue.graph.dto.BatchCreateRelationsRequest;
  4. import com.lingyue.graph.dto.CreateNodeRequest;
  5. import com.lingyue.graph.dto.CreateRelationRequest;
  6. import com.lingyue.graph.entity.GraphNode;
  7. import com.lingyue.graph.entity.GraphRelation;
  8. import lombok.extern.slf4j.Slf4j;
  9. import org.springframework.stereotype.Service;
  10. import java.util.*;
  11. /**
  12. * 图节点服务(存根)
  13. * graph_nodes / graph_relations 表已移除,仅保留空实现以兼容 API。
  14. *
  15. * @author lingyue
  16. * @since 2026-01-19
  17. */
  18. @Slf4j
  19. @Service
  20. public class GraphNodeService {
  21. // ==================== 节点操作(不持久化) ====================
  22. public GraphNode createNode(CreateNodeRequest request) {
  23. GraphNode node = new GraphNode();
  24. node.setId(UUID.randomUUID().toString().replace("-", ""));
  25. node.setDocumentId(request.getDocumentId());
  26. node.setUserId(request.getUserId());
  27. node.setName(request.getName());
  28. node.setType(request.getType());
  29. node.setValue(request.getValue());
  30. node.setPosition(request.getPosition());
  31. node.setParentId(request.getParentId());
  32. node.setLevel(request.getLevel() != null ? request.getLevel() : 0);
  33. node.setMetadata(request.getMetadata());
  34. node.setCreateTime(new Date());
  35. node.setUpdateTime(new Date());
  36. log.debug("图节点表已移除,createNode 仅返回内存对象: id={}", node.getId());
  37. return node;
  38. }
  39. public List<GraphNode> batchCreateNodes(BatchCreateNodesRequest request) {
  40. if (request.getNodes() == null || request.getNodes().isEmpty()) {
  41. return Collections.emptyList();
  42. }
  43. List<GraphNode> created = new ArrayList<>();
  44. for (CreateNodeRequest req : request.getNodes()) {
  45. if (req.getDocumentId() == null) req.setDocumentId(request.getDocumentId());
  46. if (req.getUserId() == null) req.setUserId(request.getUserId());
  47. created.add(createNode(req));
  48. }
  49. return created;
  50. }
  51. public GraphNode getNodeById(String nodeId) {
  52. return null;
  53. }
  54. public List<GraphNode> getNodesByDocumentId(String documentId) {
  55. return Collections.emptyList();
  56. }
  57. public List<GraphNode> getNodesByDocumentIdAndType(String documentId, String type) {
  58. return Collections.emptyList();
  59. }
  60. public List<GraphNode> getNodesByUserId(String userId) {
  61. return Collections.emptyList();
  62. }
  63. public GraphNode updateNode(String nodeId, CreateNodeRequest request) {
  64. log.debug("图节点表已移除,updateNode 忽略: nodeId={}", nodeId);
  65. return null;
  66. }
  67. public void deleteNode(String nodeId) {
  68. log.debug("图节点表已移除,deleteNode 忽略: nodeId={}", nodeId);
  69. }
  70. public int deleteNodesByDocumentId(String documentId) {
  71. return 0;
  72. }
  73. // ==================== 关系操作(不持久化) ====================
  74. public GraphRelation createRelation(CreateRelationRequest request) {
  75. GraphRelation relation = new GraphRelation();
  76. relation.setId(UUID.randomUUID().toString().replace("-", ""));
  77. relation.setFromNodeId(request.getFromNodeId());
  78. relation.setToNodeId(request.getToNodeId());
  79. relation.setRelationType(request.getRelationType());
  80. relation.setActionType(request.getActionType());
  81. relation.setActionConfig(request.getActionConfig());
  82. relation.setOrderIndex(request.getOrderIndex() != null ? request.getOrderIndex() : 0);
  83. relation.setConditionExpr(request.getConditionExpr());
  84. relation.setMetadata(request.getMetadata());
  85. relation.setCreateTime(new Date());
  86. relation.setUpdateTime(new Date());
  87. log.debug("图关系表已移除,createRelation 仅返回内存对象: id={}", relation.getId());
  88. return relation;
  89. }
  90. public List<GraphRelation> batchCreateRelations(BatchCreateRelationsRequest request) {
  91. if (request.getRelations() == null || request.getRelations().isEmpty()) {
  92. return Collections.emptyList();
  93. }
  94. List<GraphRelation> created = new ArrayList<>();
  95. for (CreateRelationRequest req : request.getRelations()) {
  96. created.add(createRelation(req));
  97. }
  98. return created;
  99. }
  100. public GraphRelation getRelationById(String relationId) {
  101. return null;
  102. }
  103. public List<GraphRelation> getRelationsByFromNodeId(String fromNodeId) {
  104. return Collections.emptyList();
  105. }
  106. public List<GraphRelation> getRelationsByToNodeId(String toNodeId) {
  107. return Collections.emptyList();
  108. }
  109. public List<GraphRelation> getRelationsByNodeId(String nodeId) {
  110. return Collections.emptyList();
  111. }
  112. public void deleteRelation(String relationId) {
  113. log.debug("图关系表已移除,deleteRelation 忽略: relationId={}", relationId);
  114. }
  115. public Map<String, Object> getNodeStatsByDocumentId(String documentId) {
  116. Map<String, Object> stats = new HashMap<>();
  117. stats.put("totalNodes", 0);
  118. stats.put("typeDistribution", Collections.emptyMap());
  119. return stats;
  120. }
  121. public Map<String, Object> getRelationStatsByDocumentId(String documentId) {
  122. Map<String, Object> stats = new HashMap<>();
  123. stats.put("totalRelations", 0);
  124. stats.put("typeDistribution", Collections.emptyMap());
  125. return stats;
  126. }
  127. }