|
@@ -1,79 +1,55 @@
|
|
|
package com.onemap.apply.controller.dimentity;
|
|
|
|
|
|
-import com.onemap.apply.domain.dimentity.DimEntityDto;
|
|
|
+import com.onemap.apply.domain.dimentity.EntityRelationshipToNeo4jVo;
|
|
|
import com.onemap.apply.mapper.dimentity.DimEntityReponsitory;
|
|
|
import com.onemap.apply.service.dimentity.DimEntityService;
|
|
|
+import com.onemap.common.core.utils.StringUtils;
|
|
|
import com.onemap.common.core.web.domain.RequestResult;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.neo4j.core.Neo4jClient;
|
|
|
-import org.springframework.data.neo4j.core.Neo4jTemplate;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("dimentity")
|
|
|
public class DimEntityController {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private DimEntityReponsitory dimEntityReponsitory;
|
|
|
- @Autowired
|
|
|
- private Neo4jClient neo4jClient;
|
|
|
@Resource
|
|
|
private DimEntityService dimEntityService;
|
|
|
|
|
|
@GetMapping("/entity/code/table/tree")
|
|
|
- public RequestResult queryEntityCodeTableTree(String id) throws IOException {
|
|
|
+ public RequestResult queryEntityCodeTableTree(String id) {
|
|
|
return RequestResult.success(dimEntityService.queryEntityCodeTableTree(id));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/entity/data")
|
|
|
- public RequestResult queryEntityData(String entityid) throws IOException {
|
|
|
+ public RequestResult queryEntityData(String entityid) {
|
|
|
return RequestResult.success(dimEntityService.queryEntityData(entityid));
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/test")
|
|
|
- public RequestResult test() throws IOException {
|
|
|
- dimEntityService.TestToNe04j();
|
|
|
- return RequestResult.success("操作成功", 0);
|
|
|
+ @GetMapping("/entity/relationship")
|
|
|
+ public RequestResult queryEntityRelationship(String entityid) {
|
|
|
+ return RequestResult.success(dimEntityService.queryEntityRelationshipToNeo4j(entityid));
|
|
|
}
|
|
|
|
|
|
-// @GetMapping("/test")
|
|
|
-// public RequestResult test() throws IOException {
|
|
|
-//// List<DimEntityDto> dtoList = dimEntityReponsitory.findAll();
|
|
|
-//// MovieEntity movieEntity = new MovieEntity("电影名001", "电影名001");
|
|
|
-//// movieRepository.save(movieEntity);
|
|
|
-//// return RequestResult.success(movieRepository.findAll());
|
|
|
-//
|
|
|
-//// dimEntityReponsitory.findEntityRelationships3();
|
|
|
-//// DimEntityDto f = new DimEntityDto();
|
|
|
-//// f.setEntityid("MA1001NE103K1034230XXXXXXXXXXXXX2501010009");
|
|
|
-//// dimEntityReponsitory.findAll()
|
|
|
-//
|
|
|
-//
|
|
|
-// DimEntityDto g = dimEntityReponsitory.findEntityRelationships4("MA1001NE103K1034230XXXXXXXXXXXXX2501010009");
|
|
|
-// System.out.println(g);
|
|
|
-//
|
|
|
-//// dimEntityReponsitory.findEntityRelationships5("MA1001NE103K1034230XXXXXXXXXXXXX2501010009", "MA1001NE103K103423043622XXXXXXXX2301010018", "12");
|
|
|
-//
|
|
|
-//// String relationshipType="12";
|
|
|
-//// // 构建 Cypher 查询来创建关系
|
|
|
-//// String cypherQuery = "MATCH (a:Person {id: $personId1}), (b:Person {id: $personId2}) " +
|
|
|
-//// "CREATE (a)-[r:" + relationshipType + "]->(b) " +
|
|
|
-//// "RETURN r";
|
|
|
-//
|
|
|
-// String cql = "match (a:Entity {entityid:'MA1001NE103K1034230XXXXXXXXXXXXX2501010009'}), (b:Entity {entityid:'MA1001NE103K103423043622XXXXXXXX2301010018'}) MERGE (a)-[r:关系]->(b)";
|
|
|
-// neo4jClient.query(cql).run();
|
|
|
-//
|
|
|
-// Collection<Map<String, Object>> all = neo4jClient
|
|
|
-// .query("match (n:Entity{ entityid:'MA1001NE103K1034230XXXXXXXXXXXXX2501010009'}) <-[r]->(b:Entity) return b.entityid, type(r)")
|
|
|
-// .fetch().all();
|
|
|
-// return RequestResult.success(all);
|
|
|
-// }
|
|
|
+ @GetMapping("/entity/add/relationship")
|
|
|
+ public RequestResult addEntityRelationship(EntityRelationshipToNeo4jVo entityRelationshipToNeo4jVo) {
|
|
|
+ if (entityRelationshipToNeo4jVo == null) {
|
|
|
+ return RequestResult.error("参数缺失");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(entityRelationshipToNeo4jVo.getComentityid())) {
|
|
|
+ return RequestResult.error("参数缺失");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(entityRelationshipToNeo4jVo.getEntityid())) {
|
|
|
+ return RequestResult.error("参数缺失");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(entityRelationshipToNeo4jVo.getComrelation())) {
|
|
|
+ return RequestResult.error("参数缺失");
|
|
|
+ }
|
|
|
+ dimEntityService.createEntityRelationshipToNeo4j(entityRelationshipToNeo4jVo);
|
|
|
+ return RequestResult.success("操作成功", 0);
|
|
|
+ }
|
|
|
|
|
|
}
|