Skip to content

Commit 7bb0e6d

Browse files
committed
初步完成查询
1 parent e84625c commit 7bb0e6d

5 files changed

Lines changed: 489 additions & 25 deletions

File tree

.gitignore

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
# Compiled class file
2-
*.class
3-
4-
# Log file
5-
*.log
6-
7-
# BlueJ files
8-
*.ctxt
9-
10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
12-
13-
# Package Files #
14-
*.jar
15-
*.war
16-
*.nar
17-
*.ear
18-
*.zip
19-
*.tar.gz
20-
*.rar
21-
22-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23-
hs_err_pid*
24-
replay_pid*
1+
/target/
2+
.classpath
3+
.project
4+
.settings
5+
.idea
6+
*.iml

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright ©2021 APIJSON(https://github.com/APIJSON)
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# apijson-surrealdb [![](https://jitpack.io/v/APIJSON/apijson-surrealdb.svg)](https://jitpack.io/#APIJSON/apijson-surrealdb)
2+
腾讯 [APIJSON](https://github.com/Tencent/APIJSON) 6.1.0+ 的 SurrealDB 数据库插件,可通过 Maven, Gradle 等远程依赖。<br />
3+
An SurrealDB plugin for Tencent [APIJSON](https://github.com/Tencent/APIJSON) 6.1.0+
4+
5+
![image](https://github.com/APIJSON/apijson-surrealdb/assets/5738175/243d7a46-e035-4fe6-be63-51cb54d4a69d)
6+
![image](https://github.com/APIJSON/apijson-surrealdb/assets/5738175/3c2919b6-f90a-4a9e-9fb7-592eb4c1a6bb)
7+
8+
9+
## 添加依赖
10+
## Add Dependency
11+
12+
### Maven
13+
#### 1. 在 pom.xml 中添加 JitPack 仓库
14+
#### 1. Add the JitPack repository to pom.xml
15+
```xml
16+
<repositories>
17+
<repository>
18+
<id>jitpack.io</id>
19+
<url>https://jitpack.io</url>
20+
</repository>
21+
</repositories>
22+
```
23+
24+
![image](https://user-images.githubusercontent.com/5738175/167261814-d75d8fff-0e64-4534-a840-60ef628a8873.png)
25+
26+
<br />
27+
28+
#### 2. 在 pom.xml 中添加 apijson-surrealdb 依赖
29+
#### 2. Add the apijson-surrealdb dependency to pom.xml
30+
```xml
31+
<dependency>
32+
<groupId>com.github.APIJSON</groupId>
33+
<artifactId>apijson-surrealdb</artifactId>
34+
<version>LATEST</version>
35+
</dependency>
36+
```
37+
38+
<br />
39+
40+
https://github.com/APIJSON/APIJSON-Demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/pom.xml
41+
42+
<br />
43+
<br />
44+
45+
### Gradle
46+
#### 1. 在项目根目录 build.gradle 中最后添加 JitPack 仓库
47+
#### 1. Add the JitPack repository in your root build.gradle at the end of repositories
48+
```gradle
49+
allprojects {
50+
repositories {
51+
maven { url 'https://jitpack.io' }
52+
}
53+
}
54+
```
55+
<br />
56+
57+
#### 2. 在项目某个 module 目录(例如 `app`) build.gradle 中添加 apijson-surrealdb 依赖
58+
#### 2. Add the apijson-surrealdb dependency in one of your modules(such as `app`)
59+
```gradle
60+
dependencies {
61+
implementation 'com.github.APIJSON:apijson-surrealdb:latest'
62+
}
63+
```
64+
65+
<br />
66+
<br />
67+
<br />
68+
69+
## 使用
70+
## Usage
71+
72+
在你项目继承 AbstractSQLExecutor 的子类重写方法 execute <br/>
73+
Override execute in your SQLExecutor extends AbstractSQLExecutor
74+
75+
```java
76+
@Override
77+
public JSONObject execute(@NotNull SQLConfig<Long> config, boolean unknownType) throws Exception {
78+
if (config.isSurrealDB()) {
79+
return SurrealDBUtil.execute(config, null, unknownType);
80+
}
81+
82+
return super.execute(config, unknownType);
83+
}
84+
```
85+
86+
<br/>
87+
在你项目继承 AbstractSQLConfig 的子类重写方法 execute <br/>
88+
Override execute in your SQLConfig extends AbstractSQLConfig
89+
90+
```java
91+
@Override
92+
public String getNamespace() {
93+
return SurrealDBUtil.getNamespace(super.getNamespace(), DEFAULT_NAMESPACE, isSurrealDB());
94+
}
95+
96+
@Override
97+
public String getSQLNamespace() {
98+
return SurrealDBUtil.getSQLNamespace(super.getSQLNamespace(), isSurrealDB());
99+
}
100+
101+
@Override
102+
public String getSchema() {
103+
return SurrealDBUtil.getSchema(super.getSchema(), DEFAULT_SCHEMA, isSurrealDB());
104+
}
105+
106+
@Override
107+
public String getSQLSchema() {
108+
return SurrealDBUtil.getSQLSchema(super.getSQLSchema(), isSurrealDB());
109+
}
110+
```
111+
112+
#### [SurrealDBUtil](/src/main/java/apijson/surrealdb/SurrealDBUtil.java) 的注释及 [APIJSONBoot-MultiDataSource](https://github.com/APIJSON/APIJSON-Demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource)[DemoSQLExecutor](https://github.com/APIJSON/APIJSON-Demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/demo/DemoSQLExecutor.java) <br />
113+
114+
#### See document in [SurrealDBUtil](/src/main/java/apijson/surrealdb/SurrealDBUtil.java) and [DemoSQLExecutor](https://github.com/APIJSON/APIJSON-Demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/demo/DemoSQLExecutor.java) in [APIJSONBoot-MultiDataSource](https://github.com/APIJSON/APIJSON-Demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource)
115+
116+
<br />
117+
<br />
118+
<br />
119+
120+
有问题可以去 Tencent/APIJSON 提 issue <br />
121+
https://github.com/Tencent/APIJSON/issues/36
122+
123+
<br /><br />
124+
125+
#### 点右上角 ⭐Star 支持一下,谢谢 ^_^
126+
#### Please ⭐Star this project ^_^
127+
https://github.com/APIJSON/apijson-surrealdb

pom.xml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>apijson.surrealdb</groupId>
7+
<artifactId>apijson-surrealdb</artifactId>
8+
<version>1.0.0</version>
9+
<packaging>jar</packaging>
10+
11+
<name>apijson-surrealdb</name>
12+
<description>A SurrealDB plugin for Tencent APIJSON 7.4.0+ </description>
13+
14+
<properties>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
17+
<java.version>1.8</java.version>
18+
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
19+
</properties>
20+
21+
<dependencies>
22+
<!-- APIJSON 需要用的依赖库,1.2.0 以上 -->
23+
<dependency>
24+
<groupId>com.alibaba</groupId>
25+
<artifactId>fastjson</artifactId>
26+
<version>1.2.83</version>
27+
</dependency>
28+
<!-- <dependency>-->
29+
<!-- <groupId>com.github.Tencent</groupId>-->
30+
<!-- <artifactId>APIJSON</artifactId>-->
31+
<!-- <version>7.4.0</version>-->
32+
<!-- </dependency>-->
33+
<dependency>
34+
<groupId>com.surrealdb</groupId>
35+
<artifactId>surrealdb</artifactId>
36+
<version>0.2.0</version>
37+
</dependency>
38+
39+
</dependencies>
40+
41+
<build>
42+
<plugins>
43+
<plugin>
44+
<groupId>org.apache.maven.plugins</groupId>
45+
<artifactId>maven-compiler-plugin</artifactId>
46+
<version>3.12.1</version>
47+
<configuration>
48+
<source>1.8</source>
49+
<target>1.8</target>
50+
</configuration>
51+
</plugin>
52+
53+
<plugin>
54+
<groupId>org.apache.maven.plugins</groupId>
55+
<artifactId>maven-source-plugin</artifactId>
56+
<version>3.2.1</version>
57+
<executions>
58+
<execution>
59+
<phase>package</phase>
60+
<goals>
61+
<goal>jar-no-fork</goal>
62+
</goals>
63+
</execution>
64+
</executions>
65+
</plugin>
66+
</plugins>
67+
</build>
68+
69+
<repositories>
70+
<!-- APIJSON 必须用到的托管平台 -->
71+
<repository>
72+
<id>jitpack.io</id>
73+
<url>https://jitpack.io</url>
74+
<snapshots>
75+
<enabled>true</enabled>
76+
</snapshots>
77+
</repository>
78+
</repositories>
79+
80+
</project>

0 commit comments

Comments
 (0)