Skip to content

Commit efadd00

Browse files
committed
dataway
数据服务组件
1 parent 01e9f92 commit efadd00

File tree

6 files changed

+258
-0
lines changed

6 files changed

+258
-0
lines changed

spring-boot2-dataway/.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**
5+
!**/src/test/**
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
30+
### VS Code ###
31+
.vscode/

spring-boot2-dataway/pom.xml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.0.4.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<groupId>com.example</groupId>
12+
<artifactId>demo</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>spring-boot2-dataway</name>
15+
<description>数据查询接口</description>
16+
17+
<properties>
18+
<java.version>1.8</java.version>
19+
</properties>
20+
21+
<dependencies>
22+
<!--注册中心-->
23+
<dependency>
24+
<groupId>org.springframework.cloud</groupId>
25+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-jdbc</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter-web</artifactId>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>mysql</groupId>
38+
<artifactId>mysql-connector-java</artifactId>
39+
<scope>runtime</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.projectlombok</groupId>
43+
<artifactId>lombok</artifactId>
44+
<optional>true</optional>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.springframework.boot</groupId>
48+
<artifactId>spring-boot-starter-test</artifactId>
49+
<scope>test</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>com.alibaba</groupId>
53+
<artifactId>druid</artifactId>
54+
<version>1.1.21</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>com.alibaba</groupId>
58+
<artifactId>druid-spring-boot-starter</artifactId>
59+
<version>1.1.21</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>net.hasor</groupId>
63+
<artifactId>hasor-dataway</artifactId>
64+
<version>4.1.3-fix20200414</version>
65+
<!--4.1.3版本有bug-->
66+
</dependency>
67+
<dependency>
68+
<groupId>net.hasor</groupId>
69+
<artifactId>hasor-spring</artifactId>
70+
<version>4.1.3</version>
71+
</dependency>
72+
73+
74+
</dependencies>
75+
76+
<dependencyManagement>
77+
<dependencies>
78+
<dependency>
79+
<groupId>org.springframework.boot</groupId>
80+
<artifactId>spring-boot-dependencies</artifactId>
81+
<version>2.0.4.RELEASE</version>
82+
<type>pom</type>
83+
<scope>import</scope>
84+
</dependency>
85+
<dependency>
86+
<groupId>org.springframework.cloud</groupId>
87+
<artifactId>spring-cloud-dependencies</artifactId>
88+
<version>Finchley.RELEASE</version>
89+
<type>pom</type>
90+
<scope>import</scope>
91+
</dependency>
92+
</dependencies>
93+
</dependencyManagement>
94+
95+
<build>
96+
<plugins>
97+
<plugin>
98+
<groupId>org.springframework.boot</groupId>
99+
<artifactId>spring-boot-maven-plugin</artifactId>
100+
</plugin>
101+
</plugins>
102+
</build>
103+
104+
</project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.example.demo;
2+
3+
import net.hasor.spring.boot.EnableHasor;
4+
import net.hasor.spring.boot.EnableHasorWeb;
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
8+
@SpringBootApplication
9+
@EnableHasor
10+
@EnableHasorWeb
11+
public class SpringBoot2DatawayApplication {
12+
13+
public static void main(String[] args) {
14+
SpringApplication.run(SpringBoot2DatawayApplication.class, args);
15+
}
16+
17+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.example.demo.config;
2+
3+
import net.hasor.core.ApiBinder;
4+
import net.hasor.core.DimModule;
5+
import net.hasor.db.JdbcModule;
6+
import net.hasor.db.Level;
7+
import net.hasor.spring.SpringModule;
8+
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.stereotype.Component;
10+
11+
import javax.sql.DataSource;
12+
13+
/**
14+
* <p></p>
15+
* Created by @author zhezhiyong@163.com on 2020/4/16.
16+
*/
17+
@DimModule
18+
@Component
19+
public class ExampleModule implements SpringModule {
20+
@Autowired
21+
private DataSource dataSource = null;
22+
23+
@Override
24+
public void loadModule(ApiBinder apiBinder) throws Throwable {
25+
// .DataSource form Spring boot into Hasor
26+
apiBinder.installModule(new JdbcModule(Level.Full, this.dataSource));
27+
// .custom DataQL
28+
//apiBinder.tryCast(QueryApiBinder.class).loadUdfSource(apiBinder.findClass(DimUdfSource.class));
29+
//apiBinder.tryCast(QueryApiBinder.class).bindFragment("sql", SqlFragment.class);
30+
}
31+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
spring.application.name=dataway
2+
server.port=8080
3+
# 注册中心
4+
eureka.instance.instance-id=${spring.application.name}:${spring.cloud.client.ip-address}:${server.port}
5+
eureka.instance.prefer-ip-address=true
6+
eureka.instance.metadataMap.version=0
7+
eureka.instance.metadataMap.grayScale=false
8+
eureka.client.service-url.defaultZone=http://192.168.97.217:8761/eureka/,http://192.168.97.209:8761/eureka/
9+
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
10+
spring.datasource.url=jdbc:mysql://192.168.97.147:3306/hasor?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
11+
spring.datasource.username=root
12+
spring.datasource.password=666666
13+
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
14+
#初始化时建立物理连接的个数
15+
spring.datasource.druid.initial-size=3
16+
#最小连接池数量
17+
spring.datasource.druid.min-idle=3
18+
#最大连接池数量
19+
spring.datasource.druid.max-active=10
20+
#获取连接时最大等待时间
21+
spring.datasource.druid.max-wait=60000
22+
#配置监控页面访问登录名称
23+
spring.datasource.druid.stat-view-servlet.enabled=true
24+
spring.datasource.druid.stat-view-servlet.allow=127.0.0.1
25+
spring.datasource.druid.stat-view-servlet.login-username=admin
26+
#配置监控页面访问密码
27+
spring.datasource.druid.stat-view-servlet.login-password=admin
28+
#是否开启慢sql查询监控
29+
spring.datasource.druid.filter.stat.enabled=true
30+
spring.datasource.druid.filter.stat.merge-sql=true
31+
spring.datasource.druid.filter.stat.db-type=mysql
32+
spring.datasource.druid.filter.stat.log-slow-sql=true
33+
#慢SQL执行时间
34+
spring.datasource.druid.filter.stat.slow-sql-millis=1
35+
# 启用 Dataway 功能(默认不启用)
36+
HASOR_DATAQL_DATAWAY=true
37+
# 开启 ui 管理功能(注意生产环境必须要设置为 false,否则会造成严重的生产安全事故)
38+
HASOR_DATAQL_DATAWAY_ADMIN=true
39+
# (可选)API工作路径
40+
HASOR_DATAQL_DATAWAY_API_URL=/api/
41+
# (可选)ui 的工作路径,只有开启 ui 管理功能后才有效
42+
HASOR_DATAQL_DATAWAY_UI_URL=/interface-ui/
43+
# 配置方言环境变量,例如: HASOR_DATAQL_FX_PAGE_DIALECT 等于 Mysql (不区分大小写) 建议配置
44+
HASOR_DATAQL_FX_PAGE_DIALECT=mysql
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
CREATE TABLE `interface_info` (
2+
`api_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
3+
`api_method` varchar(12) NOT NULL COMMENT 'HttpMethod:GET、PUT、POST',
4+
`api_path` varchar(512) NOT NULL COMMENT '拦截路径',
5+
`api_status` int(2) NOT NULL COMMENT '状态:0草稿,1发布,2有变更,3禁用',
6+
`api_comment` varchar(255) NULL COMMENT '注释',
7+
`api_type` varchar(24) NOT NULL COMMENT '脚本类型:SQL、DataQL',
8+
`api_script` mediumtext NOT NULL COMMENT '查询脚本:xxxxxxx',
9+
`api_schema` mediumtext NULL COMMENT '接口的请求/响应数据结构',
10+
`api_sample` mediumtext NULL COMMENT '请求/响应/请求头样本数据',
11+
`api_create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
12+
`api_gmt_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
13+
PRIMARY KEY (`api_id`)
14+
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COMMENT='Dataway 中的API';
15+
16+
CREATE TABLE `interface_release` (
17+
`pub_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Publish ID',
18+
`pub_api_id` int(11) NOT NULL COMMENT '所属API ID',
19+
`pub_method` varchar(12) NOT NULL COMMENT 'HttpMethod:GET、PUT、POST',
20+
`pub_path` varchar(512) NOT NULL COMMENT '拦截路径',
21+
`pub_status` int(2) NOT NULL COMMENT '状态:0有效,1无效(可能被下线)',
22+
`pub_type` varchar(24) NOT NULL COMMENT '脚本类型:SQL、DataQL',
23+
`pub_script` mediumtext NOT NULL COMMENT '查询脚本:xxxxxxx',
24+
`pub_script_ori` mediumtext NOT NULL COMMENT '原始查询脚本,仅当类型为SQL时不同',
25+
`pub_schema` mediumtext NULL COMMENT '接口的请求/响应数据结构',
26+
`pub_sample` mediumtext NULL COMMENT '请求/响应/请求头样本数据',
27+
`pub_release_time`datetime DEFAULT CURRENT_TIMESTAMP COMMENT '发布时间(下线不更新)',
28+
PRIMARY KEY (`pub_id`)
29+
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COMMENT='Dataway API 发布历史。';
30+
31+
create index idx_interface_release on interface_release (pub_api_id);

0 commit comments

Comments
 (0)