Data query method and device, equipment and storage medium
By obtaining and utilizing the field mapping relationship set to obtain parameter values from the data query request and constructing query statements, the problem of many type conversion rules and high development costs in the query engine data query is solved, and the convenience and efficiency of data query are improved.
Patent Information
- Application Number
- CN202411689040.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-11
AI Technical Summary
When using the query engine to query data, type conversion rules need to be set for each query parameter, resulting in high development costs, high maintenance difficulty, and poor data query convenience.
By obtaining the data query request and the preset field mapping relationship set, obtaining the parameter value from the data query request based on the parameters of the field mapping relationship set, and constructing a query statement based on the obtained parameter value and the corresponding second parameter field.
Convert the query parameters in the data query request to the types supported by the query engine to improve the convenience and efficiency of data query.
Smart Images

Figure CN119597790A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of data processing technology, and in particular to a data query method, device, equipment and storage medium. Background Art
[0002] In the related art, when using a query engine (e.g., Elasticsearch) to query data, it is necessary to convert the query parameters in the query request into types supported by the query engine. Generally, a query request includes multiple query parameters, and it is necessary to set type conversion rules for each query parameter. When the query parameters in the query request increase, it is necessary to set new type conversion rules for the newly added query parameters. The development cost of this method is high, and it is also difficult to maintain, resulting in poor convenience of data query. Summary of the invention
[0003] The embodiments of the present invention provide a data query method, device, equipment and storage medium, which can improve the convenience and efficiency of data query.
[0004] In a first aspect, an embodiment of the present invention provides a data query method, including:
[0005] Obtaining a data query request and a preset field mapping relationship set; wherein the data query request includes at least one query parameter, each query parameter includes a first parameter field and a parameter value; the field mapping relationship set includes a mapping relationship between multiple second parameter fields and parameter acquisition fields;
[0006] Acquire a parameter value from the data query request based on a parameter acquisition field in the field mapping relationship set;
[0007] Construct a query statement based on the obtained parameter value and the corresponding second parameter field;
[0008] The target data is queried based on the query statement.
[0009] In a second aspect, an embodiment of the present invention further provides a data query device, including:
[0010] An acquisition module, used to acquire a data query request and a preset field mapping relationship set; wherein the data query request includes at least one query parameter, each query parameter includes a first parameter field and a parameter value; the field mapping relationship set includes a mapping relationship between multiple second parameter fields and parameter acquisition fields;
[0011] A parameter value acquisition module, used to acquire a parameter value from the data query request based on a parameter acquisition field in the field mapping relationship set;
[0012] A query statement building module, used to build a query statement according to the acquired parameter value and the corresponding second parameter field;
[0013] The target data query module is used to query the target data based on the query statement.
[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data query method described in the embodiment of the present invention.
[0018] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data query method described in the embodiment of the present invention when executed.
[0019] The embodiment of the present invention discloses a data query method, device, equipment and storage medium. Obtain a data query request and a preset field mapping relationship set; wherein the data query request includes at least one query parameter, each query parameter includes a first parameter field and a parameter value; the field mapping relationship set includes a mapping relationship between multiple second parameter fields and parameter acquisition fields; obtain parameter values from the data query request based on the parameter acquisition field in the field mapping relationship set; construct a query statement based on the obtained parameter value and the corresponding second parameter field; query target data based on the query statement. The data query method provided by the embodiment of the present invention obtains parameter values from the data query request based on the preset field mapping relationship set, and constructs a query statement based on the obtained parameter value and the corresponding second parameter field, which can uniformly convert query parameters in the data query request into types supported by the query engine, and can improve the convenience and efficiency of data query. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is a flow chart of a data query method in Embodiment 1 of the present invention;
[0021] Figure 2 It is a structural schematic diagram of a data query device in Embodiment 2 of the present invention;
[0022] Figure 3 It is a structural schematic diagram of an electronic device in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0023] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0024] Embodiment 1
[0025] Figure 1 This is a flow chart of a data query method provided in the first embodiment of the present invention. This embodiment is applicable to the case where data query is performed through a preset query engine. The method can be executed by a data query device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal, a PC or a server, etc. Specifically, it includes the following steps:
[0026] S110, obtaining a data query request and a preset field mapping relationship set.
[0027] Among them, the data query request includes at least one query parameter, each query parameter includes a first parameter field and a parameter value; the field mapping relationship set includes a mapping relationship between multiple second parameter fields and parameter acquisition fields. The data query request can be transmitted from the front end in the form of an http request, the first parameter field in the query parameter can be understood as the key field (key) of the query parameter, and the parameter value can be understood as the specific value of the query parameter. Exemplarily, it is assumed that the query parameter is expressed as: "name": "Zhang San", where "name" is the first parameter field and "Zhang San" is the parameter value. In this embodiment, the query parameters in the data query request are generated by the user based on the format of the front end, and the format may be incompatible with the query engine. In order to ensure the smooth execution of the data query, it is necessary to convert the format of the query parameters transmitted from the front end into the format supported by the query engine.
[0028] The second parameter field can be understood as a parameter field represented in a format supported by the query engine, and the parameter acquisition field is used to obtain the parameter value corresponding to the second parameter field from the query request. The field mapping relationship set can be pre-constructed based on the query engine's format requirements for query parameters, and can be identified in the form of a two-dimensional array, where each element in the array is a mapping relationship between a second parameter field and a parameter acquisition field. For example, a field mapping relationship set includes 12 elements, and the field mapping relationship set can be expressed as: {{"uid", "getUid"}, {"vin", "getVin"}, {"device_id", "getDeviceId"}, {"device_brand", "getDeviceBrand"}, {"device_model", "getDeviceModel"}, {"manufacturer_app_id", "getManufacturerAppId"}, {"trace_id", "getTraceId"}, {"session_id", "getSessionId"}, {"event_id", "getEventId"}, {"mark", "getMark"}, {"error_code", "getErrorCode"}, {"project", "getProject"}}. The first field of each element is the second parameter field, and the second field is the parameter acquisition field.
[0029] S120: Obtain parameter values from the data query request based on the parameter acquisition field in the field mapping relationship set.
[0030] In this embodiment, in order to prevent the query parameters in the data query request from being missed, it is necessary to obtain the parameter values from the data query request one by one according to the parameter acquisition fields in the field mapping relationship set. The method of obtaining the parameter value from the data query request according to the parameter acquisition field can be: first encapsulate the parameter acquisition field into a parameter acquisition function, and then call the parameter acquisition function to obtain the parameter value from the data query request.
[0031] Optionally, a method of obtaining a parameter value from a query request based on a parameter acquisition field in a field mapping relationship set may be: traversing the parameter acquisition fields in the field mapping relationship set, building a parameter acquisition function according to the traversed parameter acquisition fields; and obtaining the parameter value from the query request based on the parameter acquisition function.
[0032] The parameter acquisition fields can be traversed in sequence according to the storage order of the mapping relationship between the second parameter field and the parameter acquisition field in the array corresponding to the field mapping relationship set. The method of constructing the parameter acquisition function according to the parameter acquisition field can be: adding a function symbol after the parameter acquisition field, and the function symbol can be parentheses. Exemplarily, assuming that the parameter acquisition field is getUid, the constructed field acquisition function can be expressed as: getUid().
[0033] In this application scenario, query parameters are stored in the parameter object of the data query request. Each time a parameter acquisition field is traversed, a parameter acquisition function is constructed according to the parameter acquisition field, and then the parameter acquisition function is called under the parameter object to obtain the corresponding parameter value through the parameter acquisition function. If the corresponding parameter value is obtained according to the parameter acquisition function, it means that the data query request contains the parameter value to be obtained by the parameter acquisition function; if the corresponding parameter value is not obtained according to the parameter acquisition function, it means that the data query request does not contain the parameter value to be obtained by the parameter acquisition function.
[0034] In this embodiment, in order to ensure data security, after obtaining the parameter value, the legitimacy of the parameter value needs to be verified. Specifically, after obtaining the parameter value from the query request based on the parameter acquisition function, the following steps are also included: verifying the legitimacy of the obtained parameter value; if the obtained parameter value passes the legitimacy check, continue to traverse the next parameter acquisition field; if the obtained parameter value fails the legitimacy check, stop traversing the parameter acquisition fields in the field mapping relationship set, and generate a first error message to prompt the user that the legitimacy check of the query request has failed.
[0035] Among them, the legality check includes at least one of the following: null value check, abnormal character check and string length check. The null value check can be understood as checking whether the parameter value is null. If the parameter value is null, the legality check fails. The abnormal character check can be understood as checking whether there is an abnormal character string in the parameter value. If it contains an abnormal character string, the legality check fails. Exemplarily, for a parameter that can only contain numbers, if the parameter value contains letters or other symbols, the parameter value contains an abnormal character string. The string length check can be understood as checking whether the character string contained in the parameter value meets the length requirement of the parameter. If the length of the character string contained in the parameter value is greater than or equal to the required length, the legality check fails. Exemplarily, for a certain query parameter, the length of the parameter value is required to be only 11 bits. If the length of the parameter value of the query parameter in the data query request is 12, the legality check of the parameter value fails.
[0036] Specifically, if the legality verification of the obtained parameter value passes, continue to traverse the next parameter acquisition field to obtain the parameter value from the data query request according to the next traversed parameter acquisition field. If the legality verification of the obtained parameter value fails, stop traversing the parameter acquisition fields in the field mapping relationship set, that is, reject the execution of the data query request. And generate a first error message to prompt the user that the legality verification of the query request fails.
[0037] Among them, the first error message carries the query parameter that fails the verification, so that the user can correct the query parameter that fails the verification according to the first error message.
[0038] S130, construct a query statement according to the obtained parameter value and the corresponding second parameter field.
[0039] In this embodiment, after traversing the field mapping relationship set, the parameter values of each query parameter in the data query request can be extracted, and the extracted parameter values are combined with their corresponding second parameter values to obtain a query statement.
[0040] Specifically, the method of constructing a query statement according to the obtained parameter value and the corresponding second parameter field can be: construct query sub-statements according to the obtained parameter value and the corresponding second parameter field to obtain multiple query sub-statements; connect the multiple query sub-statements with a preset connection symbol to obtain a query statement.
[0041] Among them, the second parameter field corresponding to the obtained parameter value is the second parameter field corresponding to the parameter acquisition field for obtaining the parameter value. The method of constructing a query sub-statement according to the obtained parameter value and the corresponding second parameter field can be: connect the obtained parameter value and the corresponding second parameter field with a preset symbol to obtain a query sub-statement. Among them, the preset symbol can be a colon. Exemplarily, assume that the obtained parameter value is "12" and its corresponding second parameter field is "uid", then the query sub-statement can be expressed as: uid = 12.
[0042] Among them, the preset connection symbol can be "and". Exemplarily, assume that the two query sub-statements are respectively: "uid:12" and "user-name:Zhang San", then the generated query statement is (uid:12) and (user-name:Zhang San).
[0043] In this embodiment, after traversing the parameter acquisition fields in the field mapping relationship set, it is also necessary to perform a legality verification on the data query request to verify whether the data query request contains query parameters that are not supported by the query engine.
[0044] Specifically, after obtaining multiple query sub-statements, the following steps are also included: performing a validity check on the data query request based on multiple query sub-statements; if the validity check of the query request passes, continuing to execute the operation of querying the target data based on the query statement; if the validity check of the query request fails, generating a second error message to prompt the user that the validity check of the query request fails.
[0045] In this embodiment, the purpose of performing a validity check on a data query request based on multiple query sub-statements is to check whether there are query parameters in the data query request that are not supported by the search engine, that is, whether there are parameter values that are not extracted by traversing the field mapping relationship set. If there are unextracted parameter values, it indicates that the query parameter where the parameter value is located is illegal.
[0046] Optionally, the method of performing a validity check on a query request based on multiple query sub-statements may be: determining whether the number of query sub-statements is the same as the number of query parameters included in the data query request; if the number of query sub-statements is the same as the number of query parameters included in the data query request, the validity check of the query request passes; if the number of query sub-statements is different from the number of query parameters included in the data query request, the validity check of the query request fails.
[0047] The difference between the number of query sub-statements and the number of query parameters included in the data query request can be understood as the number of query sub-statements being less than the number of query parameters included in the data query request, which indicates that there are parameter values in the data query request that have not been extracted by traversing the field mapping relationship set, indicating that the query parameter where the parameter value is located is illegal, that is, the data query request is illegal. If the number of query sub-statements is the same as the number of query parameters included in the data query request, it indicates that all parameter values in the data query request have been extracted, and there are no illegal query parameters, that is, the data query request is legal.
[0048] Optionally, the second error message may be generated by: extracting query parameters corresponding to parameter values that do not constitute a query sub-statement from the query request to obtain illegal query parameters; and generating the second error message based on the illegal query parameters.
[0049] The second error message includes an illegal query parameter, so as to prompt the user to correct the illegal query parameter.
[0050] S140, querying target data based on the query statement.
[0051] Specifically, after obtaining the query statement, the query statement is sent to the search engine, so that the search engine searches for target data based on the query statement and returns the data to the client.
[0052] The technical solution of this embodiment is to obtain a data query request and a preset field mapping relationship set; wherein the data query request includes at least one query parameter, each query parameter includes a first parameter field and a parameter value; the field mapping relationship set includes a mapping relationship between multiple second parameter fields and parameter acquisition fields; the parameter value is obtained from the data query request based on the parameter acquisition field in the field mapping relationship set; a query statement is constructed based on the obtained parameter value and the corresponding second parameter field; and the target data is queried based on the query statement. The data query method provided by the embodiment of the present invention obtains parameter values from the data query request based on a preset field mapping relationship set, and constructs a query statement based on the obtained parameter value and the corresponding second parameter field, which can uniformly convert the query parameters in the data query request into types supported by the query engine, and can improve the convenience and efficiency of data query.
[0053] Embodiment 2
[0054] Figure 2 is a schematic diagram of the structure of a data query device provided by Embodiment 2 of the present invention. Figure 2 As shown, the device comprises:
[0055] The acquisition module 210 is used to acquire a data query request and a preset field mapping relationship set; wherein the data query request includes at least one query parameter, each query parameter includes a first parameter field and a parameter value; the field mapping relationship set includes a mapping relationship between multiple second parameter fields and parameter acquisition fields;
[0056] A parameter value acquisition module 220, configured to acquire a parameter value from a data query request based on a parameter acquisition field in a field mapping relationship set;
[0057] A query statement building module 230, configured to build a query statement according to the acquired parameter value and the corresponding second parameter field;
[0058] The target data query module 240 is used to query the target data based on the query statement.
[0059] Optionally, the parameter value acquisition module 220 is further used to:
[0060] Traverse the parameter acquisition fields in the field mapping relationship set, and build a parameter acquisition function based on the traversed parameter acquisition fields;
[0061] Get parameter values from the query request based on the parameter acquisition function.
[0062] Optionally, the method further includes: a first verification module, configured to:
[0063] Perform a validity check on the obtained parameter value; wherein the validity check includes at least one of the following: null value check, abnormal character check, and string length check;
[0064] If the obtained parameter value passes the legality check, continue to traverse the next parameter to obtain the field;
[0065] If the obtained parameter value fails the validity check, the traversal of the parameter acquisition fields in the field mapping relationship set is stopped, and a first error message is generated to prompt the user that the validity check of the query request fails.
[0066] Optionally, the query statement building module 230 is further used to:
[0067] Constructing a query sub-statement according to the acquired parameter value and the corresponding second parameter field to obtain multiple query sub-statements; wherein the second parameter field corresponding to the acquired parameter value is the second parameter field corresponding to the parameter acquisition field used to acquire the parameter value;
[0068] Connect multiple query sub-statements through preset connectors to obtain a query statement.
[0069] Optionally, the method further includes: a second verification module, configured to:
[0070] Perform legality verification on data query requests based on multiple query sub-statements;
[0071] If the query request passes the validity check, the operation of querying the target data based on the query statement will continue;
[0072] If the query request fails to pass the validity check, a second error message is generated to prompt the user that the query request fails to pass the validity check.
[0073] Optionally, the second verification module is further used to:
[0074] Determine whether the number of query sub-statements is the same as the number of query parameters included in the data query request;
[0075] If the number of query sub-statements is the same as the number of query parameters contained in the data query request, the query request passes the validity check;
[0076] If the number of query sub-statements is different from the number of query parameters included in the data query request, the validity check of the query request fails.
[0077] Optionally, the second verification module is further used to:
[0078] Extracting query parameters corresponding to parameter values that do not constitute a query substatement from the query request to obtain illegal query parameters;
[0079] A second error message is generated based on the illegal query parameter.
[0080] The above device can execute the methods provided by all the above embodiments of the present invention, and has the corresponding functional modules and beneficial effects of executing the above methods. For technical details not described in detail in this embodiment, please refer to the methods provided by all the above embodiments of the present invention.
[0081] Embodiment 3
[0082] Figure 3 A schematic diagram of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, the connections and relationships between the components, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0083] like Figure 3 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0084] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0085] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a data query method.
[0086] In some embodiments, the data query method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the data query method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the data query method in any other appropriate manner (e.g., by means of firmware).
[0087] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0088] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0089] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0090] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0091] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0092] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0093] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0094] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A data query method, characterized in that: include: Obtaining a data query request and a preset field mapping relationship set; wherein the data query request includes at least one query parameter, each query parameter includes a first parameter field and a parameter value; the field mapping relationship set includes a mapping relationship between multiple second parameter fields and parameter acquisition fields; Acquire a parameter value from the data query request based on a parameter acquisition field in the field mapping relationship set; Construct a query statement based on the obtained parameter value and the corresponding second parameter field; The target data is queried based on the query statement.
2. The method according to claim 1, characterized in that Acquiring a parameter value from the query request based on the parameter acquisition field in the field mapping relationship set includes: Traversing the parameter acquisition fields in the field mapping relationship set, and constructing a parameter acquisition function according to the traversed parameter acquisition fields; A parameter value is obtained from the query request based on the parameter obtaining function.
3. The method according to claim 2, characterized in that After obtaining the parameter value from the query request based on the parameter obtaining function, the method further includes: Performing a validity check on the obtained parameter value; wherein the validity check includes at least one of the following: a null value check, an abnormal character check, and a string length check; If the obtained parameter value passes the legality check, continue to traverse the next parameter to obtain the field; If the obtained parameter value fails the validity check, the traversal of the parameter acquisition fields in the field mapping relationship set is stopped, and a first error message is generated to prompt the user that the query request fails the validity check.
4. The method according to claim 2, characterized in that: Construct a query statement based on the obtained parameter value and the corresponding second parameter field, including: Constructing a query sub-statement according to the acquired parameter value and the corresponding second parameter field to obtain multiple query sub-statements; wherein the second parameter field corresponding to the acquired parameter value is the second parameter field corresponding to the parameter acquisition field used to acquire the parameter value; Connect multiple query sub-statements through preset connectors to obtain a query statement.
5. The method according to claim 4, characterized in that After obtaining multiple query sub-statements, it also includes: Performing a validity check on the data query request based on the multiple query sub-statements; If the query request passes the legality check, continue to execute the operation of querying the target data based on the query statement; If the query request fails to pass the validity check, a second error message is generated to prompt the user that the query request fails to pass the validity check.
6. The method according to claim 5, characterized in that Performing a validity check on the query request based on the multiple query sub-statements includes: Determining whether the number of the query sub-statements is the same as the number of query parameters included in the data query request; If the number of the query sub-statements is the same as the number of query parameters included in the data query request, the validity check of the query request passes; If the number of the query sub-statements is different from the number of query parameters included in the data query request, the validity check of the query request fails.
7. The method according to claim 5, characterized in that A second error message is generated, including: Extracting query parameters corresponding to parameter values that do not constitute a query sub-statement from the query request to obtain illegal query parameters; A second error message is generated based on the illegal query parameter.
8. A data query device, characterized in that: include: An acquisition module, used to acquire a data query request and a preset field mapping relationship set; wherein the data query request includes at least one query parameter, each query parameter includes a first parameter field and a parameter value; the field mapping relationship set includes a mapping relationship between multiple second parameter fields and parameter acquisition fields; A parameter value acquisition module, used to acquire a parameter value from the data query request based on a parameter acquisition field in the field mapping relationship set; A query statement building module, used to build a query statement according to the acquired parameter value and the corresponding second parameter field; The target data query module is used to query the target data based on the query statement.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data query method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data query method according to any one of claims 1 to 7 when executed.