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 batchCreateNodes(BatchCreateNodesRequest request) { if (request.getNodes() == null || request.getNodes().isEmpty()) { return Collections.emptyList(); } List 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 getNodesByDocumentId(String documentId) { return Collections.emptyList(); } public List getNodesByDocumentIdAndType(String documentId, String type) { return Collections.emptyList(); } public List 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 batchCreateRelations(BatchCreateRelationsRequest request) { if (request.getRelations() == null || request.getRelations().isEmpty()) { return Collections.emptyList(); } List created = new ArrayList<>(); for (CreateRelationRequest req : request.getRelations()) { created.add(createRelation(req)); } return created; } public GraphRelation getRelationById(String relationId) { return null; } public List getRelationsByFromNodeId(String fromNodeId) { return Collections.emptyList(); } public List getRelationsByToNodeId(String toNodeId) { return Collections.emptyList(); } public List getRelationsByNodeId(String nodeId) { return Collections.emptyList(); } public void deleteRelation(String relationId) { log.debug("图关系表已移除,deleteRelation 忽略: relationId={}", relationId); } public Map getNodeStatsByDocumentId(String documentId) { Map stats = new HashMap<>(); stats.put("totalNodes", 0); stats.put("typeDistribution", Collections.emptyMap()); return stats; } public Map getRelationStatsByDocumentId(String documentId) { Map stats = new HashMap<>(); stats.put("totalRelations", 0); stats.put("typeDistribution", Collections.emptyMap()); return stats; } }