|
@@ -1,157 +1,157 @@
|
|
|
-package com.zglc.kg.controller;
|
|
|
-
|
|
|
-import com.zglc.kg.base.Result;
|
|
|
-import com.zglc.kg.entity.MovieEntity;
|
|
|
-import com.zglc.kg.entity.PersonEntity;
|
|
|
-import com.zglc.kg.entity.BaseRelationEntity;
|
|
|
-import com.zglc.kg.service.MovieService;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiResponse;
|
|
|
-import io.swagger.annotations.ApiResponses;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import org.neo4j.driver.Driver;
|
|
|
-import org.neo4j.driver.Session;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-@Api(tags = "电影图谱接口")
|
|
|
-@RequestMapping("api/movie")
|
|
|
-@CrossOrigin(allowCredentials = "true")
|
|
|
-@RestController
|
|
|
-public class MovieController {
|
|
|
- @Resource
|
|
|
- private MovieService movieService;
|
|
|
-
|
|
|
- private final Driver neo4jDriver;
|
|
|
-
|
|
|
- public MovieController(Driver neo4jDriver) {
|
|
|
- this.neo4jDriver = neo4jDriver;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation("增加电影节点")
|
|
|
- @ApiResponses({
|
|
|
- @ApiResponse(code = 0, message = "成功")
|
|
|
- })
|
|
|
- @PostMapping("addMovie")
|
|
|
- public Result<String> addMovie(@RequestBody MovieEntity movieEntity){
|
|
|
- return movieService.addMovie(movieEntity);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation("增加人物节点")
|
|
|
- @ApiResponses({
|
|
|
- @ApiResponse(code = 0, message = "成功")
|
|
|
- })
|
|
|
- @PostMapping("addPerson")
|
|
|
- public Result<String> addPerson(@RequestBody PersonEntity personEntity){
|
|
|
- return movieService.addPerson(personEntity);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation("增加关系")
|
|
|
- @ApiResponses({
|
|
|
- @ApiResponse(code = 0, message = "成功")
|
|
|
- })
|
|
|
- @PostMapping("addRelation")
|
|
|
- public Result<String> addRelation(@RequestBody BaseRelationEntity baseRelationEntity){
|
|
|
- return movieService.addRelation(baseRelationEntity);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation("删除关系")
|
|
|
- @ApiResponses({
|
|
|
- @ApiResponse(code = 0, message = "成功")
|
|
|
- })
|
|
|
- @PostMapping("deleteRelation")
|
|
|
- public Result<String> deleteRelation(@RequestParam Long id){
|
|
|
- return movieService.deleteRelation(id);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation("查看电影节点")
|
|
|
- @ApiResponses({
|
|
|
- @ApiResponse(code = 0, message = "成功")
|
|
|
- })
|
|
|
- @GetMapping("getMovieById")
|
|
|
- public Result<MovieEntity> getMovieById(@RequestParam Long id){
|
|
|
- return Result.success(movieService.getMovieById(id));
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation("查看人物节点")
|
|
|
- @ApiResponses({
|
|
|
- @ApiResponse(code = 0, message = "成功")
|
|
|
- })
|
|
|
- @GetMapping("getPersonById")
|
|
|
- public Result<PersonEntity> getPersonById(@RequestParam Long id){
|
|
|
- return Result.success(movieService.getPersonById(id));
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation("删除电影节点")
|
|
|
- @ApiResponses({
|
|
|
- @ApiResponse(code = 0, message = "成功")
|
|
|
- })
|
|
|
- @GetMapping("deleteMovie")
|
|
|
- public Result<String> deleteMovie(@RequestParam Long id){
|
|
|
- return movieService.deleteMovie(id);
|
|
|
- }
|
|
|
-// public Result<String> deleteMovie(@RequestBody DeleteEntity deleteEntity){return movieService.deleteMovie(deleteEntity.getIds());}
|
|
|
-
|
|
|
- @ApiOperation("删除人物节点")
|
|
|
- @ApiResponses({
|
|
|
- @ApiResponse(code = 0, message = "成功")
|
|
|
- })
|
|
|
- @GetMapping("deletePerson")
|
|
|
- public Result<String> deletePerson(@RequestParam Long id){
|
|
|
- return movieService.deletePerson(id);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation("根据名称查询电影")//完全一致
|
|
|
- @ApiResponses({
|
|
|
- @ApiResponse(code = 0, message = "成功")
|
|
|
- })
|
|
|
- @GetMapping("getMovieByTitle")
|
|
|
- public Result<List<BaseRelationEntity>> getMovieByTitle(@RequestParam String name){
|
|
|
- return movieService.getMovieByPerson(name);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation("根据名称查询电影1")//完全一致
|
|
|
- @ApiResponses({
|
|
|
- @ApiResponse(code = 0, message = "成功")
|
|
|
- })
|
|
|
- @GetMapping("getMovieByTitle1")
|
|
|
- public Result<List<BaseRelationEntity>> getMovieByTitle1(@RequestParam String name){
|
|
|
- return movieService.getMovieByPerson1(name);
|
|
|
- }
|
|
|
-
|
|
|
-// MATCH (tom:Person {name: "Tom Hanks"})-[:ACTED_IN]->(tomHanksMovies) RETURN tom,tomHanksMovies
|
|
|
-
|
|
|
-
|
|
|
-// @ApiOperation("查询演员所演电影")//完全一致
|
|
|
+//package com.zglc.kg.controller;
|
|
|
+//
|
|
|
+//import com.zglc.kg.base.Result;
|
|
|
+//import com.zglc.kg.entity.MovieEntity;
|
|
|
+//import com.zglc.kg.entity.PersonEntity;
|
|
|
+//import com.zglc.kg.entity.BaseRelationEntity;
|
|
|
+//import com.zglc.kg.service.MovieService;
|
|
|
+//import io.swagger.annotations.Api;
|
|
|
+//import io.swagger.annotations.ApiOperation;
|
|
|
+//import io.swagger.annotations.ApiResponse;
|
|
|
+//import io.swagger.annotations.ApiResponses;
|
|
|
+//import org.springframework.http.MediaType;
|
|
|
+//import org.springframework.web.bind.annotation.*;
|
|
|
+//
|
|
|
+//import org.neo4j.driver.Driver;
|
|
|
+//import org.neo4j.driver.Session;
|
|
|
+//
|
|
|
+//import javax.annotation.Resource;
|
|
|
+//import java.util.List;
|
|
|
+//
|
|
|
+//@Api(tags = "电影图谱接口")
|
|
|
+//@RequestMapping("api/movie")
|
|
|
+//@CrossOrigin(allowCredentials = "true")
|
|
|
+//@RestController
|
|
|
+//public class MovieController {
|
|
|
+// @Resource
|
|
|
+// private MovieService movieService;
|
|
|
+//
|
|
|
+// private final Driver neo4jDriver;
|
|
|
+//
|
|
|
+// public MovieController(Driver neo4jDriver) {
|
|
|
+// this.neo4jDriver = neo4jDriver;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// @ApiOperation("增加电影节点")
|
|
|
+// @ApiResponses({
|
|
|
+// @ApiResponse(code = 0, message = "成功")
|
|
|
+// })
|
|
|
+// @PostMapping("addMovie")
|
|
|
+// public Result<String> addMovie(@RequestBody MovieEntity movieEntity){
|
|
|
+// return movieService.addMovie(movieEntity);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiOperation("增加人物节点")
|
|
|
+// @ApiResponses({
|
|
|
+// @ApiResponse(code = 0, message = "成功")
|
|
|
+// })
|
|
|
+// @PostMapping("addPerson")
|
|
|
+// public Result<String> addPerson(@RequestBody PersonEntity personEntity){
|
|
|
+// return movieService.addPerson(personEntity);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiOperation("增加关系")
|
|
|
+// @ApiResponses({
|
|
|
+// @ApiResponse(code = 0, message = "成功")
|
|
|
+// })
|
|
|
+// @PostMapping("addRelation")
|
|
|
+// public Result<String> addRelation(@RequestBody BaseRelationEntity baseRelationEntity){
|
|
|
+// return movieService.addRelation(baseRelationEntity);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// @ApiOperation("删除关系")
|
|
|
+// @ApiResponses({
|
|
|
+// @ApiResponse(code = 0, message = "成功")
|
|
|
+// })
|
|
|
+// @PostMapping("deleteRelation")
|
|
|
+// public Result<String> deleteRelation(@RequestParam Long id){
|
|
|
+// return movieService.deleteRelation(id);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiOperation("查看电影节点")
|
|
|
+// @ApiResponses({
|
|
|
+// @ApiResponse(code = 0, message = "成功")
|
|
|
+// })
|
|
|
+// @GetMapping("getMovieById")
|
|
|
+// public Result<MovieEntity> getMovieById(@RequestParam Long id){
|
|
|
+// return Result.success(movieService.getMovieById(id));
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiOperation("查看人物节点")
|
|
|
// @ApiResponses({
|
|
|
// @ApiResponse(code = 0, message = "成功")
|
|
|
// })
|
|
|
-// @GetMapping("getMovieByPerson")
|
|
|
-// public Result<MovieEntity> getMovieByPerson(@RequestParam String name){
|
|
|
+// @GetMapping("getPersonById")
|
|
|
+// public Result<PersonEntity> getPersonById(@RequestParam Long id){
|
|
|
+// return Result.success(movieService.getPersonById(id));
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiOperation("删除电影节点")
|
|
|
+// @ApiResponses({
|
|
|
+// @ApiResponse(code = 0, message = "成功")
|
|
|
+// })
|
|
|
+// @GetMapping("deleteMovie")
|
|
|
+// public Result<String> deleteMovie(@RequestParam Long id){
|
|
|
+// return movieService.deleteMovie(id);
|
|
|
+// }
|
|
|
+//// public Result<String> deleteMovie(@RequestBody DeleteEntity deleteEntity){return movieService.deleteMovie(deleteEntity.getIds());}
|
|
|
+//
|
|
|
+// @ApiOperation("删除人物节点")
|
|
|
+// @ApiResponses({
|
|
|
+// @ApiResponse(code = 0, message = "成功")
|
|
|
+// })
|
|
|
+// @GetMapping("deletePerson")
|
|
|
+// public Result<String> deletePerson(@RequestParam Long id){
|
|
|
+// return movieService.deletePerson(id);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiOperation("根据名称查询电影")//完全一致
|
|
|
+// @ApiResponses({
|
|
|
+// @ApiResponse(code = 0, message = "成功")
|
|
|
+// })
|
|
|
+// @GetMapping("getMovieByTitle")
|
|
|
+// public Result<List<BaseRelationEntity>> getMovieByTitle(@RequestParam String name){
|
|
|
+// return movieService.getMovieByPerson(name);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiOperation("根据名称查询电影1")//完全一致
|
|
|
+// @ApiResponses({
|
|
|
+// @ApiResponse(code = 0, message = "成功")
|
|
|
+// })
|
|
|
+// @GetMapping("getMovieByTitle1")
|
|
|
+// public Result<List<BaseRelationEntity>> getMovieByTitle1(@RequestParam String name){
|
|
|
+// return movieService.getMovieByPerson1(name);
|
|
|
+// }
|
|
|
+//
|
|
|
+//// MATCH (tom:Person {name: "Tom Hanks"})-[:ACTED_IN]->(tomHanksMovies) RETURN tom,tomHanksMovies
|
|
|
+//
|
|
|
+//
|
|
|
+//// @ApiOperation("查询演员所演电影")//完全一致
|
|
|
+//// @ApiResponses({
|
|
|
+//// @ApiResponse(code = 0, message = "成功")
|
|
|
+//// })
|
|
|
+//// @GetMapping("getMovieByPerson")
|
|
|
+//// public Result<MovieEntity> getMovieByPerson(@RequestParam String name){
|
|
|
+//// try (Session session = neo4jDriver.session()) {
|
|
|
+//// return session.run("MATCH (tom:Person {name: \"Tom Hanks\"})-[:ACTED_IN]->(tomHanksMovies) RETURN tom,tomHanksMovies");
|
|
|
+//// }
|
|
|
+////
|
|
|
+//// return Result.success(movieService.getMovieByTitle(name));
|
|
|
+//// }
|
|
|
+//
|
|
|
+//
|
|
|
+// @GetMapping(path = "/movies", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+// public List<String> getMovieTitles() {
|
|
|
+//// Driver driver = GraphDatabase.driver( "bolt://localhost:7687", AuthTokens.basic( "neo4j", "neo4j" ) );
|
|
|
// try (Session session = neo4jDriver.session()) {
|
|
|
-// return session.run("MATCH (tom:Person {name: \"Tom Hanks\"})-[:ACTED_IN]->(tomHanksMovies) RETURN tom,tomHanksMovies");
|
|
|
+// return session.run("MATCH (m:Movie) RETURN m ORDER BY m.name ASC")
|
|
|
+// .list(r -> r.get("m").asNode().get("title").asString());
|
|
|
// }
|
|
|
-//
|
|
|
-// return Result.success(movieService.getMovieByTitle(name));
|
|
|
// }
|
|
|
-
|
|
|
-
|
|
|
- @GetMapping(path = "/movies", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public List<String> getMovieTitles() {
|
|
|
-// Driver driver = GraphDatabase.driver( "bolt://localhost:7687", AuthTokens.basic( "neo4j", "neo4j" ) );
|
|
|
- try (Session session = neo4jDriver.session()) {
|
|
|
- return session.run("MATCH (m:Movie) RETURN m ORDER BY m.name ASC")
|
|
|
- .list(r -> r.get("m").asNode().get("title").asString());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//}
|