实战项目-快速实战-springboot dataway

最后附项目源码, 开箱即用

访问地址

http://127.0.0.1:8101/interface-ui/#/

效果图

具体怎么用, 大家还是看官网,中文文档

https://www.dataql.net/docs/dataway/ui/ui-list

项目结构

代码

DataWayApplication

java 复制代码
package com.zero.dataway;

import net.hasor.spring.boot.EnableHasor;
import net.hasor.spring.boot.EnableHasorWeb;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@EnableHasor
@EnableHasorWeb
@SpringBootApplication(scanBasePackages = {"com.zero.hasor"})
public class DataWayApplication {

  public static void main(String[] args) {
    SpringApplication.run(DataWayApplication.class, args);
  }
}

HasorModule

java 复制代码
package com.zero.hasor;

import net.hasor.core.ApiBinder;
import net.hasor.core.DimModule;
import net.hasor.db.JdbcModule;
import net.hasor.db.Level;
import net.hasor.spring.SpringModule;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.sql.DataSource;

@DimModule
@Component
public class HasorModule implements SpringModule {

    @Resource
    private DataSource dataSource;

    @Override
    public void loadModule (ApiBinder apiBinder) throws Throwable {
        apiBinder.installModule(new JdbcModule(Level.Full, this.dataSource));
    }
}

application.yml

yaml 复制代码
#
server:
  port: 8101
spring:
  application:
    name: dataway-demo

  datasource:
    url: jdbc:mysql://localhost:3306/test?characterEncoding=utf-8&useSSL=false
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource

    # druid
    druid:
      initial-size: 3
      min-idle: 3
      max-active: 10
      max-wait: 60000
      stat-view-servlet:
        login-username: admin
        login-password: admin
      filter:
        stat:
          log-slow-sql: true
          slow-sql-millis: 1

# 是否启用 Dataway 功能(必选:默认false)
HASOR_DATAQL_DATAWAY: true
# 是否开启 Dataway 后台管理界面(必选:默认false)
HASOR_DATAQL_DATAWAY_ADMIN: true
# dataway  API工作路径(可选,默认:/api/)
HASOR_DATAQL_DATAWAY_API_URL: /api/
# dataway-ui 的工作路径(可选,默认:/interface-ui/)
HASOR_DATAQL_DATAWAY_UI_URL: /interface-ui/
# SQL执行器方言设置(可选,建议设置)
HASOR_DATAQL_FX_PAGE_DIALECT: mysql

pom.xml

xml 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>com.zero</groupId>
    <artifactId>dataway-demo</artifactId>
    <version>0.0.1</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <version>2.2.7.RELEASE</version>
        <artifactId>spring-boot-starter-parent</artifactId>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>net.hasor</groupId>
            <artifactId>hasor-spring</artifactId>
            <version>4.1.6</version>
        </dependency>
        <dependency>
            <groupId>net.hasor</groupId>
            <artifactId>hasor-dataway</artifactId>
            <version>4.1.6</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.49</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.2</version>
        </dependency>
    </dependencies>

</project>

初始化脚本

sql 复制代码
# select * from interface_info;



/*
    访问地址
    http://127.0.0.1:8101/interface-ui/#/
*/

-- auto-generated definition
create table interface_info
(
    api_id          int auto_increment comment 'ID'
        primary key,
    api_method      varchar(12)  not null comment 'HttpMethod:GET、PUT、POST',
    api_path        varchar(512) not null comment '拦截路径',
    api_status      varchar(4)   not null comment '状态:-1-删除, 0-草稿,1-发布,2-有变更,3-禁用',
    api_comment     varchar(255) not null comment '注释',
    api_type        varchar(24)  not null comment '脚本类型:SQL、DataQL',
    api_script      mediumtext   not null comment '查询脚本:xxxxxxx',
    api_schema      mediumtext   not null comment '接口的请求/响应数据结构',
    api_sample      mediumtext   not null comment '请求/响应/请求头样本数据',
    api_option      mediumtext   not null comment '扩展配置信息',
    api_create_time varchar(32)  not null comment '创建时间',
    api_gmt_time    varchar(32)  not null comment '修改时间',
    constraint uk_interface_info
        unique (api_path)
)
    comment 'Dataway 中的API';





-- auto-generated definition
create table interface_release
(
    pub_id           int auto_increment comment 'Publish ID'
        primary key,
    pub_api_id       varchar(64)  not null comment '所属API ID',
    pub_method       varchar(12)  not null comment 'HttpMethod:GET、PUT、POST',
    pub_path         varchar(512) not null comment '拦截路径',
    pub_status       varchar(4)   not null comment '状态:-1-删除, 0-草稿,1-发布,2-有变更,3-禁用',
    pub_comment      varchar(255) null comment '注释',
    pub_type         varchar(24)  not null comment '脚本类型:SQL、DataQL',
    pub_script       mediumtext   not null comment '查询脚本:xxxxxxx',
    pub_script_ori   mediumtext   not null comment '原始查询脚本,仅当类型为SQL时不同',
    pub_schema       mediumtext   not null comment '接口的请求/响应数据结构',
    pub_sample       mediumtext   not null comment '请求/响应/请求头样本数据',
    pub_option       mediumtext   not null comment '扩展配置信息',
    pub_release_time varchar(32)  not null comment '发布时间(下线不更新)'
)
    comment 'Dataway API 发布历史。';

create index idx_interface_release_api
    on interface_release (pub_api_id);

create index idx_interface_release_path
    on interface_release (pub_path);

项目源码

【金山文档 | WPS云文档】 dataway-demo

https://kdocs.cn/l/cm2uYUv7cKXO

相关推荐
孟无岐1 天前
AI小游戏·极简贪食蛇
源码·小游戏·laya·ai游戏开发·贪食蛇
淘源码d1 天前
基于Spring Cloud Alibaba的智慧工地微服务源码实战:快速构建与二次开发指南
java·源码·二次开发·saas·智慧工地
万岳软件开发小城2 天前
企业级项目实录:在线教育系统源码如何支撑考试答题小程序开发
开源·源码·在线教育系统源码·教育软件开发·考试刷题软件开发·答题考试系统源码·教育培训小程序开发
2501_937145412 天前
神马影视8.8版2026最新版:核心技术升级与多场景适配解析
android·源码·电视盒子·源代码管理
WangYaolove13143 天前
基于人脸表情的分类算法的设计(源码+文档)
python·mysql·django·毕业设计·源码
WangYaolove13143 天前
基于图像取证技术研究与实现(源码+文档)
python·django·毕业设计·源码·计算机源码
千寻技术帮3 天前
10408_基于SSM的野营用品租赁管理系统
毕业设计·ssm·源码·安装·文档·ppt·野营租赁
万岳科技程序员小金4 天前
用招聘系统源码做平台创业:人才招聘平台开发的可行性与盈利模型分析
大数据·源码·同城招聘系统源码·招聘app开发·招聘源码·人才招聘平台开发·招聘小程序开发
biyezuopinvip4 天前
基于深度学习的新闻文本分类系统的研究与设计(源码)
人工智能·深度学习·分类·源码·代码·基于深度学习的·新闻文本分类系统的研究与设计
2501_937189235 天前
IPTV 2026 优化版:解码适配 + 安全运维双升级,筑牢使用体验基石
android·源码·开源软件·源代码管理