Http interface data table field query method and system

This method for querying data table fields, implemented in Go, utilizes mapping relationships for data field validation and querying, solving the problem of low code writing efficiency in existing technologies and achieving efficient HTTP interface data table field querying.

CN114218278BActive Publication Date: 2025-10-21CCB FINTECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111545532.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-16
Publication Date
2025-10-21
Estimated Expiration
2041-12-16

AI Technical Summary

Technical Problem

Existing technologies for querying data table fields in HTTP interfaces on web servers suffer from low code writing efficiency and maintenance difficulties, especially when adding, modifying, or deleting form fields, which requires a large amount of repetitive code modification.

Method used

This method for querying data table fields, implemented in Go, retrieves query parameters for specified data fields, creates a form to be returned, performs data field validation and querying using mapping relationships, and outputs a JSON-formatted string as a service response, thus avoiding repetitive code writing.

Benefits of technology

It improves the processing and writing efficiency of HTTP interfaces, simplifies the maintenance process of form fields, and reduces the workload of code modification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114218278B_ABST
    Figure CN114218278B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a kind of http interface data table field query method and system.The method comprises the following steps: obtaining the query parameter of specified data field;According to the query parameter of the specified data field, the rule of pre-set structure list is created, and the table form to be returned is created;The data form of the corresponding API interface of query request is obtained, the query parameter of specified data field and the table form to be returned are based on, the specified data field is inquired in the data form, and the data obtained by inquiring is saved to the table form to be returned;Based on the table form to be returned of completing data saving, the string of json format is output, and service response is carried out based on the string of json format.The present application improves the writing efficiency and processing efficiency of data table field query method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method for querying data table fields via an HTTP interface and a system for querying data table fields via an HTTP interface. Background Art

[0002] Web servers implemented using software programming languages ​​often provide additional API interfaces that can be called via HTTP / HTTPS. API interfaces often require functionality such as querying data in a table and returning multiple entries / rows of data, each entry / row containing multiple columns of data fields. Alternatively, the returned data list can be filtered for a specific column of data fields while querying the table data, specifically only those with a specific data value. Based on the aforementioned requirements for filtering query functionality for HTTP interfaces in web server software systems, existing approaches primarily involve obtaining a specific query table and then, in each implemented API interface, performing multiple layers of if-else statements on each column to determine whether the query target exists. Alternatively, switch statements are used to perform search and match queries, with decisions made based on the search and match results. This approach requires extensive repetitive code writing for different API interface forms, resulting in lengthy code logic for individual form fields. Furthermore, adding, modifying, or deleting form fields requires extensive code modifications, making the API interface less convenient for future maintenance and updates. This has greatly affected both the writing efficiency and the processing efficiency. In view of the low writing efficiency and processing efficiency of the existing processing methods, a new data table field query method using the http interface is urgently needed. Summary of the Invention

[0003] The purpose of the embodiments of the present application is to provide a method and system for querying data table fields through an HTTP interface.

[0004] In order to achieve the above-mentioned purpose, the first aspect of the present application provides a data table field query method of an http interface, including: obtaining query parameters of a specified data field; creating a to-be-returned form according to a preset structure list creation rule and the query parameters of the specified data field; obtaining a data form of the API interface corresponding to the query request, querying the specified data field in the data form based on the query parameters of the specified data field and the to-be-returned form, and saving the data obtained from the query to the to-be-returned form; outputting a string in json format based on the to-be-returned form in which data saving is completed, and making a service response based on the string in json format.

[0005] In the embodiment of the present application, the query parameter of the specified data field includes a key-value pair consisting of the name of the specified data field and the corresponding value.

[0006] In an embodiment of the present application, the form to be returned is defined as a struct data type; wherein, the form to be returned includes multiple data field columns, and each data field column is defined as a member variable of the struct data.

[0007] In an embodiment of the present application, each member variable is provided with a structure tag, the keys of the structure tag are json and column; wherein, json is used to describe the name of each data field in the entity string; column is used to describe the name of each data field in the data form; wherein, each member variable represents the mapping relationship between the name of a data field in the entity string and the name in the data form.

[0008] In an embodiment of the present application, before querying the specified data field in the data form based on the query parameters of the specified data field and the form to be returned, the method also includes: verifying the specified data field in the data form based on the query parameters of the specified data field and the form to be returned, including: obtaining the name of the specified data field in the data form according to the mapping relationship based on the name of the specified data field in the entity string; comparing the name of the specified data field in the data form with the names of each data column in the data form of the corresponding API interface to determine whether there is a matching relationship; if there is no matching relationship, determining that the specified data field does not exist in the data form of the corresponding API interface, and determining that the verification of the specified data field has failed; if there is a matching relationship, outputting a verification success signal for the specified data field.

[0009] In an embodiment of the present application, the query parameters of the specified data field and the form to be returned are used to query the specified data field in the data form, and the data obtained from the query is saved in the form to be returned, including: in response to a verification success signal, the query parameters of the specified data field and the form to be returned are spliced ​​to obtain query structure parameters; based on the query structure parameters, the specified data field is queryed in the data form to obtain the specific data value under the specified data field; the specific data value under the specified data field is output, and the specific data value is saved in the form to be returned.

[0010] In an embodiment of the present application, the output of a string in json format based on the form to be returned after completing data storage includes: converting the data in the form to be returned after completing data storage into a corresponding string in json format according to a preset json string serialization method.

[0011] The second aspect of the present application provides a data table field query system for an HTTP interface, comprising: a collection unit for obtaining query parameters for a specified data field, and a data form for obtaining a data form of an API interface corresponding to a query request; a processing unit for creating a form to be returned based on a preset structure list creation rule and the query parameters of the specified data field; querying the specified data field in the data form based on the query parameters of the specified data field and the form to be returned, and saving the data obtained from the query to the form to be returned; an output unit for outputting a string in JSON format based on the form to be returned in which data saving is completed; and an execution unit for making a service response based on the string in JSON format.

[0012] A third aspect of the present application provides a machine-readable storage medium having instructions stored thereon. When the instructions are executed by a processor, the processor is configured to execute the above-mentioned data table field query method of the http interface.

[0013] A fourth aspect of the present application provides a computer program product, comprising a computer program, which implements the above-mentioned http interface data table field query method when executed by a processor.

[0014] With the above technical solution, when a query request is received, a to-be-returned form is constructed based on the specified data fields. The data is then verified to be in the target data form. If the verification passes, the query data is mapped and extracted based on the created return form, and the query data is saved in the to-be-returned form. Data feedback is then generated based on the to-be-returned form, with the data processed into a JSON-formatted string, and a service response is provided based on the JSON-formatted string.

[0015] The solution of the present invention provides a query algorithm based on the Go language with strong universality. It does not require repeated coding for different situations. Direct use of this method can meet all query requirements of the HTTP interface, which has a positive impact on both processing efficiency and writing efficiency.

[0016] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following detailed description, they are used to explain the embodiments of the present application but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:

[0018] Figure 1 Schematically shows a flowchart of the steps of the data table field query method of the http interface according to an embodiment of the present application;

[0019] Figure 2 The following schematically shows a flow chart of querying a specified data field according to an embodiment of the present application;

[0020] Figure 3 Schematically shows a system structure diagram of a data table field query system of an http interface according to an embodiment of the present application;

[0021] Figure 4 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0022] To make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0023] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the various components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indications will also change accordingly.

[0024] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of such features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the fact that they can be implemented by ordinary technicians in this field. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0025] Web servers implemented using software programming languages ​​often provide additional APIs that can be called via HTTP / HTTPS. APIs often require functionality such as querying data in a table and returning multiple entries / rows, each containing multiple columns. Alternatively, the returned list can be filtered to identify specific columns, limiting the search to those containing specific values. This requirement for filtering specific form data arises from the HTTP interface in web server software systems.

[0026] In the existing processing methods, the main method is to obtain a specific query form, and then in each implemented API interface, perform multiple layers of if-else on each different column field, and judge whether the query target exists layer by layer. Or it is implemented by searching and matching through a switch statement, and judging based on the search and matching results. In the implementation process of this method, a large amount of repeated code writing is required for different API interface forms, and the code logic of a single form field will be too long. In addition, changes in the addition, modification, and deletion of form fields involve too many code modifications, and the API interface is even more inconvenient for subsequent maintenance and updating. This has a great impact on both writing efficiency and processing efficiency. Therefore, there is an urgent need for a logical implementation method of an http interface that can efficiently perform data table field queries. Based on this problem, the present invention provides a unified and concise logic processing method to solve the code encoding problem mentioned above.

[0027] For ease of explanation, the specific implementation methods of this application will be described using the Go programming language. However, it should be noted that the proposed methods are not limited to the Go programming language. Based on the concepts and processes presented in this application, any programming language can theoretically implement the proposed methods. The Go programming language is a statically strongly typed, compiled language with a syntax similar to C, but with features such as memory safety, garbage collection (GC), structural morphology, and CSP-style concurrent computing. As a relatively new language, only ten years old, the Go programming language has seen rapid growth and has already replaced Python in many applications, such as processing cloud logs stored on S3; moving terabyte-sized files between S3 buckets and / or regions; and matching local database records with S3 files to ensure synchronization. These tasks are often one-time, making them more suitable for scripting languages. These tasks require rapid programming, and the code is typically discarded after a single use. Generally speaking, the requirements for these tasks are relatively novel and specific, and code reuse is rare. The Go programming language offers advantages such as a convenient compiler, fast development speed, improved parallelism, simple deployment, consistent style, and convenient tooling. This invention is based on the advantages of the Go language and creates a logical implementation method for an HTTP interface that realizes data table field query.

[0028] Figure 3 The system structure of the data table field query system of the http interface according to the embodiment of the present application is schematically shown. Figure 3 As shown, the present application provides a data table field query system for an http interface, including: a collection unit, used to obtain query parameters for a specified data field, and a data form of an API interface corresponding to the query request; a processing unit, used to: create a to-be-returned form according to a preset structure list creation rule and the query parameters of the specified data field; based on the query parameters of the specified data field and the to-be-returned form, query the specified data field in the data form, and save the data obtained from the query to the to-be-returned form; an output unit, used to output a string in json format based on the to-be-returned form in which data saving is completed; and an execution unit, used to make a service response based on the string in json format.

[0029] Figure 1 The following schematically shows a flow chart of a method for querying data table fields using an http interface according to an embodiment of the present application. Figure 1 As shown, in one embodiment of the present application, a method for querying data table fields using an HTTP interface is provided, comprising the following steps:

[0030] Step S10: Obtain query parameters of the specified data field.

[0031] Specifically, the core purpose of the present invention is to directly query and extract fields from a target data table. To achieve this, the form fields to be queried must first be obtained. In the present invention, a complete web service API interface page request method is as follows: First, the client calls the web server API interface via the HTTP GET method to query the data list under the specified data field value of the specified form. The web server then receives the HTTP request and enters the code function implemented by the API interface for execution. The function then obtains the key and value of the data field of the form to be queried specified in the request parameters and performs data verification on the parameter key and value. If the parameter verification fails, a request error is returned; if the parameter verification passes, the next step is performed. Then, based on the request URL and parameters, the SQL statement or method required for database query is assembled to query the database data. The query results returned by the database are saved in the data structure list defined in the form, converted into a JSON format string using the JSON string serialization method, and finally returned to the client via the HTTP response. Finally, the client receives the form JSON data list in the returned HTTP response and displays the page form, completing the page request.

[0032] First, it is necessary to obtain a service query request. The user initiates a service request on the front end. The http interface allocates the corresponding API interface based on the service request to execute the business. The API interface needs to perform subsequent data queries. The query parameters of the specified data field are obtained according to the query target. Preferably, the query parameters include a key-value pair consisting of the name of the specified data field and the corresponding value, that is, the key and value of the specified data field. In layman's terms, it is necessary to map the entity language request name initiated by the user to the storage language name of the storage backend, and then retrieve the backend data according to the mapping relationship. Therefore, each data field includes a front-end name and a back-end name. The name of the specified data field obtained at this time is the name of the front end.

[0033] Step S20: creating a form to be returned according to the preset structure list creation rules and the query parameters of the designated data fields.

[0034] Specifically, as mentioned above, it is necessary to find the name of the corresponding data field in the backend according to the mapping relationship. Based on this rule, the present invention proposes a mapping relationship system, that is, a preset structure list creation rule. For the form field that needs to be queried, it is necessary to obtain the corresponding specific http API interface, and then return the required form field through it. For this form field, it is necessary to create it as a preset form to be returned. Preferably, the form to be returned is written in go language, and the form to be returned is set to the struct data type. The form to be returned contains multiple form columns, which are exactly the target set we want to query. In order to distinguish the form columns, the form field of each column is defined as a member variable of struct. In order to characterize the differentiation of the form fields of each column, a structure tag StructTag is set for each member variable, and the Struct Tag characterizes the identity information of the corresponding member variable. The corresponding structure tag adds the tag Tag key as json, which is used to describe the field name of the form, and adds the tag Tag key as column, which is used to describe the field name of the database table to be queried. For example, for column field 1, its representation is:

[0035] Column field 1 string `json:"The name represented in json" column:"The name defined in the database table".

[0036] Step S30: Obtain the data form of the API interface corresponding to the query request, query the specified data field in the data form based on the query parameters of the specified data field and the form to be returned, and save the query data to the form to be returned.

[0037] Specifically, according to the requested URL and parameters, the SQL statement or method required for database query is spliced ​​to obtain the target data table field. The target can also be actively specified by the user. In order to define the query target, a name key is set for the query target for subsequent retrieval and comparison. Then, the query rules need to be preset. Figure 2 , including the following steps:

[0038] Step S301: Map the structure tags in the to-be-returned form formed by the corresponding API interface into a map system.

[0039] Specifically, first define a general function CheckStructTag, the input parameter of which is the interface object interface{} of any defined form to be returned. The interface{} type, the empty interface, is the source of a lot of confusion. The interface{} type is an interface without methods. Since there is no implements keyword, all types implement at least 0 methods, so all types implement the empty interface. This means that if you write a function with an interface{} value as a parameter, you can provide any value to the function, which can represent the interface object of any defined form to be returned. The output parameter of the function is map[string]string, which is used to obtain the value of the json defined in the tag Tag of each member variable (column field) in the form to be returned as the input parameter, and the value of the column defined in the Tag is the value of the map. Among them, map is a data structure that obtains value through key. Its underlying storage method is array. Key cannot be repeated during storage. When the key is repeated, the value is overwritten. We perform hash operation on the key (which can be simply understood as converting the key into an integer) and then take the remainder of the length of the array to get the index position of the array where the key is stored. Finally, assemble the key and value into a structure and put it into the array index.

[0040] Step S302: Based on the reflection function of the Go language, each member variable in the form to be returned is traversed, and the structure tag of each member variable is mapped to a corresponding key:value pair.

[0041] Specifically, the pre-defined general function CheckStructTag utilizes the Go language's "reflect" feature. Reflection in the Go language refers to the ability to access and modify a program during runtime. During program compilation, variables are converted to memory addresses, and the variable names are not written into the executable by the compiler. During program execution, the program cannot access its own information. Languages ​​that support reflection can integrate variable reflection information, such as field names, types, and structures, into the executable file during program compilation and provide the program with an interface to access this reflection information. This allows the program to obtain type reflection information and modify it during runtime. Using this feature, the JSON and column information of the Struct Tag description for each member of the input structure, struct, is retrieved. The JSON value of the structure tag corresponds to the map key, and the column value of the structure tag corresponds to the map value. The corresponding map key and map value are stored in key:value pairs.

[0042] Step S303: perform verification of designated data fields.

[0043] Specifically, if the specified data field does not exist in the corresponding data form, it is meaningless to perform subsequent data query and extraction. In order to avoid the impact of such meaningless steps, it is preferred that the specified data field is checked first when performing a specific data query. As mentioned above, the mapping relationship constructed is a mapping relationship in which each member variable represents the name of a data field in the entity string and the name in the form. Based on the mapping relationship, the name of the specified data field is mapped to the name in the data form, and then the name of the specified data field in the data form and the name of each data column in the data form of the corresponding API interface are compared to determine whether there is a matching relationship; if there is no matching relationship, it means that the specified data field does not exist in the corresponding form, and the specified data field verification fails. If there is a matching relationship, it means that the current specified data field exists in the data form, and the next step can be executed.

[0044] Step S304: extracting specific query data.

[0045] Specifically, if it is determined that the designated data field exists in the data form of the corresponding API interface, the extracted specific query data is filled into the form to be returned.

[0046] Step S40: Based on the form to be returned in which data storage is completed, a string in json format is output, and a service response is performed based on the string in json format.

[0047] Specifically, the data is serialized into a JSON string for the queried data table fields. When the JSON string is serialized, a bool value of true is output, notifying the user that the query is complete. The user can then proceed based on the JSON string sequence. If the specified data field does not exist in the data form of the corresponding API interface, the output string is empty, and a bool value of false is output, notifying the user that the query failed.

[0048] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the query method of the data table field of the HTTP interface can be implemented by adjusting the kernel parameters.

[0049] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0050] An embodiment of the present application provides a storage medium on which a program is stored. When the program is executed by a processor, the data table field query method of the above-mentioned http interface is implemented.

[0051] An embodiment of the present application provides a computer program product, including a computer program, which implements the data table field query method of the above-mentioned http interface when executed by a processor.

[0052] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor A01, a network interface A02, a display screen A04, an input device A05 and a memory (not shown in the figure) connected via a system bus. The processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A06. The non-volatile storage medium A06 stores an operating system B01 and a computer program B02. The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A06. The network interface A02 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 A01, it implements a data table field query method of an http interface. The display screen A04 of the computer device can be a liquid crystal display or an electronic ink display, and the input device A05 of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse.

[0053] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the 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 component arrangement.

[0054] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0055] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0056] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0057] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.

[0058] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0059] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0060] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology for information storage. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.

[0061] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0062] The above are merely embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A data table field query method for an http interface, characterized in that: The method comprises: Get the query parameters of the specified data field; Create a form to be returned based on the preset structure list creation rules and the query parameters of the specified data field; wherein, The query parameters of the specified data field include: a key-value pair consisting of the name of the specified data field and the corresponding value; The form to be returned is defined as a struct data type; wherein the form to be returned includes multiple data field columns, and each data field column is defined as a member variable of the struct data; Each member variable is provided with a structure tag, the keys of which are json and column; json is used to describe the name of each data field in the entity string; column is used to describe the name of each data field in the data form; each member variable represents the mapping relationship between the name of a data field in the entity string and the name in the data form; Obtaining a data form of the API interface corresponding to the query request, querying the specified data field in the data form based on the query parameters of the specified data field and the form to be returned, and saving the query data to the form to be returned; wherein, Before querying the designated data field in the data form based on the query parameters of the designated data field and the form to be returned, the method further includes: verifying the designated data field in the data form based on the query parameters of the designated data field and the form to be returned; Based on the form to be returned after completing data storage, a string in json format is output, and a service response is performed based on the string in json format.

2. The method according to claim 1, characterized in that Based on the query parameters of the designated data field and the form to be returned, verifying the designated data field in the data form includes: According to the name of the specified data field in the entity string, according to the mapping relationship, obtain the name of the specified data field in the data form; Compare the name of the specified data field in the data form with the name of each data column in the data form of the corresponding API interface to determine whether there is a match; If there is no matching relationship, it is determined that the specified data field does not exist in the data form of the corresponding API interface, and it is determined that the verification of the specified data field fails; If there is a matching relationship, the verification success signal of the specified data field is output.

3. The method according to claim 2, characterized in that The query parameter based on the designated data field and the form to be returned, querying the designated data field in the data form, and saving the queryed data in the form to be returned, includes: In response to the verification success signal, concatenate the query parameters of the designated data field and the form to be returned to obtain query structure parameters; Based on the query structure parameters, query the specified data field in the data form to obtain the specific data value under the specified data field; Output the specific data value under the specified data field, and save the specific data value to the form to be returned.

4. The method according to claim 3, characterized in that The form to be returned based on the completed data storage outputs a string in json format, including: According to the preset json string serialization method, the data in the form to be returned after the data is saved is converted into the corresponding json format string.

5. A data table field query system based on http interface, characterized in that: The system comprises: The collection unit is used to obtain the query parameters of the specified data field and the data form of the corresponding API interface for the query request; wherein, The query parameters of the specified data field include: a key-value pair consisting of the name of the specified data field and the corresponding value; The form to be returned is defined as a struct data type; wherein the form to be returned includes multiple data field columns, and each data field column is defined as a member variable of the struct data; Each member variable is provided with a structure tag, the keys of which are json and column; json is used to describe the name of each data field in the entity string; column is used to describe the name of each data field in the data form; each member variable represents the mapping relationship between the name of a data field in the entity string and the name in the data form; A processing unit for: Create a form to be returned based on the preset structure list creation rules and the query parameters of the specified data fields; Based on the query parameters of the designated data field and the form to be returned, the designated data field is queried in the data form, and the data obtained from the query is saved in the form to be returned; before the designated data field is queried in the data form based on the query parameters of the designated data field and the form to be returned, the method further includes: verifying the designated data field in the data form based on the query parameters of the designated data field and the form to be returned; The output unit is used to output a string in json format based on the form to be returned after the data is saved; The execution unit is used to make a service response based on the string in the json format.

6. A machine-readable storage medium having instructions stored thereon, characterized in that: When the instruction is executed by a processor, the processor is configured to execute the data table field query method of the http interface according to any one of claims 1 to 4.

7. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the data table field query method of the http interface according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method and system for realizing acceleration interface data request

    CN110727615A

  • Method, device and equipment for operating relational database based on C language

    CN112015831A