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

2024-09-03 09:44

本文主要是介绍实战项目-快速实战-springboot dataway,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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

访问地址

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

效果图

具体怎么用, 大家还是看官网,中文文档
https://www.dataql.net/docs/dataway/ui/ui-list
在这里插入图片描述

项目结构

在这里插入图片描述

代码

DataWayApplication

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

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 {@Resourceprivate DataSource dataSource;@Overridepublic void loadModule (ApiBinder apiBinder) throws Throwable {apiBinder.installModule(new JdbcModule(Level.Full, this.dataSource));}
}

application.yml

#
server:port: 8101
spring:application:name: dataway-demodatasource:url: jdbc:mysql://localhost:3306/test?characterEncoding=utf-8&useSSL=falseusername: rootpassword: rootdriver-class-name: com.mysql.jdbc.Drivertype: com.alibaba.druid.pool.DruidDataSource# druiddruid:initial-size: 3min-idle: 3max-active: 10max-wait: 60000stat-view-servlet:login-username: adminlogin-password: adminfilter:stat:log-slow-sql: trueslow-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 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>

初始化脚本

# 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_infounique (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_apion interface_release (pub_api_id);create index idx_interface_release_pathon interface_release (pub_path);

项目源码

【金山文档 | WPS云文档】 dataway-demo
https://kdocs.cn/l/cm2uYUv7cKXO

这篇关于实战项目-快速实战-springboot dataway的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1132648

相关文章

springboot rocketmq配置生产者和消息者的步骤

《springbootrocketmq配置生产者和消息者的步骤》本文介绍了如何在SpringBoot中集成RocketMQ,包括添加依赖、配置application.yml、创建生产者和消费者,并展... 目录1. 添加依赖2. 配置application.yml3. 创建生产者4. 创建消费者5. 使用在

Spring Retry 实现乐观锁重试实践记录

《SpringRetry实现乐观锁重试实践记录》本文介绍了在秒杀商品SKU表中使用乐观锁和MybatisPlus配置乐观锁的方法,并分析了测试环境和生产环境的隔离级别对乐观锁的影响,通过简单验证,... 目录一、场景分析 二、简单验证 2.1、可重复读 2.2、读已提交 三、最佳实践 3.1、配置重试模板

Spring中@Lazy注解的使用技巧与实例解析

《Spring中@Lazy注解的使用技巧与实例解析》@Lazy注解在Spring框架中用于延迟Bean的初始化,优化应用启动性能,它不仅适用于@Bean和@Component,还可以用于注入点,通过将... 目录一、@Lazy注解的作用(一)延迟Bean的初始化(二)与@Autowired结合使用二、实例解

SpringBoot使用Jasypt对YML文件配置内容加密的方法(数据库密码加密)

《SpringBoot使用Jasypt对YML文件配置内容加密的方法(数据库密码加密)》本文介绍了如何在SpringBoot项目中使用Jasypt对application.yml文件中的敏感信息(如数... 目录SpringBoot使用Jasypt对YML文件配置内容进行加密(例:数据库密码加密)前言一、J

Java中有什么工具可以进行代码反编译详解

《Java中有什么工具可以进行代码反编译详解》:本文主要介绍Java中有什么工具可以进行代码反编译的相关资,料,包括JD-GUI、CFR、Procyon、Fernflower、Javap、Byte... 目录1.JD-GUI2.CFR3.Procyon Decompiler4.Fernflower5.Jav

Spring Boot 中正确地在异步线程中使用 HttpServletRequest的方法

《SpringBoot中正确地在异步线程中使用HttpServletRequest的方法》文章讨论了在SpringBoot中如何在异步线程中正确使用HttpServletRequest的问题,... 目录前言一、问题的来源:为什么异步线程中无法访问 HttpServletRequest?1. 请求上下文与线

在 Spring Boot 中使用异步线程时的 HttpServletRequest 复用问题记录

《在SpringBoot中使用异步线程时的HttpServletRequest复用问题记录》文章讨论了在SpringBoot中使用异步线程时,由于HttpServletRequest复用导致... 目录一、问题描述:异步线程操作导致请求复用时 Cookie 解析失败1. 场景背景2. 问题根源二、问题详细分

Java对象和JSON字符串之间的转换方法(全网最清晰)

《Java对象和JSON字符串之间的转换方法(全网最清晰)》:本文主要介绍如何在Java中使用Jackson库将对象转换为JSON字符串,并提供了一个简单的工具类示例,该工具类支持基本的转换功能,... 目录前言1. 引入 Jackson 依赖2. 创建 jsON 工具类3. 使用示例转换 Java 对象为

SpringBoot快速接入OpenAI大模型的方法(JDK8)

《SpringBoot快速接入OpenAI大模型的方法(JDK8)》本文介绍了如何使用AI4J快速接入OpenAI大模型,并展示了如何实现流式与非流式的输出,以及对函数调用的使用,AI4J支持JDK8... 目录使用AI4J快速接入OpenAI大模型介绍AI4J-github快速使用创建SpringBoot

Vue项目的甘特图组件之dhtmlx-gantt使用教程和实现效果展示(推荐)

《Vue项目的甘特图组件之dhtmlx-gantt使用教程和实现效果展示(推荐)》文章介绍了如何使用dhtmlx-gantt组件来实现公司的甘特图需求,并提供了一个简单的Vue组件示例,文章还分享了一... 目录一、首先 npm 安装插件二、创建一个vue组件三、业务页面内 引用自定义组件:四、dhtmlx