Data interface generation method and device, equipment and medium
By obtaining and fusion of description information of the data resource table to generate data interface files, the problem of low data interface generation efficiency in the prior art is solved, and the automated generation and efficiency improvement of data interfaces are realized.
Patent Information
- Application Number
- CN202410997910.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2044-07-24
AI Technical Summary
In the prior art, the efficiency of developing data interfaces through manual customization is low, and it is difficult to meet the need for increasing data volume during data communication.
By obtaining the data interface of the request, querying the data cataloging information of the target data type, obtaining the description information of the data resource table, and fusing this information to generate the cataloging data table of the target data type, and finally generating the data interface file based on the cataloging data table. Implement automatic generation of data interfaces.
It improves the efficiency of data interface generation, avoids the tedious process of artificial customization, and realizes the automatic generation of data interface files.
Smart Images

Figure CN118939659A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data interface generation method, device, equipment and medium. Background Art
[0002] With the rapid development of information technology, electronic devices have appeared in all aspects of people's lives. Data sharing can be achieved through data communication between electronic devices.
[0003] In the related art, a data interface can be manually customized and developed, and then data communication can be realized through the customized data interface to realize data sharing and interaction functions. However, as the amount of data transmitted during data communication continues to increase, the efficiency of manually customizing and developing data interfaces is low, time-consuming and labor-intensive. Summary of the invention
[0004] Based on this, it is necessary to provide a data interface generation method, device, equipment and medium that can improve the efficiency of data interface generation in response to the above technical problems.
[0005] In a first aspect, the present application provides a data interface generation method, comprising:
[0006] Obtaining a data interface generation request sent by a requesting end, wherein the data interface generation request includes a target data type requested by the requesting end;
[0007] Query at least one data catalog information corresponding to the target data type, where the data catalog information is used to indicate a data resource adapted by the target data type;
[0008] Obtaining description information of a data resource table corresponding to the at least one data cataloging information;
[0009] According to the description information of each data table, the data tables are merged to obtain a catalog data table corresponding to the target data type;
[0010] A data interface file corresponding to the target data type is generated according to the cataloged data table.
[0011] In one embodiment, generating a data interface file corresponding to the target data type according to the cataloged data table includes:
[0012] Adding the field names in the catalog data table to the configuration information corresponding to the target data type;
[0013] Obtain a preset general statement template, wherein the general statement template includes an input parameter position and an output parameter position;
[0014] According to the configuration information, the fields in the catalog data table are filled into the input parameter position and the output parameter position using a general interface code file to generate a data interface file.
[0015] In one embodiment, the merging of the data tables according to the description information of the data tables to obtain the catalog data table corresponding to the target data type includes:
[0016] Determine whether there is a catalog data table corresponding to the target data type according to the description information of each data table;
[0017] If not, then the data tables are merged according to the description information of the data tables to obtain a catalog data table corresponding to the target data type.
[0018] In one embodiment, the merging of the data tables according to the description information of the data tables to obtain the catalog data table corresponding to the target data type includes:
[0019] According to the description information of each data table, query the overlapping data between the data tables;
[0020] According to the overlapping data between the various data tables, the various data tables are spliced to form the cataloged data table.
[0021] In one embodiment, querying at least one data catalog information corresponding to the target data type includes:
[0022] Query the data type corresponding to the request authority of the data requester;
[0023] Compare the data type corresponding to the requested permission with the target data type to obtain a comparison result;
[0024] Verifying the request authority of the requesting end according to the comparison result;
[0025] If the request authority check of the requesting end passes, at least one data cataloging information corresponding to the target data type is queried.
[0026] In one of the embodiments, before querying at least one data catalog information corresponding to the target data type, the method further includes:
[0027] Acquire data resources of at least one business system;
[0028] Determine attribute information corresponding to the data resources of the at least one business system respectively;
[0029] Cataloging the data resources of the at least one business system according to the attribute information, generating data cataloging information of the at least one business system and at least one data table corresponding to each piece of data cataloging information;
[0030] The querying of at least one data catalog information corresponding to the target data type includes:
[0031] According to the data catalog information of the at least one business system, at least one data catalog information corresponding to the target data type is queried.
[0032] In one of the embodiments, after generating the data interface file corresponding to the target data type according to the cataloged data table, the method further includes:
[0033] Deploy the data interface file in the target container;
[0034] Running and loading the data interface file in the target container to test the code function in the data interface file;
[0035] When the code function test of the data interface file passes, the data interface file is released.
[0036] In a second aspect, the present application also provides a data interface generating device, including:
[0037] A request acquisition module, used to acquire a data interface generation request sent by a request end, wherein the data interface generation request includes a target data type requested by the request end;
[0038] An information query module, used to query at least one data catalog information corresponding to the target data type, wherein the data catalog information is used to indicate a data resource adapted to the target data type;
[0039] An information extraction module, used to obtain description information of a data resource table corresponding to the at least one data cataloging information;
[0040] A data table fusion module, used to fuse the data tables according to the description information of the data tables to obtain a catalog data table corresponding to the target data type;
[0041] The file generation module is used to generate a data interface file corresponding to the target data type according to the cataloged data table.
[0042] In one of the embodiments, the file generation module is also used to add the field names in the catalog data table to the configuration information corresponding to the target data type; obtain a preset general statement template, the general statement template including an input parameter position and an output parameter position; according to the configuration information, use a general interface code file to fill the fields in the catalog data table into the input parameter position and the output parameter position to generate a data interface file.
[0043] In one of the embodiments, the data table fusion module is also used to determine whether there is a catalog data table corresponding to the target data type based on the description information of the various data tables; if not, the various data tables are merged based on the description information of the various data tables to obtain the catalog data table corresponding to the target data type.
[0044] In one of the embodiments, the data table fusion module is further used to query the overlapping data between the data tables according to the description information of the data tables; and to splice the data tables according to the overlapping data between the data tables to form the catalog data table.
[0045] In one of the embodiments, the information query module is also used to query the data type corresponding to the request permission of the data requester; compare the data type corresponding to the request permission with the target data type to obtain a comparison result; verify the request permission of the requesting end according to the comparison result; if the request permission of the requesting end passes the verification, query at least one data cataloging information corresponding to the target data type.
[0046] In one of the embodiments, the information query module is also used to obtain data resources of at least one business system; determine the attribute information corresponding to the data resources of the at least one business system; catalog the data resources of the at least one business system according to the attribute information, generate data catalog information of the at least one business system, and at least one data table corresponding to each data catalog information; and query at least one data catalog information corresponding to the target data type according to the data catalog information of the at least one business system.
[0047] In one embodiment, the data interface generating device further includes:
[0048] A test release module is used to deploy the data interface file in a target container; run and load the data interface file in the target container to test the code function in the data interface file; and release the data interface file when the code function test of the data interface file passes.
[0049] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned data interface generation method when executing the computer program.
[0050] In a fourth aspect, the present application also provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the above-mentioned data interface generation method when executed by a processor.
[0051] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the above-mentioned data interface generation method when executed by a processor.
[0052] The above-mentioned data interface generation method, device, equipment and medium first obtain a data interface generation request sent by the requesting end, wherein the data interface generation request includes the target data type requested by the requesting end. Secondly, query at least one data cataloging information corresponding to the target data type, and the data cataloging information is used to indicate the data resources adapted by the target data type. And obtain the description information of the data resource table corresponding to the at least one data cataloging information. Thirdly, according to the description information of each data table, the various data tables are merged to obtain the cataloging data table corresponding to the target data type. Finally, according to the cataloging data table, a data interface file corresponding to the target data type is generated. Since the corresponding cataloging data table can be obtained by the target data type of different requests, and then the corresponding data interface file is generated based on the cataloging data table, there is no need to manually customize the generation of the data interface file, thereby realizing the automatic generation of the data interface file and improving the efficiency of data interface generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0054] FIG1 is an application environment diagram of a data interface generation method provided in an embodiment of the present application;
[0055] Figure 2 A flow chart of a data interface generation method provided in an embodiment of the present application;
[0056] Figure 3 A flowchart of another data interface generation method provided in an embodiment of the present application;
[0057] Figure 4A flowchart of another data interface generation method provided in an embodiment of the present application;
[0058] Figure 5 A structural block diagram of a data interface generating device provided in an embodiment of the present application;
[0059] FIG6 is a diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0061] The data interface generation method provided in the embodiment of the present application can be applied to the application environment shown in Figure 1. Among them, the request end 101 communicates with the server end 102 through the network. The data storage system can store the data that the server end 102 needs to process. The data storage system can be integrated on the server end 102, or it can be placed on the cloud or other network servers.
[0062] When it is necessary to generate a data interface, the requesting end 101 can send a data interface generation request to the server 102, and the data interface generation request includes the target data type requested by the requesting end. Secondly, the server 102 queries at least one data cataloging information corresponding to the target data type, and the data cataloging information is used to indicate the data resources adapted by the target data type, and obtains the description information of the data resource table corresponding to at least one data cataloging information. Thirdly, the server 102 merges each data table according to the description information of each data table to obtain the cataloging data table corresponding to the target data type. Finally, the server 102 generates a data interface file corresponding to the target data type based on the cataloging data table.
[0063] The request end 101 may be a server corresponding to the business system, a terminal device, or an independent platform connected to the business system. The server end 102 may be a server corresponding to the interface generation system. The terminal device may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The server may be an independent physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides cloud computing services.
[0064] It should be understood that the data interface generation method provided in the embodiment of the present application can be applied to a data interface generation device, which can be implemented in the form of hardware and / or software, and the data interface generation request device can be the server of Figure 1.
[0065] Figure 2 A flow chart of a data interface generation method provided in an embodiment of the present application is provided, and the method is applied to a server as an example for explanation. The data interface generation method includes S201-S205:
[0066] S201. Obtain a data interface generation request sent by a requesting end, where the data interface generation request includes the target data type requested by the requesting end.
[0067] The requesting end may be a server corresponding to the business system, a terminal device, or an independent platform connected to the business system, etc. When a data interface needs to be generated, the requesting end may send a data interface generation request to the server, so that the server generates a data interface file.
[0068] The data interface may be a method of interaction between software components defined by specific syntax and specifications. For example, the data interface defines input parameters, output parameters, functions, classes, and methods between software components, as well as calling methods and constraints between software components.
[0069] Exemplarily, the requesting end can generate request data and send it to the data interface according to the parameters sent by the requesting end through a preset input parameter format, call the data interface, run the program or module based on the request data, and obtain an execution result, which generates data consistent with the output parameter format and returns it to the requesting end. Correspondingly, the data interface generation request can be a command to generate the data interface that the requesting end wants to call, and the data interface generation request specifies the target data type requested by the requesting end.
[0070] It should be understood that the embodiments of the present application do not limit how the server obtains the data interface generation request sent by the requester. In some embodiments, the server can obtain the data interface generation request sent by the requester through data capture, neural networks, or data crawlers, and the embodiments of the present application do not limit this.
[0071] The target data type may be the data type of the result output by calling the data interface. For example, the target data type includes but is not limited to a representational state transfer (RESTful) type and a web service (webservice) type.
[0072] In some embodiments, after the server obtains the data interface generation request, the target data type can be extracted from the data interface generation request. Exemplarily, the server can extract the target data type from the data interface generation request by means of neural network, natural language processing or string matching, etc., which is not limited in the embodiments of the present application.
[0073] S202: Query at least one data catalog information corresponding to the target data type, where the data catalog information is used to indicate data resources adapted to the target data type.
[0074] In this step, after the server obtains the data interface generation request sent by the requester, it can query at least one data cataloging information corresponding to the target data type.
[0075] The data catalog information may be a list of data resources, including but not limited to structured data, unstructured data, reports and query results, data visualization and overview information, and the connection information between machine learning models and databases. Unstructured data may include documents, web pages, emails, social media content, or pictures and videos.
[0076] Exemplarily, data catalog information mainly records five types of metadata, which include data sets, personnel metadata, search metadata, processing metadata, and supplier metadata. Data sets are files and tables that can be accessed by institutional personnel. Data sets may be located in data lakes, data warehouses, master databases, or any other shared data resources. Personnel metadata can be a description of personnel roles related to data, including data users, regulators, and administrators. Search metadata can be tags and keywords added to data elements to facilitate data searches. Processing metadata can be a description of various data processing tasks in the data lifecycle management process, such as updating data and converting data. Supplier metadata can be information such as the source, subscription source, and license restrictions of the data. Furthermore, there is also a data lineage relationship between fields in the data set, and the data between fields can be updated and converted through structured query language (SQL).
[0077] In some embodiments, the server can query at least one data catalog information corresponding to the target data type through a query algorithm, and the query algorithm can include but is not limited to a depth-first algorithm and a breadth-first algorithm, etc., which are not limited in the embodiments of the present invention. For example, the server can query 5 data catalog information corresponding to the target data type restful through a depth-first algorithm.
[0078] In some embodiments, each data catalog information corresponds to at least one data table. Exemplarily, the data catalog information corresponds to the requested data type, the requested data type corresponds to at least one data catalog information, and one data catalog information corresponds to at least one data table.
[0079] Exemplarily, the data catalog information may be a string composed of data table names, so that the data table corresponding to each data catalog information can be obtained through a string segmentation algorithm. The string segmentation algorithm includes but is not limited to natural language processing, string matching algorithm, and neural network, etc., which are not limited in the embodiments of the present application.
[0080] Exemplarily, data cataloging information 1 is a string formed by concatenating data table names, and data cataloging information 1 is a string formed by concatenating electricity usage type, total electricity usage and electricity equipment. The data tables corresponding to data cataloging information 1 obtained through natural language processing are electricity usage type table, total electricity usage table and electricity equipment table.
[0081] In some optional embodiments, the server may also perform a permission check before querying the data catalog information. The server may query the data type corresponding to the requested permission of the data requester. Subsequently, the data type corresponding to the requested permission is compared with the target data type to obtain a comparison result, and the requested permission of the requester is verified based on the comparison result. If the requested permission of the requester passes the verification, at least one data catalog information corresponding to the target data type is queried. If the requested permission of the requester passes the verification, the query of at least one data catalog information corresponding to the target data type is stopped.
[0082] The requested permission may be an identifier that allows the requesting end to obtain the data interface file information corresponding to the target data type. The target data type may be the data type corresponding to the data interface file that the requesting end wants to obtain. The comparison result may be that the target data type is included in the data type corresponding to the requested permission, or that the target data type is not included in the data type corresponding to the requested permission.
[0083] It should be understood that the requested permission can be a permission to access data, and the requesting end can request the requested permission of the requesting end by sending an access request. For example, the requesting party can access the first row of data in the data table only if it obtains permission A; the requesting party can access the second row of data in the data table only if it obtains permission B; and any requesting party can access the third row of data in the data table without requiring permission.
[0084] Exemplarily, the data type corresponding to the request permission of the requesting end can be queried, the data type corresponding to the request permission and the target data type can be compared, and it is determined whether the data type corresponding to the request permission of the requesting end and the target data type are consistent, and a comparison result is obtained. If the data type corresponding to the request permission of the requesting end and the target data type are inconsistent, it is determined that the requesting end fails the verification, then the requesting end has no authority, and the requesting end cannot obtain the data cataloging information corresponding to the target data type. At this time, a prompt message that the authority does not meet the requirements can be returned to the requesting end. When the verification passes, at least one data cataloging information corresponding to the target data type can be queried.
[0085] For example, an employee of a power production department of an electric power system generates a data interface through a request from a requesting end, at which time the employee's identity can be authenticated. After the verification is passed, the target data type requested by the requesting end is extracted, and based on the target data type, the data cataloging information corresponding to the requested data type is queried.
[0086] In an embodiment of the present application, a comparison result is obtained by comparing the data type corresponding to the requested permission with the target data type, and the permission of the requesting party is verified based on the comparison result. When the verification passes, at least one data cataloging information corresponding to the target data type is queried. The permission of the requesting end can be verified through the verification operation to avoid misoperation problems and improve the accuracy of data interface generation.
[0087] The following describes how to generate data cataloging information.
[0088] In some embodiments, the server can obtain data resources of at least one business system and determine the attribute information corresponding to the data resources of at least one business system. Subsequently, the server can catalog the data resources of at least one business system according to the attribute information, generate data catalog information of at least one business system, and at least one data table corresponding to each data catalog information. Finally, the server can query at least one data catalog information corresponding to the target data type according to the data catalog information of at least one business system.
[0089] The data resource may be data information, and the attribute information may be information such as data type, content, and field name.
[0090] Exemplarily, the data resource may be the business system data connected to the platform. The server can catalog the data resource based on the attribute information, determine the field name, field attribute value and field to which the data belongs, etc. Subsequently, the server generates different data tables according to the different fields to which the data resource belongs, and each data table has a unique identifier corresponding to it. The server can search the data table based on the identifier, thereby obtaining the description information such as the fields and row and column values included in the data table, and summarize the description information to generate data catalog information.
[0091] For example, for a bicycle manufacturer, data resources may be information about bicycle parts, production, supply channels, supply and sales costs, and parts processing. For a medical system, data resources may be user cases, including user attribute information, gender, and age. For a registration system, data resources may be doctor information, user case information, department information, and hospital structure address, etc. For a power grid system, data resources may be electricity consumption information, equipment information, system circuit connection information, power equipment loss value, and equipment maintenance information. Data cataloging may be the process of cataloging data resources, classifying data according to certain standard rules, and generating data tables. Based on the data cataloging information of each business system, at least one data cataloging information corresponding to the target data type may be queried.
[0092] For example, if it is resource data of the power system, the corresponding attribute information may include power consumption information, equipment information, system circuit connection information, power equipment loss value and equipment maintenance information. Accordingly, based on the above attribute information, the resource data of the power system can be cataloged to form data catalog information corresponding to the data resources and at least one data table corresponding to the data catalog information. Subsequently, according to the data catalog information of each business system, the data catalog information corresponding to the target data type is queried.
[0093] In an embodiment of the present application, data resources of at least one business system are obtained, and attribute information corresponding to the data resources of at least one business system is determined. Subsequently, the data resources of at least one business system are cataloged according to the attribute information, and data cataloging information of at least one business system and at least one data table corresponding to each data cataloging information are generated. Finally, according to the data cataloging information of at least one business system, at least one data cataloging information corresponding to the target data type is queried. Because information classification processing is performed to obtain descriptive information of the data table, and each data table is merged to obtain a cataloged data table, a data interface file corresponding to the target data type is generated, thereby improving the efficiency of data interface generation.
[0094] S203: Obtain description information of a data resource table corresponding to at least one data cataloging information.
[0095] In this step, after the server queries at least one data catalog information corresponding to the target data type, the description information of the data resource table corresponding to the at least one data catalog information can be obtained.
[0096] In some embodiments, the description information of the data table may include identification information of the data table. Each data table may be searched through the description information to obtain the data table to be searched.
[0097] In some embodiments, the description information of the data table may also include the field name in the data table, the data in the data table, the business system information to which the data table belongs, and the data resource authority information of the data table, etc. Accordingly, the server may extract the description information of the above data table by means of a neural network.
[0098] For example, data catalog information 1 is a string formed by combining electricity type, total electricity consumption and electricity equipment, and the data tables corresponding to data catalog information 1 are electricity type table, total electricity consumption table and electricity equipment table. Descriptive information such as electricity type table, total electricity consumption table and electricity equipment table can be extracted from the data catalog information through a neural network.
[0099] S204. According to the description information of each data table, each data table is merged to obtain a catalog data table corresponding to the target data type.
[0100] In this step, after the server obtains the description information of the data resource table corresponding to at least one data catalog information, it can merge the data tables according to the description information of each data table to obtain the catalog data table corresponding to the target data type.
[0101] The catalog data table may be a data table obtained by merging data tables corresponding to the data catalog information. One piece of data catalog information corresponds to one catalog data table.
[0102] In some embodiments, the data tables corresponding to the data catalog information can be merged according to the description information to obtain a catalog data table, and the catalog data table is stored to facilitate querying the merged description information of the data tables corresponding to the data catalog information.
[0103] Exemplarily, the data catalog information 1 is a string formed by concatenating the electricity type, the total electricity consumption, and the electricity equipment. The data tables corresponding to the data catalog information 1 are the electricity type table, the total electricity consumption table, and the electricity equipment table. The description information of the electricity type table, the total electricity consumption table, and the electricity equipment table is extracted from the data catalog information. The electricity type table, the total electricity consumption table, and the electricity equipment table corresponding to the data catalog information 1 are merged according to the description information to obtain a catalog data table 1.
[0104] It should be understood that the embodiments of the present application do not limit how to merge the data tables according to the description information of the data tables. In some embodiments, the server can query the overlapping data between the data tables according to the description information of the data tables. Subsequently, the server can splice the data tables according to the overlapping data between the data tables to form a catalog data table.
[0105] The overlapping data may be data with the same field name or data type in two data tables.
[0106] In some embodiments, the server can query the overlapping data between the data tables based on the description information of each data table, and merge all data tables corresponding to the data cataloging information corresponding to the target data type. If there is overlapping data between the data tables, the data in the data tables are rearranged according to the overlapping data, and the description information of the same field name or data type is placed in a column in order, and the different field names or data types are placed in a row in order, so as to splice the data tables together. If there is no overlapping data between the data tables, the data tables are spliced horizontally or vertically to obtain a spliced data table to form a cataloging data table.
[0107] Exemplarily, the target data type is restful, and the data catalog information 1 corresponding to the target data type is a string formed by concatenating the electricity type, the total electricity consumption, and the electricity equipment. The data tables corresponding to the data catalog information 1 are the electricity type table, the total electricity consumption table, and the electricity equipment table. The column names of the electricity type table are electricity users and electricity types, the column names of the total electricity consumption table are electricity users and total electricity consumption, and the column names of the electricity equipment table are electricity users and electricity equipment. The electricity type table, the total electricity consumption table, and the electricity equipment table corresponding to the data catalog information 1 can be merged according to the column names of each data table to obtain a catalog data table 1. The column names of the catalog data table 1 are electricity users, electricity types, total electricity consumption, and electricity equipment. The description information in the catalog data table 1 is the description information of the electricity users, electricity types, total electricity consumption, and electricity equipment columns.
[0108] In an embodiment of the present application, the data tables are spliced based on the overlapping data between the data tables to form a cataloged data table. The data tables corresponding to the same data cataloging information can be spliced to obtain summary information corresponding to the data cataloging information, which facilitates obtaining the input parameters of the data interface, generates a data interface file, and improves the efficiency of data interface generation.
[0109] In some embodiments, before merging the data tables, the server can also determine whether there is a catalog data table corresponding to the target data type based on the description information of each data table. If there is no catalog data table corresponding to the target data type, the data tables are merged based on the description information of each data table to obtain a catalog data table corresponding to the target data type.
[0110] In some embodiments, if there is a data interface corresponding to the target data type, indicating that the data interface corresponding to the target data type has been generated in the historical time period, there is no need to generate the data interface again, and the data interface file corresponding to the requested data type can be directly obtained, and a prompt message that the data interface already exists is returned to the user. The prompt message can be relevant communication information that can call the data interface, such as the data interface deployment location or the data interface call address.
[0111] Exemplarily, the target data type is restful, and if it is detected that there is a data interface corresponding to the target data type restful, the data interface file corresponding to the target data type is obtained, and the data interface call address of the data interface is returned to the user.
[0112] In an embodiment of the present application, by detecting, based on the description information of each data table, that the data interface corresponding to the requested data type does not exist, the data tables are merged based on the description information of each data table to obtain a cataloged data table, thereby avoiding redundant generation of data interfaces and avoiding waste of resources.
[0113] S205. Generate a data interface file corresponding to the target data type according to the cataloged data table.
[0114] In this step, after the server merges the data tables according to the description information of the data tables to obtain the catalog data table corresponding to the target data type, it can generate a data interface file corresponding to the target data type according to the catalog data table.
[0115] The data interface file may be an executable code file that generates information of a callable data interface in response to a data interface generation request.
[0116] In some embodiments, the server may search for a catalog data table corresponding to the target data type based on the catalog data table, and then generate a data interface file corresponding to the requested data type based on the description information in the catalog data table.
[0117] Exemplarily, the data catalog information 1 is a string formed by concatenating the electricity type, the total electricity consumption, and the electricity equipment. The data tables corresponding to the data catalog information 1 are the electricity type table, the total electricity consumption table, and the electricity equipment table. The description information of the electricity type table, the total electricity consumption table, and the electricity equipment table is extracted from the data catalog information. According to the description information, the electricity type table, the total electricity consumption table, and the electricity equipment table corresponding to the data catalog information 1 are merged to obtain a catalog data table 1. According to the catalog data table 1, the catalog data table corresponding to the requested data type is searched, and according to the description information in the catalog data table, the data interface file corresponding to the requested data type is generated.
[0118] It should be understood that the embodiments of the present application do not limit how to generate a data interface file corresponding to the target data type based on the catalog data table. In some embodiments, the server can first add the field name in the catalog data table to the configuration information corresponding to the target data type. Subsequently, the server can obtain a preset general statement template, which includes an input parameter position and an output parameter position. Finally, the server can use the general interface code file to fill the fields in the catalog data table into the input parameter position and the output parameter position according to the configuration information to generate a data interface file.
[0119] The data interface generation method provided in the embodiment of the present application first obtains the data interface generation request sent by the requesting end, and the data interface generation request includes the target data type requested by the requesting end. Secondly, query at least one data cataloging information corresponding to the target data type, and the data cataloging information is used to indicate the data resources adapted by the target data type. And obtain the description information of the data resource table corresponding to at least one data cataloging information. Thirdly, according to the description information of each data table, each data table is merged to obtain the cataloging data table corresponding to the target data type. Finally, according to the cataloging data table, a data interface file corresponding to the target data type is generated. Since the corresponding cataloging data table can be obtained according to the target data type of different requests, and then the corresponding data interface file is generated based on the cataloging data table, there is no need to manually customize the generation of the data interface file, which realizes the automatic generation of the data interface file and improves the efficiency of data interface generation.
[0120] The following describes how to generate a data interface file corresponding to the target data type based on the cataloged data table. Figure 3 A flow chart of another data interface generation method provided in an embodiment of the present application is shown as follows: Figure 3 As shown, the data interface generation method includes S301-S307:
[0121] S301. Obtain a data interface generation request sent by a requesting end, where the data interface generation request includes the target data type requested by the requesting end.
[0122] S302: Query at least one data catalog information corresponding to the target data type, where the data catalog information is used to indicate data resources adapted to the target data type.
[0123] S303: Obtain description information of a data resource table corresponding to at least one data cataloging information.
[0124] S304. According to the description information of each data table, each data table is merged to obtain a catalog data table corresponding to the target data type.
[0125] S305: Add the field names in the catalog data table to the configuration information corresponding to the target data type.
[0126] The configuration information may be information of a field name corresponding to a target data type.
[0127] In some embodiments, the server may obtain field names in the catalog data table, and add the obtained field names to the configuration information corresponding to the target data type.
[0128] Exemplarily, the target data type is restful, and the field names of catalog data table 1 are electricity users, electricity types, total electricity usage and electricity devices. Then, electricity users, electricity types, total electricity usage and electricity devices are added to the configuration information corresponding to the target data type restful.
[0129] S306: Obtain a preset general sentence template.
[0130] The general statement may be a Structured Query Language (SQL) statement. Structured Query Language is a special-purpose programming language, a database query and programming language, used to access data and query, update and manage relational database systems.
[0131] In some embodiments, the general statement template includes an input parameter position and an output parameter position, wherein the input parameter position may be a position in an input parameter where a parameter can be replaced, and the output parameter position may be a position in an output parameter where a parameter can be replaced.
[0132] The number of general statement templates may be one or more, including general statement templates of the types of adding, deleting, modifying and querying.
[0133] S307. According to the configuration information, use the general interface code file to fill the fields in the catalog data table into the input parameter position and the output parameter position to generate a data interface file.
[0134] The general interface code file may be a code file corresponding to the function of filling input parameters into SQL statements, executing SQL statements, obtaining return results, and returning the return results to the requesting end.
[0135] In some embodiments, when the general interface code file is executed, the fields in the cataloged data table are filled into the general statement template, and a statement to be executed may be generated, and the statement to be executed is executed to generate a data interface file.
[0136] Exemplarily, the field names of the catalog data table 1 are electricity users, electricity types, total electricity consumption, and electricity equipment. After obtaining the general statement template, the general statement template includes an input parameter position and an output parameter position. The electricity users, electricity types, total electricity consumption, and electricity equipment can be filled into the general statement template through the general interface code file.
[0137] In some embodiments, the configuration information corresponding to the target data type can be a pre-generated general file, or it can be a general file that has not been generated in the historical time period and is generated during the execution of the current general statement. An empty configuration file is preset, and the field names in the data catalog table are directly added to the configuration file to obtain the configuration information corresponding to the requested data type. Subsequently, the fields in the catalog data table are filled into the input parameter position and the output parameter position of the general statement template, thereby generating a data interface file corresponding to the target data type.
[0138] Exemplarily, an empty configuration file 1 is preset, and the field names of electrical equipment and electricity usage type in the data catalog table 1 are directly added to the configuration file 1 to obtain configuration information corresponding to the requested data type; the fields of electrical equipment and electricity usage type in the catalog data table 1 are filled into the input parameter position of the general statement template, and the indexed keywords of electrical equipment and electricity usage type are filled into the output parameter position of the general statement template, thereby generating a data interface file 1 corresponding to the target data type.
[0139] In an embodiment of the present application, the field names in the catalog data table are added to the configuration information corresponding to the target data type, and a preset general statement template is obtained, which includes an input parameter position and an output parameter position. According to the configuration information, a general interface code file is used to fill the fields in the catalog data table into the input parameter position and the output parameter position to generate a data interface file. Since the data interface file is automatically generated through multidimensional data, there is no need to manually customize the generation of the data interface file, which improves the efficiency of data interface generation.
[0140] The following describes how to test and publish the data interface file after generating the data interface file corresponding to the target data type. Figure 4 A flow chart of another data interface generation method provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the data interface generation method includes S401-S408:
[0141] S401. Obtain a data interface generation request sent by a requesting end, where the data interface generation request includes a target data type requested by the requesting end.
[0142] S402: Query at least one data catalog information corresponding to the target data type, where the data catalog information is used to indicate data resources adapted to the target data type.
[0143] S403: Obtain description information of a data resource table corresponding to at least one data cataloging information.
[0144] S404: Merge the data tables according to their description information to obtain a cataloged data table corresponding to the target data type.
[0145] S405. Generate a data interface file corresponding to the target data type according to the cataloged data table.
[0146] S406: Deploy the data interface file in the target container.
[0147] The target container may be a virtual storage space, and the data processing and storage between multiple target containers are isolated from each other and do not interfere with each other.
[0148] S407: Run the loaded data interface file in the target container to test the code function in the data interface file.
[0149] In some embodiments, a request to add a specified field is sent in the configuration file, and the data interface file is automatically run. If the data table successfully adds the specified field and returns a correct result, the code function in the data interface file can run correctly. The process of automated testing can be achieved by pre-generating an automated test script and running the script in the container. The script generates input information based on the field name in the configuration file and sends it to the interface. After the interface obtains the data, it determines whether the output result of the interface is consistent with the preset output result. If the output result of the interface is consistent with the preset output result, it proves that the code function in the data interface file can run correctly; the preset output result can be stored in a data table or database. After the test of each code function in the data interface file is completed, the data interface file is released.
[0150] S408. When the code function test of the data interface file passes, the data interface file is released.
[0151] In this application, the data interface file is deployed in a container, the code in the data interface file is loaded and run, and the code function in the data interface file is tested. When the test passes, the data interface file is released. By testing the code function in the data interface file, the reliability of the data interface file is guaranteed.
[0152] The data interface generation method provided in the embodiment of the present application first obtains the data interface generation request sent by the requesting end, and the data interface generation request includes the target data type requested by the requesting end. Secondly, query at least one data cataloging information corresponding to the target data type, and the data cataloging information is used to indicate the data resources adapted by the target data type. And obtain the description information of the data resource table corresponding to at least one data cataloging information. Thirdly, according to the description information of each data table, each data table is merged to obtain the cataloging data table corresponding to the target data type. Finally, according to the cataloging data table, a data interface file corresponding to the target data type is generated. Since the corresponding cataloging data table can be obtained according to the target data type of different requests, and then the corresponding data interface file is generated based on the cataloging data table, there is no need to manually customize the generation of the data interface file, which realizes the automatic generation of the data interface file and improves the efficiency of data interface generation.
[0153] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0154] Based on the same inventive concept, the embodiment of the present application also provides a data interface generation device for implementing the data interface generation method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more data interface generation device embodiments provided below can refer to the limitations on the data interface generation method above, and will not be repeated here.
[0155] In an exemplary embodiment, Figure 5As shown, a data interface generating device 500 is provided, comprising: a request obtaining module 501, an information query module 502, an information extraction module 503, a data table fusion module 504 and a file generating module 505, wherein:
[0156] The request acquisition module 501 is used to acquire a data interface generation request sent by a request end, where the data interface generation request includes a target data type requested by the request end.
[0157] The information query module 502 is used to query at least one data catalog information corresponding to the target data type, where the data catalog information is used to indicate the data resources adapted by the target data type.
[0158] The information extraction module 503 is used to obtain description information of a data resource table corresponding to at least one data cataloging information.
[0159] The data table fusion module 504 is used to fuse the data tables according to the description information of the data tables to obtain a catalog data table corresponding to the target data type.
[0160] The file generation module 505 is used to generate a data interface file corresponding to the target data type according to the cataloged data table.
[0161] In one of the embodiments, the file generation module 505 is also used to add the field names in the catalog data table to the configuration information corresponding to the target data type; obtain a preset general statement template; and use the general interface code file to fill the fields in the catalog data table into the input parameter position and the output parameter position according to the configuration information to generate a data interface file.
[0162] In one of the embodiments, the data table fusion module 504 is also used to determine whether there is a catalog data table corresponding to the target data type based on the description information of each data table; if not, the data tables are merged based on the description information of each data table to obtain the catalog data table corresponding to the target data type.
[0163] In one of the embodiments, the data table fusion module 504 is also used to query the overlapping data between the data tables according to the description information of each data table; and to splice the data tables according to the overlapping data between the data tables to form a catalog data table.
[0164] In one of the embodiments, the information query module 502 is also used to query the data type corresponding to the request permission of the data requester; compare the data type corresponding to the request permission with the target data type to obtain a comparison result; verify the request permission of the requesting end according to the comparison result; if the request permission of the requesting end passes the verification, query at least one data cataloging information corresponding to the target data type.
[0165] In one of the embodiments, the information query module 502 is also used to obtain data resources of at least one business system; determine the attribute information corresponding to the data resources of at least one business system; catalog the data resources of at least one business system according to the attribute information, generate data catalog information of at least one business system, and at least one data table corresponding to each data catalog information; query at least one data catalog information corresponding to the target data type according to the data catalog information of at least one business system.
[0166] In one embodiment, the data interface generating device 500 further includes:
[0167] The test release module is used to deploy the data interface file in the target container; run the loaded data interface file in the target container to test the code function in the data interface file; and release the data interface file when the code function test of the data interface file passes.
[0168] Each module in the above-mentioned data interface generation device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0169] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a data interface generation method is implemented.
[0170] Those skilled in the art will understand that the structure shown in FIG. 6 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0171] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above-mentioned data interface generation method when executing the computer program.
[0172] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned data interface generation method is implemented.
[0173] In one embodiment, a computer program product is provided, including a computer program, which implements the above-mentioned data interface generation method when executed by a processor.
[0174] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0175] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0176] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A data interface generation method, characterized in that: The method comprises: Obtaining a data interface generation request sent by a requesting end, wherein the data interface generation request includes a target data type requested by the requesting end; Query at least one data catalog information corresponding to the target data type, where the data catalog information is used to indicate a data resource adapted by the target data type; Obtaining description information of a data resource table corresponding to the at least one data cataloging information; According to the description information of each data table, the data tables are merged to obtain a catalog data table corresponding to the target data type; A data interface file corresponding to the target data type is generated according to the cataloged data table.
2. The method according to claim 1, characterized in that The step of generating a data interface file corresponding to the target data type according to the cataloged data table includes: Adding the field names in the catalog data table to the configuration information corresponding to the target data type; Obtain a preset general statement template, wherein the general statement template includes an input parameter position and an output parameter position; According to the configuration information, the fields in the catalog data table are filled into the input parameter position and the output parameter position using a general interface code file to generate a data interface file.
3. The method according to claim 1, characterized in that The step of fusing the data tables according to the description information of the data tables to obtain a catalog data table corresponding to the target data type includes: Determine, based on the description information of each data table, whether there is a catalog data table corresponding to the target data type; If not, then the data tables are merged according to the description information of the data tables to obtain a catalog data table corresponding to the target data type.
4. The method according to claim 1 or 3, characterized in that: The step of fusing the data tables according to the description information of the data tables to obtain a catalog data table corresponding to the target data type includes: According to the description information of each data table, query the overlapping data between the data tables; According to the overlapping data between the various data tables, the various data tables are spliced to form the cataloged data table.
5. The method according to claim 1, characterized in that The querying of at least one data catalog information corresponding to the target data type includes: Query the data type corresponding to the request authority of the data requester; Compare the data type corresponding to the requested permission with the target data type to obtain a comparison result; Verifying the request authority of the requesting end according to the comparison result; If the request authority check of the requesting end passes, at least one data cataloging information corresponding to the target data type is queried.
6. The method according to claim 1, characterized in that Before querying at least one data catalog information corresponding to the target data type, the method further includes: Acquire data resources of at least one business system; Determine attribute information corresponding to the data resources of the at least one business system respectively; Cataloging the data resources of the at least one business system according to the attribute information, generating data cataloging information of the at least one business system and at least one data table corresponding to each piece of data cataloging information; The querying of at least one data catalog information corresponding to the target data type includes: According to the data catalog information of the at least one business system, at least one data catalog information corresponding to the target data type is queried.
7. The method according to claim 1, characterized in that After generating the data interface file corresponding to the target data type according to the cataloged data table, the method further includes: Deploy the data interface file in the target container; Running and loading the data interface file in the target container to test the code function in the data interface file; When the code function test of the data interface file passes, the data interface file is released.
8. A data interface generating device, characterized in that: The device comprises: A request acquisition module, used to acquire a data interface generation request sent by a request end, wherein the data interface generation request includes a target data type requested by the request end; An information query module, used to query at least one data catalog information corresponding to the target data type, wherein the data catalog information is used to indicate a data resource adapted to the target data type; An information extraction module, used to obtain description information of a data resource table corresponding to the at least one data cataloging information; A data table fusion module, used to fuse the data tables according to the description information of the data tables to obtain a catalog data table corresponding to the target data type; The file generation module is used to generate a data interface file corresponding to the target data type according to the cataloged data table.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Metadata self-discovery-based data query interface automatic generation method and system
CN110083650A
An API interface generation method and device, an API interface calling method and device and electronic equipment
CN113448985A
Interface generation method and device, computer equipment and storage medium
CN114218315A
File generation method and system, computer equipment and storage medium
CN117669518A
