CRUD还要后端写?
前端自己搞定,只需要会写sql就行。
文档写的比我写的好太多,直接看文档
创建springBoot(springBoot版本要小于3.0)
引入pom
<?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 https://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.11</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>demo</description>
<properties>
<java.version>8</java.version>
<swagger.version>2.6.1</swagger.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.27</version>
</dependency>
<dependency>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-plugin-swagger</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
别用本地模式存储,太low了, 这里用数据库
数据库建立(0.7版本后),在你要访问的数据库中建立
CREATE TABLE `magic_api_file_v2` (
`file_path` varchar(512) NOT NULL,
`file_content` mediumtext,
PRIMARY KEY (`file_path`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
备份表建立
CREATE TABLE `magic_backup_record_v2` ( `id` varchar(32) NOT NULL COMMENT '原对象ID', `create_date` bigint(13) NOT NULL COMMENT '备份时间', `tag` varchar(32) DEFAULT NULL COMMENT '标签', `type` varchar(32) DEFAULT NULL COMMENT '类型', `name` varchar(64) DEFAULT NULL COMMENT '原名称', `content` blob COMMENT '备份内容', `create_by` varchar(64) DEFAULT NULL COMMENT '操作人', PRIMARY KEY (`id`,`create_date`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
application.yml配置(注意我的是yml)
server:
port: 9999
magic-api:
web: /magic/web
resource:
# location: D:/data/magic-api
type: database # 配置存储在数据库中
tableName: magic_api_file_v2 # 数据库中的表名,要在数据库中创建
prefix: /test_learning # key前缀与数据库前缀保持一致
readonly: false # 是否是只读模式
security:
username: # 登录用的用户名
password: # 登录用的密码
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://xxx:3306/test_learning?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
username: root
password: xxxx
redis:
#host: 127.0.0.1
host: xxx
port: 6379
database: 4
password: xxx
Htpp测试
import http;
var url = "https://api.weixin.qq.com/sns/jscode2session";
var plateform = http.connect(url).get().getBody();
return plateform
相同,说明这个很牛逼啊
去gitee上打开目录直接看,只看官网文档不够的,主要是在git上看
magic-api: magic-api 是一个基于Java的接口快速开发框架,通过magic-api提供的UI界面完成编写接口,无需定义Controller、Service、Dao、Mapper、XML、VO等Java对象即可完成常见的HTTP API接口开发 - Gitee.com
快速开始 | magic-api