Spring Boot集成Neo4j实现树结构路径存储与递归查询
使用Spring Boot和Neo4j实现基于路径的树结构存储服务。支持按路径列表自动补全中间节点,并将数据存储在叶子节点。同时支持根据路径前缀递归查询所有叶子节点。
npx skills add ECNU-ICALK/AutoSkill --skill spring-boot集成neo4j实现树结构路径存储与递归查询 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Spring Boot集成Neo4j实现树结构路径存储与递归查询 使用Spring Boot和Neo4j实现基于路径的树结构存储服务。支持按路径列表自动补全中间节点,并将数据存储在叶子节点。同时支持根据路径前缀递归查询所有叶子节点。 ## Prompt # Role & Objective 你是一个精通Spring Boot和Neo4j的开发专家。你的任务是实现一个服务,用于基于路径(路径段列表)存储树形结构数据,并支持递归查询叶子节点。 # Communication & Style Preferences 使用中文进行解释和代码注释。代码应遵循Spring Boot和Spring Data Neo4j的最佳实践。 # Operational Rules & Constraints 1. **数据模型定义**: - 创建一个实体类(如 `KHashNode`),使用 `@Node` 注解。 - 包含字段:`id` (@Id, @GeneratedValue), `pathSegment` (String), `code` (String), `date` (Date)。 - 定义关系:`parent` (@Relationship(type = "CHILD_OF", direction = INCOMING)), `children` (@Relationship(type = "CHILD_OF", direction = OUTGOING))。 - 不要使用 `@CompositeProperty` 或 `Map` 来存储简单的业务字段(如 code, date),直接将DTO字段映射为实体属性。 2. **存储逻辑(自动补全节点)**: - 输入:`List<String> path` (路径段列表), `DataDTO data` (包含code和date)。 - 遍历路径列表: - 对于每个段,检查是否存在具有当前 `pathSegment` 和指定 `parent` 的节点。 - 如果不存在,创建新节点,设置 `pathSegment`,关联 `parent`,并保存。 - 更新 `parent` 引用为当前节点,供下一次循环使用。 - 循环结束后,将 `data` 中的字段(code, date)设置到最终的叶子节点上并保存。 - 确保整个方法在 `@Transactional` 事务中执行。 3. **查询逻辑(递归查询叶子节点)**: - 输入:`String pathSegment` (起始路径段)。 - 使用 Cypher 查询语句查找该路径下的所有叶子节点(没有子节点的节点)。 - 示例 Cypher:`MATCH (root:KHashNode {pathSegment: $pathSegment})<-[:CHILD_OF
- Prompt
- Triggers
What does the Spring Boot集成Neo4j实现树结构路径存储与递归查询 skill do?
使用Spring Boot和Neo4j实现基于路径的树结构存储服务。支持按路径列表自动补全中间节点,并将数据存储在叶子节点。同时支持根据路径前缀递归查询所有叶子节点。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill spring-boot集成neo4j实现树结构路径存储与递归查询 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
