| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- package com.lingyue.graph.service;
- import com.lingyue.graph.dto.BatchCreateNodesRequest;
- import com.lingyue.graph.dto.BatchCreateRelationsRequest;
- import com.lingyue.graph.dto.CreateNodeRequest;
- import com.lingyue.graph.dto.CreateRelationRequest;
- import com.lingyue.graph.entity.GraphNode;
- import com.lingyue.graph.entity.GraphRelation;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.stereotype.Service;
- import java.util.*;
- /**
- * 图节点服务(存根)
- * graph_nodes / graph_relations 表已移除,仅保留空实现以兼容 API。
- *
- * @author lingyue
- * @since 2026-01-19
- */
- @Slf4j
- @Service
- public class GraphNodeService {
- // ==================== 节点操作(不持久化) ====================
- public GraphNode createNode(CreateNodeRequest request) {
- GraphNode node = new GraphNode();
- node.setId(UUID.randomUUID().toString().replace("-", ""));
- node.setDocumentId(request.getDocumentId());
- node.setUserId(request.getUserId());
- node.setName(request.getName());
- node.setType(request.getType());
- node.setValue(request.getValue());
- node.setPosition(request.getPosition());
- node.setParentId(request.getParentId());
- node.setLevel(request.getLevel() != null ? request.getLevel() : 0);
- node.setMetadata(request.getMetadata());
- node.setCreateTime(new Date());
- node.setUpdateTime(new Date());
- log.debug("图节点表已移除,createNode 仅返回内存对象: id={}", node.getId());
- return node;
- }
- public List<GraphNode> batchCreateNodes(BatchCreateNodesRequest request) {
- if (request.getNodes() == null || request.getNodes().isEmpty()) {
- return Collections.emptyList();
- }
- List<GraphNode> created = new ArrayList<>();
- for (CreateNodeRequest req : request.getNodes()) {
- if (req.getDocumentId() == null) req.setDocumentId(request.getDocumentId());
- if (req.getUserId() == null) req.setUserId(request.getUserId());
- created.add(createNode(req));
- }
- return created;
- }
- public GraphNode getNodeById(String nodeId) {
- return null;
- }
- public List<GraphNode> getNodesByDocumentId(String documentId) {
- return Collections.emptyList();
- }
- public List<GraphNode> getNodesByDocumentIdAndType(String documentId, String type) {
- return Collections.emptyList();
- }
- public List<GraphNode> getNodesByUserId(String userId) {
- return Collections.emptyList();
- }
- public GraphNode updateNode(String nodeId, CreateNodeRequest request) {
- log.debug("图节点表已移除,updateNode 忽略: nodeId={}", nodeId);
- return null;
- }
- public void deleteNode(String nodeId) {
- log.debug("图节点表已移除,deleteNode 忽略: nodeId={}", nodeId);
- }
- public int deleteNodesByDocumentId(String documentId) {
- return 0;
- }
- // ==================== 关系操作(不持久化) ====================
- public GraphRelation createRelation(CreateRelationRequest request) {
- GraphRelation relation = new GraphRelation();
- relation.setId(UUID.randomUUID().toString().replace("-", ""));
- relation.setFromNodeId(request.getFromNodeId());
- relation.setToNodeId(request.getToNodeId());
- relation.setRelationType(request.getRelationType());
- relation.setActionType(request.getActionType());
- relation.setActionConfig(request.getActionConfig());
- relation.setOrderIndex(request.getOrderIndex() != null ? request.getOrderIndex() : 0);
- relation.setConditionExpr(request.getConditionExpr());
- relation.setMetadata(request.getMetadata());
- relation.setCreateTime(new Date());
- relation.setUpdateTime(new Date());
- log.debug("图关系表已移除,createRelation 仅返回内存对象: id={}", relation.getId());
- return relation;
- }
- public List<GraphRelation> batchCreateRelations(BatchCreateRelationsRequest request) {
- if (request.getRelations() == null || request.getRelations().isEmpty()) {
- return Collections.emptyList();
- }
- List<GraphRelation> created = new ArrayList<>();
- for (CreateRelationRequest req : request.getRelations()) {
- created.add(createRelation(req));
- }
- return created;
- }
- public GraphRelation getRelationById(String relationId) {
- return null;
- }
- public List<GraphRelation> getRelationsByFromNodeId(String fromNodeId) {
- return Collections.emptyList();
- }
- public List<GraphRelation> getRelationsByToNodeId(String toNodeId) {
- return Collections.emptyList();
- }
- public List<GraphRelation> getRelationsByNodeId(String nodeId) {
- return Collections.emptyList();
- }
- public void deleteRelation(String relationId) {
- log.debug("图关系表已移除,deleteRelation 忽略: relationId={}", relationId);
- }
- public Map<String, Object> getNodeStatsByDocumentId(String documentId) {
- Map<String, Object> stats = new HashMap<>();
- stats.put("totalNodes", 0);
- stats.put("typeDistribution", Collections.emptyMap());
- return stats;
- }
- public Map<String, Object> getRelationStatsByDocumentId(String documentId) {
- Map<String, Object> stats = new HashMap<>();
- stats.put("totalRelations", 0);
- stats.put("typeDistribution", Collections.emptyMap());
- return stats;
- }
- }
|