当前位置:   article > 正文

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

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

数据库结构

  1. /*
  2. Navicat MySQL Data Transfer
  3. Source Server : localhost_3306
  4. Source Server Version : 50724
  5. Source Host : localhost:3306
  6. Source Database : interface
  7. Target Server Type : MYSQL
  8. Target Server Version : 50724
  9. File Encoding : 65001
  10. Date: 2024-03-18 12:32:48
  11. */
  12. SET FOREIGN_KEY_CHECKS=0;
  13. -- ----------------------------
  14. -- Table structure for interface
  15. -- ----------------------------
  16. DROP TABLE IF EXISTS `interface`;
  17. CREATE TABLE `interface` (
  18. `id` int(11) NOT NULL AUTO_INCREMENT,
  19. `name` varchar(255) NOT NULL,
  20. `type` varchar(255) DEFAULT NULL,
  21. `path` varchar(255) DEFAULT NULL COMMENT '接口的访问路径',
  22. `status` int(11) NOT NULL DEFAULT '0' COMMENT '接口的完成状态:1:完成 0:未完成',
  23. `group_id` int(11) NOT NULL,
  24. PRIMARY KEY (`id`),
  25. KEY `group_id` (`group_id`),
  26. CONSTRAINT `interface_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `interface_group` (`id`)
  27. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  28. -- ----------------------------
  29. -- Table structure for interface_detail
  30. -- ----------------------------
  31. DROP TABLE IF EXISTS `interface_detail`;
  32. CREATE TABLE `interface_detail` (
  33. `id` int(11) NOT NULL,
  34. `update_time` datetime DEFAULT NULL,
  35. `update_id` int(11) DEFAULT NULL,
  36. `create_time` datetime DEFAULT NULL,
  37. `create_id` int(11) DEFAULT NULL,
  38. `describe` varchar(255) DEFAULT NULL,
  39. `heads` varchar(255) DEFAULT NULL,
  40. `body` varchar(255) DEFAULT NULL COMMENT '存储请求参数,格式为转化为json字符串的List<myInterface>',
  41. `query` varchar(255) DEFAULT NULL,
  42. `return_value` varchar(255) DEFAULT NULL,
  43. `interface_id` int(11) NOT NULL,
  44. PRIMARY KEY (`id`),
  45. KEY `interface_id` (`interface_id`),
  46. CONSTRAINT `interface_detail_ibfk_1` FOREIGN KEY (`interface_id`) REFERENCES `interface` (`id`)
  47. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  48. -- ----------------------------
  49. -- Table structure for interface_group
  50. -- ----------------------------
  51. DROP TABLE IF EXISTS `interface_group`;
  52. CREATE TABLE `interface_group` (
  53. `id` int(11) NOT NULL AUTO_INCREMENT,
  54. `name` varchar(255) DEFAULT NULL,
  55. `describe` varchar(255) DEFAULT NULL,
  56. `project_id` int(11) NOT NULL,
  57. PRIMARY KEY (`id`),
  58. KEY `project_id` (`project_id`),
  59. CONSTRAINT `interface_group_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`)
  60. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  61. -- ----------------------------
  62. -- Table structure for project
  63. -- ----------------------------
  64. DROP TABLE IF EXISTS `project`;
  65. CREATE TABLE `project` (
  66. `id` int(11) NOT NULL AUTO_INCREMENT,
  67. `name` varchar(255) DEFAULT NULL COMMENT '项目名称',
  68. `user_id` varchar(255) DEFAULT NULL COMMENT '使用json字符串来储存一个list<Integer>,来储存项目的管理员id',
  69. `user_ids` varchar(255) DEFAULT NULL COMMENT '使用json字符串来储存一个list<Integer>,来储存项目的组员id',
  70. `describe` varchar(255) DEFAULT NULL COMMENT '项目的描述信息',
  71. `token` varchar(255) NOT NULL COMMENT '项目唯一标识码',
  72. PRIMARY KEY (`id`),
  73. UNIQUE KEY `token` (`token`)
  74. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  75. -- ----------------------------
  76. -- Table structure for user
  77. -- ----------------------------
  78. DROP TABLE IF EXISTS `user`;
  79. CREATE TABLE `user` (
  80. `id` int(11) NOT NULL AUTO_INCREMENT,
  81. `username` varchar(255) NOT NULL,
  82. `password` varchar(255) NOT NULL,
  83. PRIMARY KEY (`id`)
  84. ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;

user表

project 表

interface_group表

interface表 

 

interface_detail表

 项目准备工作

项目架构

项目依赖

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>2.3.9.RELEASE</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>cn.itcast.demo</groupId>
  12. <artifactId>hotel-demo</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>hotel-demo</name>
  15. <description>Demo project for Spring Boot</description>
  16. <properties>
  17. <java.version>1.8</java.version>
  18. <elasticsearch.version>7.12.1</elasticsearch.version>
  19. </properties>
  20. <dependencies>
  21. <dependency>
  22. <groupId>org.elasticsearch.client</groupId>
  23. <artifactId>elasticsearch-rest-high-level-client</artifactId>
  24. </dependency>
  25. <dependency>
  26. <groupId>org.springframework.boot</groupId>
  27. <artifactId>spring-boot-starter-web</artifactId>
  28. </dependency>
  29. <dependency>
  30. <groupId>com.baomidou</groupId>
  31. <artifactId>mybatis-plus-boot-starter</artifactId>
  32. <version>3.4.2</version>
  33. </dependency>
  34. <dependency>
  35. <groupId>mysql</groupId>
  36. <artifactId>mysql-connector-java</artifactId>
  37. <scope>runtime</scope>
  38. </dependency>
  39. <dependency>
  40. <groupId>org.projectlombok</groupId>
  41. <artifactId>lombok</artifactId>
  42. <optional>true</optional>
  43. </dependency>
  44. <dependency>
  45. <groupId>org.springframework.boot</groupId>
  46. <artifactId>spring-boot-starter-test</artifactId>
  47. <scope>test</scope>
  48. <exclusions>
  49. <exclusion>
  50. <groupId>org.junit.vintage</groupId>
  51. <artifactId>junit-vintage-engine</artifactId>
  52. </exclusion>
  53. </exclusions>
  54. </dependency>
  55. <!--FastJson-->
  56. <dependency>
  57. <groupId>com.alibaba</groupId>
  58. <artifactId>fastjson</artifactId>
  59. <version>1.2.71</version>
  60. </dependency>
  61. <dependency>
  62. <groupId>org.apache.commons</groupId>
  63. <artifactId>commons-lang3</artifactId>
  64. </dependency>
  65. <dependency>
  66. <groupId>org.springframework.boot</groupId>
  67. <artifactId>spring-boot-starter-amqp</artifactId>
  68. </dependency>
  69. </dependencies>
  70. <build>
  71. <plugins>
  72. <plugin>
  73. <groupId>org.springframework.boot</groupId>
  74. <artifactId>spring-boot-maven-plugin</artifactId>
  75. <version>2.3.9.RELEASE</version>
  76. <configuration>
  77. <excludes>
  78. <exclude>
  79. <groupId>org.projectlombok</groupId>
  80. <artifactId>lombok</artifactId>
  81. </exclude>
  82. </excludes>
  83. </configuration>
  84. </plugin>
  85. </plugins>
  86. </build>
  87. </project>

 实体类准备

 User:

  1. /**
  2. * 用户
  3. */
  4. @Data
  5. public class User {
  6. private Integer id;//用户id
  7. private String username;//用户账号
  8. private String password;//用户密码
  9. }

Project:

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

InterfaceGroup  

  1. /**
  2. * 接口分组
  3. */
  4. @Data
  5. public class InterfaceGroup {
  6. private Integer id;//接口组id
  7. private String name;//接口分组名称
  8. private String describe;//接口分钟描述
  9. private Integer projectId;//所属项目id
  10. }

 MyInterface 

  1. /**
  2. * 接口
  3. */
  4. @Data
  5. public class MyInterface {
  6. private Integer id;//接口id
  7. private String name;//接口名称
  8. private String type;//请求类型
  9. private String path;//接口路径
  10. private Integer status;//接口完成状态 1:完成 0 :未完成
  11. private Integer groupId;//接口所属组别id
  12. }

 InterfaceDetail 

  1. **
  2. * 接口详细id
  3. */
  4. @Data
  5. public class InterfaceDetail {
  6. private Integer id;//接口详细id
  7. private String describe;//描述
  8. private String heads;//请求头参数,实际为json字符串,储存list<interfaceParm>
  9. private String body;//请求体参数,实际为json字符串
  10. private String query;//请求路径参数,实际为json字符串
  11. private String returnValue;//返回数据格式,实际为json字符串
  12. private LocalDateTime createTime;//接口创建时间
  13. private LocalDateTime updateTime;//接口更新时间
  14. private Integer createId;//接口创建人id
  15. private Integer updateId;//接口跟新人id
  16. private Integer integerId;//所属接口id
  17. }

 interfaceParam 

  1. /**
  2. * 请求参数
  3. */
  4. public class interfaceParam {
  5. private String name;//参数名称
  6. private String type;//参数类型
  7. private String status;//是否为必须参数 1:必须 0:非必须
  8. private String description;//参数描述
  9. }

枚举类准备 

RequestType 

  1. /**
  2. * 请求类型
  3. */
  4. public enum RequestType {
  5. POST,
  6. GET,
  7. DELETE,
  8. PUT,
  9. }

 ParamType 

  1. /**
  2. * 请求参数类型
  3. */
  4. public enum ParamType {
  5. STRING,
  6. NUMBER,
  7. ARRAY,
  8. OBJECT,
  9. INTEGER,
  10. BOOLEAN
  11. }

 

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号