-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
39 changed files
with
1,107 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.7.0</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<artifactId>kg-api</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>kg-api</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-redis</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-tomcat</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-undertow</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.nebula-contrib</groupId> | ||
<artifactId>ngbatis</artifactId> | ||
<version>1.2.2</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
22 changes: 22 additions & 0 deletions
22
examples/kg-api/src/main/java/org/nebula/contrib/kg/KgApiApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.nebula.contrib.kg; | ||
|
||
// Copyright (c) 2024 All project authors. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
|
||
/** | ||
* Hello world! | ||
*/ | ||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, | ||
scanBasePackages = {"org.nebula.contrib", "org.nebula.contrib.kg"}) | ||
public class KgApiApp { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication app = new SpringApplication(KgApiApp.class); | ||
app.run(args); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
examples/kg-api/src/main/java/org/nebula/contrib/kg/controller/DataController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.nebula.contrib.kg.controller; | ||
|
||
// Copyright (c) 2024 All project authors. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
import java.util.List; | ||
import org.nebula.contrib.kg.pojo.Triplet; | ||
import org.nebula.contrib.kg.service.DataService; | ||
import org.nebula.contrib.kg.utils.R; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author yeweicheng | ||
* @since 2024-09-02 15:46 | ||
* <br>Now is history! | ||
*/ | ||
@RestController | ||
@RequestMapping("/kg/data") | ||
public class DataController { | ||
|
||
@Autowired | ||
private DataService service; | ||
|
||
@RequestMapping("next") | ||
public R<List<Triplet<String>>> next(String id) { | ||
return R.ok(service.next(id)); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
examples/kg-api/src/main/java/org/nebula/contrib/kg/controller/SchemaController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.nebula.contrib.kg.controller; | ||
|
||
// Copyright (c) 2024 All project authors. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author yeweicheng | ||
* @since 2024-09-02 15:46 | ||
* <br>Now is history! | ||
*/ | ||
@RestController | ||
@RequestMapping("/kg/schema") | ||
public class SchemaController { | ||
|
||
// TODO | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
examples/kg-api/src/main/java/org/nebula/contrib/kg/dao/DataDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.nebula.contrib.kg.dao; | ||
|
||
// Copyright (c) 2024 All project authors. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
import java.util.List; | ||
import org.nebula.contrib.kg.pojo.Triplet; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
/** | ||
* @author yeweicheng | ||
* @since 2024-09-02 15:54 | ||
* <br>Now is history! | ||
*/ | ||
public interface DataDao<T> { | ||
|
||
List<Triplet<T>> selectTriplets(@Param("id") T id); | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...es/kg-api/src/main/java/org/nebula/contrib/kg/ngbatis/CollectionTripletResultHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.nebula.contrib.kg.ngbatis; | ||
|
||
// Copyright (c) 2024 All project authors. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
import com.vesoft.nebula.client.graph.data.ResultSet; | ||
import java.util.Collection; | ||
import org.nebula.contrib.kg.pojo.Triplet; | ||
import org.nebula.contrib.ngbatis.handler.AbstractResultHandler; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* @author yeweicheng | ||
* @since 2024-08-28 13:59 | ||
* <br>Now is history! | ||
*/ | ||
@Component | ||
public class CollectionTripletResultHandler extends | ||
AbstractResultHandler<Collection, Triplet<String>> { | ||
|
||
@Autowired | ||
private TripletResultHandler singleHandler; | ||
|
||
@Override | ||
public Collection handle(Collection newResult, ResultSet result, Class resultType) | ||
throws NoSuchFieldException, IllegalAccessException, InstantiationException { | ||
|
||
int rowsSize = result.rowsSize(); | ||
for (int i = 0; i < rowsSize; i++) { | ||
ResultSet.Record row = result.rowValues(i); | ||
Triplet<String> triplet = new Triplet<>(); | ||
triplet = singleHandler.handle(triplet, row); | ||
newResult.add(triplet); | ||
} | ||
return newResult; | ||
} | ||
|
||
} |
Oops, something went wrong.