CN114461955A - Method for automatically generating http interface based on web page configuration - Google Patents

Method for automatically generating http interface based on web page configuration Download PDF

Info

Publication number
CN114461955A
CN114461955A CN202111544849.1A CN202111544849A CN114461955A CN 114461955 A CN114461955 A CN 114461955A CN 202111544849 A CN202111544849 A CN 202111544849A CN 114461955 A CN114461955 A CN 114461955A
Authority
CN
China
Prior art keywords
interface
url
data
client
web page
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111544849.1A
Other languages
Chinese (zh)
Inventor
郭志强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangxi Mammoth Energy Co ltd
Original Assignee
Jiangxi Mammoth Energy Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jiangxi Mammoth Energy Co ltd filed Critical Jiangxi Mammoth Energy Co ltd
Priority to CN202111544849.1A priority Critical patent/CN114461955A/en
Publication of CN114461955A publication Critical patent/CN114461955A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9577Optimising the visualization of content, e.g. distillation of HTML documents

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention is suitable for the field of computers, and provides a method for automatically generating an http interface based on web page configuration, which comprises the following steps: configuring a data interface url and access parameters for a pre-constructed metadata system; introducing an interface document according to the configured data interface url and the access parameter; processing and converting the introduced interface document data; setting a url monitoring path, and acquiring a specific url accessed by a client; matching the interface configuration of a specific url; executing the sql statement, and finishing data processing in the processed and converted interface document data; the data processing result is returned to the client, and the method has the advantages that: the efficiency of generating the data interface can be improved and the monitoring of a plurality of client interfaces can be realized.

Description

Method for automatically generating http interface based on web page configuration
Technical Field
The invention belongs to the technical field of computers, and particularly relates to a method for automatically generating an http interface based on web page configuration.
Background
The ground code development is a popular mode in the industry at present, and is mainly characterized in that the investment in code development is reduced, so that the program function is more concentrated in a business scene, and the ground code application scene is wide in the future.
Most application scenes of the existing interface service are that corresponding sql statements are returned to a fixed data format according to a configured api path.
If there is a business logic process (e.g. which data table to query according to the state in some kind of cache), or the data format is changed, it becomes very difficult or not supported at all, and most of the slightly complicated business logic processes require extra development workload, and may not accelerate the development speed of the interface.
Disclosure of Invention
An embodiment of the present invention provides a method for automatically generating an http interface based on web page configuration, which is intended to solve the problems in the background art.
The embodiment of the invention is realized in such a way that, on one hand, a method for automatically generating an http interface based on web page configuration comprises the following steps:
configuring a data interface url and access parameters for a pre-constructed metadata system;
introducing an interface document according to the configured data interface url and the access parameter;
processing and converting the introduced interface document data;
setting a url monitoring path, and acquiring a specific url accessed by a client;
matching the interface configuration of a specific url;
executing the sql statement, and finishing data processing in the processed and converted interface document data;
and returning the data processing result to the client.
As a further aspect of the present invention, the configuring a data interface url and the accessing parameters for the pre-constructed metadata system specifically include:
constructing a metadata system through java development language;
setting a pre-groovy code;
setting an sql statement and a placeholder;
post-setting groovy code is set.
As a further aspect of the present invention, the import interface document specifically includes:
acquiring original url import data;
matching original url import data with existing access parameters;
if the matching is successful, introducing the interface document into the system according to the original url introduction data;
and if the matching fails, copying and pasting the interface document content into a rich text editing box in the system.
As a further aspect of the present invention, the processing and converting the imported interface document data specifically includes:
with pre-and post-groovy code, the runtime makes use of hot-loading techniques so that the user-configured execution code can be executed immediately after submission without restarting the service and publishing it.
As a further scheme of the present invention, the setting a url listening path, and the obtaining a specific url accessed by a client specifically includes:
and setting a url monitoring path as/api/, acquiring the servlet, matching all access requests starting with the api/through the api/, and acquiring the specific url accessed by the client through the servlet.
As a further aspect of the present invention, the method further comprises:
mapping between url and actual execution code and sql according to the configuration;
and finding the sql and groovy codes which need to be executed through mapping according to the specific url accessed by the client.
As a further aspect of the present invention, the interface configuration matching the specific url specifically includes:
acquiring a configuration file, wherein the configuration file comprises a placeholder of an sql statement and a parameter;
and matching the interface configuration according to the configuration file and the specific url of the client.
As a further scheme of the present invention, the executing the sql statement specifically includes:
splicing complete sql according to the configured sql statement and the placeholder of the parameter;
and transmitting the complete sql into a database for execution, wherein the database is a collection of processed and converted interface document data.
As a further aspect of the present invention, the returning the data processing result to the client specifically includes:
processing a processing result returned by the complete sql through a goovy code;
and feeding back a return value obtained by processing the goovy code to the client.
The method for automatically generating the http interface based on the web page configuration, provided by the embodiment of the invention, introduces an interface document according to the configured data interface url and the access parameter, processes and converts the introduced interface document data, sets the url monitoring path, acquires the specific url accessed by the client, matches the interface configuration of the specific url, executes the sql statement, completes data processing in the processed and converted interface document data, and returns the data processing result to the client, and particularly can splice a complete sql according to the placeholder of the configured sql statement and the parameter and transmit the sql into the database for execution, so that the function to be realized by one access request is processed after the data is changed, the efficiency of generating the data interface is improved, the processing result returned by the sql statement is flexibly processed into a meaningful return value format required by the interface protocol through the goovy code, tells the client that the access request has been processed.
Drawings
Fig. 1 is a main flow diagram of a method of automatically generating an http interface based on a web page configuration.
FIG. 2 is a workflow diagram of an implementation of a method for automatically generating an http interface based on a web page configuration.
FIG. 3 is a flow chart of an incoming interface document in a method for automatically generating an http interface based on a web page configuration.
FIG. 4 is a flow chart of an interface configuration matching a particular url in a method for automatically generating an http interface based on web page configuration.
FIG. 5 is a flow diagram of the execution of an sql statement in a method for automatically generating an http interface based on web page configuration.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Specific implementations of the present invention are described in detail below with reference to specific embodiments.
The method for automatically generating the http interface based on the web page configuration solves the technical problem in the background technology.
As shown in fig. 1 and fig. 2, a main flow chart and a workflow chart of a method for automatically generating an http interface based on a web page configuration according to an embodiment of the present invention are provided, where the method for automatically generating an http interface based on a web page configuration includes:
step S10: configuring a data interface url and access parameters for a pre-constructed metadata system;
step S11: introducing an interface document according to the configured data interface url and the access parameter;
step S12: processing and converting the introduced interface document data;
step S13: setting a url monitoring path, and acquiring a specific url accessed by a client; and
step S14: matching the interface configuration of a specific url;
step S15: executing the sql statement, and finishing data processing in the processed and converted interface document data;
step S16: and returning the data processing result to the client.
When the method is applied, according to the data format, structure and sql statement of the configuration definition, the database is added, deleted, changed and checked to form an accessible http interface, and the service functions such as data query and storage can be completed through the interface.
As a preferred embodiment of the present invention, the configuring a data interface url and accessing parameters for a pre-constructed metadata system specifically includes:
step S101: constructing a metadata system through java development language;
step S102: setting a pre-groovy code;
step S103: setting an sql statement and a placeholder;
step S104: post-setting groovy code is set.
In the embodiment, when the method is applied, by specifying url as a url when the specified interface is accessed, which is usually a rest style such as,/urser/detail/, and specifying parameter as a parameter format that the specified interface is accessed, which is JSON format such as { "userld": U1234"," username ": three by three } is accessed, according to the interface and the input parameter, a proper database and table are accessed, SQL statements are executed, and well-specified business logic is processed, so that the corresponding function is completed. For example, the configured sql is select from user where userId # { userId } and username # { username }; assuming that the incoming parameters are { "userId": U1234"," username ": three in a piece } that the actually executed sql is selected from user where userId ═ U1234' and username { ' three in a piece of paper '; the visitor to the interface thus obtains the desired user details. The actual processing logic inside the program replaces # { userId } with "U1234" and # { username } with "zhang three" so that sql only needs to configure one, but can execute all users' query requests.
As shown in fig. 3, as a preferred embodiment of the present invention, the import interface document specifically includes:
step S111: acquiring original url import data;
step S112: matching original url import data with existing access parameters;
step S113: if the matching is successful, introducing the interface document into the system according to the original url introduction data;
step S114: and if the matching fails, copying and pasting the interface document content into a rich text editing box in the system.
As a preferred embodiment of the present invention, the processing and converting the imported interface document data specifically includes:
step S121: with pre-and post-groovy code, the runtime makes use of hot-loading techniques so that the user-configured execution code can be executed immediately after submission without restarting the service and publishing it.
In application, the execution code configured by the user can be executed immediately after submission by using the groovy code runtime hot loading technology without restarting service and publishing. E.g., String userName ═ user.
Integer age=user.getAge();
String fullName=userName+age;
user.setFullName(fullName);
return user;
This code completes the function of combining the user name and age, and accessing this interface can obtain the attributes of the user fullName in addition to the user information.
As a preferred embodiment of the present invention, the setting a url listening path, and the obtaining a specific url accessed by a client specifically includes:
step S131: and setting a url monitoring path as/api/, acquiring the servlet, matching all access requests starting with the api/through the api/, and acquiring the specific url accessed by the client through the servlet.
As a preferred embodiment of the present invention, the method further comprises:
step S20: mapping between url and actual execution code and sql according to the configuration;
step S21: and finding the sql and groovy codes which need to be executed through mapping according to the specific url accessed by the client.
In the embodiment, when the method is applied, interfaces meeting expression conditions can be monitored through Java, for example, api/. can monitor all access requests beginning with api/such as api/a1 api/a2, the background only needs to map url, actual execution codes and sql according to configuration, finds sql and groovy codes to be executed according to url accessed by the front end through mapping, and returns results after execution, so that the purpose of monitoring a plurality of interfaces through configuration is achieved.
As shown in fig. 4, as a preferred embodiment of the present invention, the interface configuration matching a specific url specifically includes:
step S141: acquiring a configuration file, wherein the configuration file comprises a placeholder of an sql statement and a parameter;
step S142: and matching the interface configuration according to the configuration file and the specific url of the client.
When the method is applied, according to interface configuration, a corresponding groovy code is executed, a parameter format is processed, and execution of an sql statement is determined.
As shown in fig. 5, as a preferred embodiment of the present invention, the executing the sql statement specifically includes:
step S151: splicing complete sql according to the configured sql statement and the placeholder of the parameter;
step S152: and transmitting the complete sql into a database for execution, wherein the database is a collection of processed and converted interface document data, and the function to be realized by one access request is processed after the data is changed.
As a preferred embodiment of the present invention, the returning the data processing result to the client specifically includes:
step S161: processing a processing result returned by the complete sql through a goovy code;
step S162: and feeding back a return value obtained by processing the goovy code to the client.
When the method is applied, the returned data format is processed according to the returned value of the sql statement and the configuration file. The purpose is as follows: and flexibly processing a processing result returned by the sql statement into a meaningful return value format required by the interface protocol through a goovy code, and informing the client that the access request is processed and completed.
The embodiment of the invention provides a method for automatically generating an http interface based on web page configuration, which comprises the steps of configuring a data interface url and access parameters for a pre-constructed metadata system, introducing an interface document according to the configured data interface url and the access parameters, processing and converting the introduced interface document data, setting a url monitoring path, acquiring a specific url accessed by a client, matching the interface configuration of the specific url, executing an sql statement, completing data processing in the processed and converted interface document data, returning a data processing result to the client, splicing a complete sql according to a placeholder of the configured sql statement and parameters, transmitting the spliced sql into a database for execution, processing a function to be realized by an access request after data is changed, flexibly processing a processing result returned by the sql statement into a meaningful return value format required by an interface protocol through a goovy code, tells the client that the access request has been processed.
In order to load the above method and system to operate successfully, the system may include more or less components than those described above, or combine some components, or different components, in addition to the various modules described above, for example, input/output devices, network access devices, buses, processors, memories, and the like.
The processor may be a Central Processing Unit (CPU), other general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like that is the control center for the system and that connects the various components using various interfaces and lines.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (9)

1. A method for automatically generating an http interface based on web page configuration, the method comprising:
configuring a data interface url and access parameters for a pre-constructed metadata system;
introducing an interface document according to the configured data interface url and the access parameter;
processing and converting the introduced interface document data;
setting a url monitoring path, and acquiring a specific url accessed by a client;
matching the interface configuration of a specific url;
executing the sql statement, and finishing data processing in the processed and converted interface document data;
and returning the data processing result to the client.
2. The method for automatically generating an http interface based on web page configuration according to claim 1, wherein the configuring a data interface url and access parameters for a pre-constructed metadata system specifically includes:
constructing a metadata system through java development language;
setting a pre-groovy code;
setting an sql statement and a placeholder;
post-setting groovy code is set.
3. The method for automatically generating an http interface based on web page configuration according to claim 1, wherein the incoming interface document specifically includes:
acquiring original url import data;
matching original url import data with existing access parameters;
if the matching is successful, introducing the interface document into the system according to the original url introduction data;
and if the matching fails, copying and pasting the interface document content into a rich text editing box in the system.
4. The method for automatically generating an http interface based on web page configuration according to claim 2, wherein the processing and converting the imported interface document data specifically includes:
with pre-and post-groovy code, the runtime makes use of hot-loading techniques so that the user-configured execution code can be executed immediately after submission without restarting the service and publishing it.
5. The method for automatically generating an http interface based on web page configuration according to claim 1, wherein the setting a url listening path and the obtaining a specific url accessed by a client specifically includes:
and setting a url monitoring path as/api/, acquiring the servlet, matching all access requests starting with the api/through the api/, and acquiring the specific url accessed by the client through the servlet.
6. The method for automatically generating an http interface based on a web page configuration of claim 1, further comprising:
mapping between url and actual execution code and sql according to the configuration;
and finding the sql and groovy codes which need to be executed through mapping according to the specific url accessed by the client.
7. The method for automatically generating an http interface based on web page configuration according to any one of claims 1 to 3, wherein the matching of the interface configuration of the specific url specifically includes:
acquiring a configuration file, wherein the configuration file comprises a placeholder of an sql statement and a parameter;
and matching the interface configuration according to the configuration file and the specific url of the client.
8. The method for automatically generating an http interface based on web page configuration of claim 7, wherein the executing the sql statement specifically includes:
splicing complete sql according to the configured sql statement and the placeholder of the parameter;
and transmitting the complete sql into a database for execution, wherein the database is a collection of processed and converted interface document data.
9. The method for automatically generating an http interface based on web page configuration of claim 8, wherein the returning of the data processing result to the client specifically comprises:
processing a processing result returned by the complete sql through a goovy code;
and feeding back a return value obtained by processing the goovy code to the client.
CN202111544849.1A 2021-12-16 2021-12-16 Method for automatically generating http interface based on web page configuration Pending CN114461955A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111544849.1A CN114461955A (en) 2021-12-16 2021-12-16 Method for automatically generating http interface based on web page configuration

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111544849.1A CN114461955A (en) 2021-12-16 2021-12-16 Method for automatically generating http interface based on web page configuration

Publications (1)

Publication Number Publication Date
CN114461955A true CN114461955A (en) 2022-05-10

Family

ID=81405663

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111544849.1A Pending CN114461955A (en) 2021-12-16 2021-12-16 Method for automatically generating http interface based on web page configuration

Country Status (1)

Country Link
CN (1) CN114461955A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115146187A (en) * 2022-09-01 2022-10-04 闪捷信息科技有限公司 Interface information processing method, storage medium, and electronic device
CN115906187A (en) * 2023-02-22 2023-04-04 山东经伟晟睿数据技术有限公司 User authority control method and system combining function authority and interface authority
CN115951882A (en) * 2023-02-16 2023-04-11 中孚安全技术有限公司 Third-party interface format conversion platform and method based on vue

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115146187A (en) * 2022-09-01 2022-10-04 闪捷信息科技有限公司 Interface information processing method, storage medium, and electronic device
CN115951882A (en) * 2023-02-16 2023-04-11 中孚安全技术有限公司 Third-party interface format conversion platform and method based on vue
CN115951882B (en) * 2023-02-16 2023-06-20 中孚安全技术有限公司 Third-party interface format conversion platform and method based on vue
CN115906187A (en) * 2023-02-22 2023-04-04 山东经伟晟睿数据技术有限公司 User authority control method and system combining function authority and interface authority

Similar Documents

Publication Publication Date Title
CN114461955A (en) Method for automatically generating http interface based on web page configuration
US10812566B2 (en) Distributed steam processing
US10114682B2 (en) Method and system for operating a data center by reducing an amount of data to be processed
EP3761172A1 (en) Deep learning task scheduling method and system and related apparatus
US10534695B2 (en) Systems and methods for initializing test environments
WO2017156916A1 (en) Data access method and device
US20110238859A1 (en) Information processing apparatus and document data producing method
US10747586B2 (en) Remote communication and remote programming by application programming interface
CN110727417B (en) Data processing method and device
WO2019161620A1 (en) Application dependency update method, terminal and device, and storage medium
CN111008254B (en) Object creation method, device, computer equipment and storage medium
US11762687B2 (en) Processing of messages and documents carrying business transactions
CN116737127A (en) Low code development method, device, equipment and storage medium
CN113051102A (en) File backup method, device, system, storage medium and computer equipment
US20140344832A1 (en) Automated framework for tracking and maintaining kernel symbol list types
CN103914479A (en) Resource request matching method and device
WO2018000864A1 (en) Method for router supporting rss feed task download and router
CN112883088A (en) Data processing method, device, equipment and storage medium
KR102023999B1 (en) Method and apparatus for generating web pages
CN113746932B (en) Network request merging method, device, electronic device and computer program product
CN112487218B (en) Content processing method, system, device, computing equipment and storage medium
CN115114321A (en) Dynamic query method and system
CN113742385A (en) Data query method and device
CN114461595A (en) Method, device, medium and electronic equipment for sending message
CN112835573A (en) Data query method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination