API implementation system and method for adding, deleting, modifying and querying a single table in a database based on BS architecture
Patent Information
- Application Number
- CN202210575414.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-25
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-05-25
AI Technical Summary
[0004]本发明解决的技术问题是:克服了现有架构中同类接口研发周期长,维护困难的缺点,提供了基于BS架构的数据库API在线开发系统,通过在Java的servlet框架中,可以自定义Filter拦截器对http请求进行拦截,获取当前请求的路径,在这里可以与自定义的API路径进行匹配,然后将其对应的SQL脚本进行解析处理,再通过JDBC技术执行SQL语句,实现了与数据库的交互
[0033] 1. Dynamically define data interfaces: Developers can define standard restful API interfaces graphically and put them into use in the system without writing any background code;
Smart Images

Figure CN115033567B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software development, and in particular to a database API online development system and method based on a BS architecture. Background Art
[0002] In the software development process of BS architecture, the workload of back-end data interface development is huge. For data interfaces that have no special business requirements and only operate a single table in the database, they also have to go through a complex development process. For example, using JAVA language to develop interfaces based on the Springboot framework requires four steps: defining entity classes, writing SQL statements, writing services, and defining APIs. For single-table data operations, the core part is just writing SQL statements for adding, deleting, modifying, and checking. The other code writing is just some conventions of the framework, which increases the workload and has no practical significance. Moreover, in the later operation and maintenance process, once there is a change in the data structure, it is necessary to re-enter the development process before going online. Not only is the cycle long, but online service deployment also has certain risks.
[0003] Currently, interface development is all done in a customized coding manner, which requires compilation, packaging, deployment, testing and other processes before it can be put online. For operations on a single table in the database, there is no special business logic, and even a very small change requires a relatively long development cycle. This is not only inefficient, but also increases the cost of operation and maintenance. Therefore, developing a function that can maintain interfaces online, write scripts, and publish in real time can solve the above defects. Summary of the invention
[0004] The technical problem solved by the present invention is: it overcomes the shortcomings of long R&D cycle and difficult maintenance of similar interfaces in the existing architecture, and provides a database API online development system based on the BS architecture. In the Java servlet framework, a custom Filter interceptor can be used to intercept http requests and obtain the path of the current request, where it can be matched with the custom API path, and then the corresponding SQL script is parsed and processed, and then the SQL statement is executed through the JDBC technology to realize interaction with the database.
[0005] The objective of the present invention is achieved through the following technical solutions:
[0006] The database API online development system based on BS architecture is characterized by including:
[0007] Backend interception module: intercepts the path of custom API and searches for the configured database name and SQL statement through the path;
[0008] Database connection module: displays the databases available for connection and implements dynamic connection with the database;
[0009] Database API information definition module; add, delete, modify and query API information, and store data persistently through the database;
[0010] SQL script editing module: edit SQL scripts, customize SQL parameters and variables;
[0011] SQL script test module: combines the written SQL statement with the test parameter information, parses and executes it through the server, and verifies the correctness of the SQL statement;
[0012] SQL parsing module: parses and splices custom functions and dynamic parameters in SQL statements to prevent SQL injection attacks;
[0013] Release module: Store a copy of the current API data and modify the status mark in the API information to "release" to ensure that the data modification does not affect the use of the released interface;
[0014] Database interaction module: interacts with the database through the parsed SQL statements and returns the results of the operation;
[0015] Front-end graphical module: Provides developers with a configurable development interface in a graphical manner;
[0016] The client dynamically creates an API module: develop an API interface on the client and define API information.
[0017] Specifically, it is characterized in that the background interception module is implemented using the servlet filter interception technology.
[0018] Specifically, it is characterized in that the database connection module is implemented using mybatis technology.
[0019] Specifically, it is characterized in that the database interaction module enables SQL statements to interact with the database through mybatis technology.
[0020] Specifically, it is characterized in that the front-end graphical module is developed using the vue.js framework.
[0021] Specifically, it is characterized by: also including a custom function module: built-in custom functions, the custom functions include obtaining server time, generating a unique ID, obtaining the current operating user, etc.
[0022] Specifically, it is characterized in that: the API information includes API primary key, API URI, API request method, SQL script, database name, test parameters, API status, release time and deletion flag; the API is a standard restful API; the API request methods include GET, PUT, POST and DELETE.
[0023] The database API online development method based on the BS architecture is implemented by using the database API online development system based on the BS architecture, and is characterized by comprising the following steps:
[0024] Step 1: Define the API path;
[0025] Step 2: Select the API request method;
[0026] Step 3: Select the database;
[0027] Step 4: Write SQL scripts and customize parameter variables;
[0028] Step 5: Test the SQL script;
[0029] Step 6: Publish.
[0030] Specifically, it is characterized by: further comprising a custom function step: a built-in custom function, wherein the custom function includes obtaining server time, generating a unique ID, and obtaining the user of the current operation.
[0031] Specifically, the feature is that: it also includes the step of dynamically creating an API on the client side: developing an API interface on the client side and defining API information.
[0032] Beneficial effects of the present invention:
[0033] 1. Dynamically define data interface: Developers can use graphical methods to define standard RESTful API interfaces and put them into use in the system without writing any background code;
[0034] 2. Dynamic execution of SQL scripts: supports standard SQL statement input and custom parameter variables, which can be dynamically passed in when calling the interface. The background automatically parses variables and processes system functions to prevent SQL injection;
[0035] 3. Improve staff utilization: With the graphical development method, even developers who are not familiar with the data backend language can easily start developing data interfaces as long as they can write SQL statements. During the development process, the work of team members can be reasonably allocated, and the work content will not be unsaturated due to technical problems. It can make the best use of people and things, greatly reducing the cost of employment;
[0036] 4. Reduce operation and maintenance costs: The SQL executed inside the interface is dynamically defined. When there is a change in demand, you only need to modify it online and republish it to take effect. There is no need to redevelop and deploy it, which saves time and does not affect the normal use of the online system. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.
[0038] Figure 1 is a flow chart of the present invention;
[0039] Figure 2 It is a diagram of the API information data structure of the present invention. DETAILED DESCRIPTION
[0040] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0041] In order to have a clearer understanding of the technical features, purposes and beneficial effects of the present invention, the technical solution of the present invention is now described in detail below. Obviously, the implementation cases described are part of the embodiments of the present invention, not all of the embodiments, and cannot be understood as limiting the scope of the implementation of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the protection scope of the present invention.
[0042] Embodiment 1:
[0043] In this embodiment, the database API online development system based on the BS architecture is characterized by including:
[0044] Backend interception module: intercepts the path of custom API and searches for the configured database name and SQL statement through the path;
[0045] Database connection module: displays the databases available for connection and implements dynamic connection with the database;
[0046] Database API information definition module; add, delete, modify and query API information, and store data persistently through the database;
[0047] SQL script editing module: edit SQL scripts, customize SQL parameters and variables;
[0048] SQL script test module: combines the written SQL statement with the test parameter information, parses and executes it through the server, and verifies the correctness of the SQL statement;
[0049] SQL parsing module: parses and splices custom functions and dynamic parameters in SQL statements to prevent SQL injection attacks;
[0050] Release module: Store a copy of the current API data and modify the status mark in the API information to "release" to ensure that the data modification does not affect the use of the released interface;
[0051] Database interaction module: interacts with the database through the parsed SQL statements and returns the results of the operation;
[0052] Front-end graphical module: Provides developers with a configurable development interface in a graphical manner;
[0053] The client dynamically creates an API module: develop an API interface on the client and define API information.
[0054] Specifically, it is characterized in that the background interception module is implemented using the servlet filter interception technology.
[0055] Specifically, it is characterized in that the database connection module is implemented using mybatis technology.
[0056] Specifically, it is characterized in that the database interaction module enables SQL statements to interact with the database through mybatis technology.
[0057] Specifically, it is characterized in that the front-end graphical module is developed using the vue.js framework.
[0058] Specifically, it is characterized by: also including a custom function module: built-in custom functions, the custom functions include obtaining server time, generating a unique ID, obtaining the current operating user, etc.
[0059] Specifically, it is characterized in that: Figure 2 As shown, the API information includes API primary key, API URI, API request method, SQL script, database name, test parameters, API status, release time and deletion flag; the API is a standard restful API; the API request methods include GET, PUT, POST and DELETE.
[0060] like Figure 1As shown, the database API online development method based on the BS architecture is implemented by using the database API online development system based on the BS architecture, and is characterized by comprising the following steps:
[0061] Step 1: Define the API path;
[0062] Step 2: Select the API request method;
[0063] Step 3: Select the database;
[0064] Step 4: Write SQL scripts and customize parameter variables;
[0065] Step 5: Test the SQL script;
[0066] Step 6: Publish.
[0067] Specifically, it is characterized by: further comprising a custom function step: a built-in custom function, wherein the custom function includes obtaining server time, generating a unique ID, and obtaining the user of the current operation.
[0068] Specifically, the feature is that: it also includes the step of dynamically creating an API on the client side: developing an API interface on the client side and defining API information.
[0069] The above shows and describes the basic principles, main features and advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited by the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of the present invention to be protected is defined by the attached claims and their equivalents.
[0070] It should be noted that, for the above-mentioned various method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and units involved are not necessarily required by this application.
[0071] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0072] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a ROM, a RAM, etc.
[0073] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.
Claims
1. Database API online development system based on BS architecture, characterized by: include: Backend interception module: intercepts the path of custom API and searches for the configured database name and SQL statement through the path; Database connection module: displays the databases available for connection and implements dynamic connection with the database; Database API information definition module; add, delete, modify and query API information, and store data persistently through the database; SQL script editing module: edit SQL scripts, customize SQL parameters and variables; SQL script test module: combines the written SQL statement with the test parameter information, parses and executes it through the server, and verifies the correctness of the SQL statement; SQL parsing module: parses and splices custom functions and dynamic parameters in SQL statements to prevent SQL injection attacks; Release module: Store a copy of the current API data and modify the status mark in the API information to "release" to ensure that the data modification does not affect the use of the released interface; Database interaction module: interacts with the database through the parsed SQL statements and returns the results of the operation; Front-end graphical module: Provides developers with a configurable development interface in a graphical manner; The client dynamically creates an API module: develop an API interface on the client and define API information.
2. According to the BS architecture-based database API online development system of claim 1, it is characterized in that: The background interception module is implemented using servlet filter interception technology.
3. According to the BS architecture-based database API online development system of claim 1, it is characterized in that: The database connection module is implemented using mybatis technology.
4. The database API online development system based on BS architecture according to claim 1 is characterized in that: The database interaction module enables SQL statements to interact with the database through mybatis technology.
5. The database API online development system based on BS architecture according to claim 1 is characterized in that: The front-end graphical module is developed using the vue.js framework.
6. The database API online development system based on BS architecture according to claim 1 is characterized by: It also includes a custom function module: built-in custom functions, including obtaining server time, generating a unique ID, obtaining the user of the current operation, etc.
7. The database API online development system based on BS architecture according to claim 1 is characterized by: The API information includes API primary key, API URI, API request method, SQL script, database name, test parameters, API status, release time and deletion mark; the API is a standard restful API; the API request methods include GET, PUT, POST and DELETE.
8. A database API online development method based on BS architecture, implemented by using a database API online development system based on BS architecture as described in any one of claims 1 to 7, characterized in that: The following steps are involved: Step 1: Define the API path; Step 2: Select the API request method; Step 3: Select the database; Step 4: Write SQL scripts and customize parameter variables; Step 5: Test the SQL script; Step 6: Publish.
9. The method for online development of database API based on BS architecture according to claim 8, characterized in that: It also includes a custom function step: a built-in custom function, wherein the custom function includes obtaining server time, generating a unique ID, and obtaining the user of the current operation.
10. The method for online development of database API based on BS architecture according to claim 8, characterized in that: It also includes the steps of dynamically creating an API on the client side: developing an API interface on the client side and defining API information.
Citation Information
Patent Citations
Method and system for quickly developing projects by arranging API
CN107015804A
Data processing method and device for user-defined API (Application Program Interface)
CN114510222A
Server-side framework device for development of web service application, method for executing web service application developmed using the same and computer program for the same
KR101865343B1
Automatically executing graphql queries on databases
US20210248143A1
