You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
3.5 KiB
Java
110 lines
3.5 KiB
Java
package com.supervision.neo4j.controller;
|
|
|
|
import com.supervision.common.domain.R;
|
|
import com.supervision.neo4j.domain.CaseNode;
|
|
import com.supervision.neo4j.domain.Rel;
|
|
import com.supervision.neo4j.service.Neo4jService;
|
|
//import io.swagger.annotations.Api;
|
|
//import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author qmy
|
|
* @since 2023-10-26
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/neo4j")
|
|
public class Neo4jController {
|
|
|
|
@Autowired
|
|
private Neo4jService neo4jService;
|
|
|
|
@PostMapping("/save")
|
|
public R<CaseNode> save(@RequestBody CaseNode caseNode) {
|
|
try {
|
|
CaseNode save = neo4jService.save(caseNode);
|
|
return R.ok(save);
|
|
} catch (RuntimeException e) {
|
|
return R.fail(e.getMessage());
|
|
}
|
|
}
|
|
|
|
@PostMapping("/delNode")
|
|
public R<?> delNode(Long id) {
|
|
neo4jService.delNode(id);
|
|
return R.ok();
|
|
}
|
|
|
|
@PostMapping("/deleteRel")
|
|
public R<?> deleteRel(Long relId) {
|
|
neo4jService.deleteRel(relId);
|
|
return R.ok();
|
|
}
|
|
|
|
@PostMapping("/findById")
|
|
public R<?> findById(@RequestParam Long id) {
|
|
CaseNode node = neo4jService.findById(id);
|
|
return R.ok(node);
|
|
}
|
|
|
|
@PostMapping("/findByName")
|
|
public R<?> findByName(@RequestParam String caseId,
|
|
@RequestParam(required = false, defaultValue = "") String recordsId,
|
|
@RequestParam(required = false, defaultValue = "") String nodeType,
|
|
@RequestParam String name,
|
|
@RequestParam(required = false, defaultValue = "1") String picType) {
|
|
List<CaseNode> list = neo4jService.findByName(caseId, recordsId, nodeType, name, picType);
|
|
return R.ok(list);
|
|
}
|
|
|
|
@PostMapping("/findOneByName")
|
|
public R<?> findOneByName(@RequestParam String caseId,
|
|
@RequestParam(required = false, defaultValue = "") String recordsId,
|
|
@RequestParam(required = false, defaultValue = "") String nodeType,
|
|
@RequestParam String name,
|
|
@RequestParam(required = false, defaultValue = "1") String picType) {
|
|
CaseNode node = neo4jService.findOneByName(caseId, recordsId, nodeType, name, picType);
|
|
return R.ok(node);
|
|
}
|
|
|
|
@PostMapping("/findRelation")
|
|
public Rel findRelation(@RequestBody Rel rel) {
|
|
return neo4jService.findRelation(rel);
|
|
}
|
|
|
|
@PostMapping("/saveRelation")
|
|
public R<?> saveRelation(@RequestBody Rel rel) {
|
|
Boolean result = neo4jService.saveRelation(rel);
|
|
return R.judgeResult(result, null, "保存失败");
|
|
}
|
|
|
|
/*************************************************************************************/
|
|
|
|
@GetMapping("/getNode")
|
|
public R<?> getNode(@RequestParam String picType, @RequestParam String caseId) {
|
|
return neo4jService.getNode(picType, caseId);
|
|
}
|
|
|
|
@GetMapping("/test")
|
|
public R<?> test() {
|
|
return neo4jService.test();
|
|
}
|
|
|
|
@ApiOperation("构建抽象图谱")
|
|
@GetMapping("createAbstractGraph")
|
|
public void createAbstractGraph(String path, String sheetName) {
|
|
neo4jService.createAbstractGraph(path, sheetName);
|
|
}
|
|
|
|
@ApiOperation("清除抽象图谱")
|
|
@GetMapping("deleteAbstractGraph")
|
|
public void deleteAbstractGraph() {
|
|
neo4jService.deleteAbstractGraph();
|
|
}
|
|
|
|
}
|