数据库结构
/*
Navicat MySQL Data TransferSource Server : localhost_3306
Source Server Version : 50724
Source Host : localhost:3306
Source Database : interfaceTarget Server Type : MYSQL
Target Server Version : 50724
File Encoding : 65001Date: 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;//用户idprivate String username;//用户账号private String password;//用户密码
}
Project:
/*** 项目信息*/
@Data
public class Project {private Integer id;//项目idprivate 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;//接口组idprivate String name;//接口分组名称private String describe;//接口分钟描述private Integer projectId;//所属项目id
}
MyInterface
/*** 接口*/
@Data
public class MyInterface {private Integer id;//接口idprivate 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;//接口详细idprivate 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;//接口创建人idprivate Integer updateId;//接口跟新人idprivate 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
}