基于spring boot实现接口管理平台

数据库结构

/*
Navicat MySQL Data Transfer

Source Server         : localhost_3306
Source Server Version : 50724
Source Host           : localhost:3306
Source Database       : interface

Target Server Type    : MYSQL
Target Server Version : 50724
File Encoding         : 65001

Date: 2024-03-18 12:32:48
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for interface
-- ----------------------------
DROP TABLE IF EXISTS `interface`;
CREATE TABLE `interface` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `type` varchar(255) DEFAULT NULL,
  `path` varchar(255) DEFAULT NULL COMMENT '接口的访问路径',
  `status` int(11) NOT NULL DEFAULT '0' COMMENT '接口的完成状态:1:完成  0:未完成',
  `group_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `group_id` (`group_id`),
  CONSTRAINT `interface_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `interface_group` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Table structure for interface_detail
-- ----------------------------
DROP TABLE IF EXISTS `interface_detail`;
CREATE TABLE `interface_detail` (
  `id` int(11) NOT NULL,
  `update_time` datetime DEFAULT NULL,
  `update_id` int(11) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `create_id` int(11) DEFAULT NULL,
  `describe` varchar(255) DEFAULT NULL,
  `heads` varchar(255) DEFAULT NULL,
  `body` varchar(255) DEFAULT NULL COMMENT '存储请求参数,格式为转化为json字符串的List<myInterface>',
  `query` varchar(255) DEFAULT NULL,
  `return_value` varchar(255) DEFAULT NULL,
  `interface_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `interface_id` (`interface_id`),
  CONSTRAINT `interface_detail_ibfk_1` FOREIGN KEY (`interface_id`) REFERENCES `interface` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Table structure for interface_group
-- ----------------------------
DROP TABLE IF EXISTS `interface_group`;
CREATE TABLE `interface_group` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `describe` varchar(255) DEFAULT NULL,
  `project_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `project_id` (`project_id`),
  CONSTRAINT `interface_group_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Table structure for project
-- ----------------------------
DROP TABLE IF EXISTS `project`;
CREATE TABLE `project` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL COMMENT '项目名称',
  `user_id` varchar(255) DEFAULT NULL COMMENT '使用json字符串来储存一个list<Integer>,来储存项目的管理员id',
  `user_ids` varchar(255) DEFAULT NULL COMMENT '使用json字符串来储存一个list<Integer>,来储存项目的组员id',
  `describe` varchar(255) DEFAULT NULL COMMENT '项目的描述信息',
  `token` varchar(255) NOT NULL COMMENT '项目唯一标识码',
  PRIMARY KEY (`id`),
  UNIQUE KEY `token` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;

user表

project 表

interface_group表

interface表 

 

interface_detail表

 项目准备工作

项目架构

项目依赖

<?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.3.9.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>cn.itcast.demo</groupId>
    <artifactId>hotel-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>hotel-demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <elasticsearch.version>7.12.1</elasticsearch.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
        </dependency>

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

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.2</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

		<!--FastJson-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.71</version>
        </dependency>

		<dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>

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

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.3.9.RELEASE</version>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

 实体类准备

 User:

/**
 * 用户
 */
@Data
public class User {
    private Integer id;//用户id
    private String username;//用户账号
    private String password;//用户密码
}

Project:

/**
 * 项目信息
 */
@Data
public class Project {
    private Integer id;//项目id
    private String name;//项目名称
    private String userId;//管理项目的用户id,实际上是一个json字符串存储了List<Integer>
    private String userIds;//组员id,实际上是一个json字符串存储了List<Integer>
    private String describe;//项目描述
    private String token;//项目唯一标识码,用来加入项目
}

InterfaceGroup  

/**
 * 接口分组
 */
@Data
public class InterfaceGroup {
    private Integer id;//接口组id
    private String name;//接口分组名称
    private String describe;//接口分钟描述
    private Integer projectId;//所属项目id
}

 MyInterface 

/**
 * 接口
 */
@Data
public class MyInterface {
    private Integer id;//接口id
    private String name;//接口名称
    private String type;//请求类型
    private String path;//接口路径
    private Integer status;//接口完成状态 1:完成 0 :未完成
    private Integer groupId;//接口所属组别id
}

 InterfaceDetail 

**
 * 接口详细id
 */
@Data
public class InterfaceDetail {
    private Integer id;//接口详细id
    private String describe;//描述
    private String heads;//请求头参数,实际为json字符串,储存list<interfaceParm>
    private String body;//请求体参数,实际为json字符串
    private String query;//请求路径参数,实际为json字符串
    private String returnValue;//返回数据格式,实际为json字符串
    private LocalDateTime createTime;//接口创建时间

    private LocalDateTime updateTime;//接口更新时间

    private Integer createId;//接口创建人id

    private Integer updateId;//接口跟新人id

    private Integer integerId;//所属接口id
}

 interfaceParam 

/**
 * 请求参数
 */
public class interfaceParam {
    private String name;//参数名称
    private String type;//参数类型
    private String status;//是否为必须参数 1:必须 0:非必须
    private String description;//参数描述
}

枚举类准备 

RequestType 

/**
 * 请求类型
 */
public enum RequestType {
    POST,
    GET,
    DELETE,
    PUT,
}

 ParamType 

/**
 * 请求参数类型
 */
public enum ParamType {
    STRING,
    NUMBER,
    ARRAY,
    OBJECT,
    INTEGER,
    BOOLEAN
}

 

  • 10
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

拉普兰德做的到吗?

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值