12
This commit is contained in:
@@ -730,6 +730,19 @@ public class BaseGraphSerice {
|
||||
return ResultSetUtils.printResultPath(resultSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据明确关系查询一个节点的周边一层节点关系
|
||||
* @param nQ
|
||||
* @return
|
||||
*/
|
||||
public NebulaModel findOnePathById(final String space,final String vid, List<String> relations) {
|
||||
final String fmtVid = StrUtil.format("\"{}\"", vid);
|
||||
final String rl = StringUtils.join(relations, "|");
|
||||
final String fmtrl = StrUtil.format("[r:{}]", rl);
|
||||
final String nGql = StrUtil.format(GqlTemplate.WITHRELATIONBYID, fmtrl, fmtVid);
|
||||
ResultSet resultSet = executeGql(space, nGql);
|
||||
return ResultSetUtils.printResultPath(resultSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询一个头节点和尾结点的关系
|
||||
|
||||
@@ -49,6 +49,8 @@ public interface GqlTemplate {
|
||||
|
||||
final static String ONERELATIONBYID = "MATCH p=(n1)-->(n2) where id(n1)=={} RETURN p";
|
||||
|
||||
final static String WITHRELATIONBYID = "MATCH p=(n1)-{}->(n2) where id(n1)=={} RETURN p";
|
||||
|
||||
final static String ONERELATIONBYSRCIDANDDCTID = "MATCH p=(n1)-->(n2) where id(n1)=={} and id(n2)=={} RETURN p";
|
||||
|
||||
final static String PAGING =" | limit {},{}";
|
||||
|
||||
@@ -382,6 +382,20 @@ public class NebulaOperateController extends BaseController {
|
||||
return success(nebulaOperateService.findOnePathById(space, vid));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询一个节点和明确的关系查询周边一层节点关系
|
||||
* @param nQ
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/findonepathbyidwithrelation/{space}/{vid}")
|
||||
public ResponseData findOnePathById(@PathVariable("space") String space,
|
||||
@PathVariable("vid") String vid,
|
||||
@RequestBody NebulaQo nebulaQo) {
|
||||
return success(nebulaOperateService.findOnePathById(space, vid, nebulaQo.getRelations()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询一个头节点和尾结点的关系
|
||||
* @param nQ
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.wx.application.nebula.graph.query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@@ -18,5 +20,7 @@ public class NebulaQo {
|
||||
private Integer page = 1;
|
||||
|
||||
private Integer pageSize = 200;
|
||||
|
||||
private List<String> relations;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user