Data query method and apparatus
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING PACTERA JINXIN TECH LTD
- Filing Date
- 2024-11-28
- Publication Date
- 2026-08-07
AI Technical Summary
[0003]相关技术中,基于编写数据查询接口代码实现数据查询,然而,传统的数据查询接口的设计通常基于特定的查询场景,导致请求体高度定制化,灵活性较差,无法适应多变的业务需求,并且这种设计方法在面对不断变化的业务需求和多团队协作开发时,可能导致代码治理难度增加,甚至变得不可控,降低了数据查询效率
[0011] In this technical solution, a data query request is received from a client, including data query conditions. Based on these conditions, target business code adapted to the target business scenario of the data query request is encapsulated to obtain a data query object. The data query object is then invoked to query target data matching the data query conditions from the target data model. Finally, a data query response carrying the target data is sent to the client. This process of encapsulating the target business code based on the data query conditions to obtain the data query object separates the processing of query conditions from the data access logic, reducing the coupling between the business logic layer and the data access layer. This allows for changes in business requirements without requiring modifications to a large amount of hard-coded query logic, reducing maintenance costs and improving query efficiency. Specifically, the query condition object, query configuration information, and target business code are combined to generate the data query object. The query configuration information defines the query scope, query fields and aliases, query field operators, etc., ensuring that the query is only performed within the specified data model and avoiding cross-model errors. The query configuration information dynamically generates query logic, ensuring the legality and validity of the query conditions and improving the flexibility of data queries.
Smart Images

Figure CN119576990B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing technology, and in particular to a data query method and apparatus. Background Technology
[0002] In the financial industry, data querying is a crucial component of business operations and decision support. Financial institutions need to efficiently and accurately process a large number of data query requests to support various business needs such as risk management, transaction monitoring, customer management, and report generation.
[0003] In related technologies, data queries are implemented by writing data query interface code. However, the design of traditional data query interfaces is usually based on specific query scenarios, resulting in highly customized request bodies, poor flexibility, and inability to adapt to changing business needs. Furthermore, this design approach may increase the difficulty of code governance or even become uncontrollable when facing constantly changing business needs and multi-team collaborative development, thus reducing data query efficiency. Summary of the Invention
[0004] This disclosure provides a data query method and apparatus to at least partially solve one of the technical problems in the related art. The technical solution of this disclosure is as follows:
[0005] According to a first aspect of the present disclosure, a data query method is provided, comprising: receiving a data query request sent by a client; wherein the data query request includes data query conditions; based on the data query conditions, encapsulating target business code adapted to the target business scenario to which the data query request belongs, to obtain a data query object; invoking the data query object to query target data matching the data query conditions from a target data model; and sending a data query response carrying the target data to the client.
[0006] According to a second aspect of the present disclosure, a data query apparatus is provided, comprising: a receiving module for receiving a data query request sent by a client; wherein the data query request includes data query conditions; an encapsulation module for encapsulating target business code adapted to the target business scenario to which the data query request belongs, based on the data query conditions, to obtain a data query object; an invocation module for invoking the data query object to query target data matching the data query conditions from a target data model; and a sending module for sending a data query response carrying the target data to the client.
[0007] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the data query method as described in the first aspect of the present disclosure.
[0008] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided that, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform a data query method as described in the first aspect of the present disclosure.
[0009] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising: a computer program that, when executed by a processor, implements the data query method as described in the first aspect of the present disclosure.
[0010] The technical solutions provided by the embodiments of this disclosure have at least the following beneficial effects:
[0011] In this technical solution, a data query request is received from a client, including data query conditions. Based on these conditions, target business code adapted to the target business scenario of the data query request is encapsulated to obtain a data query object. The data query object is then invoked to query target data matching the data query conditions from the target data model. Finally, a data query response carrying the target data is sent to the client. This process of encapsulating the target business code based on the data query conditions to obtain the data query object separates the processing of query conditions from the data access logic, reducing the coupling between the business logic layer and the data access layer. This allows for changes in business requirements without requiring modifications to a large amount of hard-coded query logic, reducing maintenance costs and improving query efficiency. Specifically, the query condition object, query configuration information, and target business code are combined to generate the data query object. The query configuration information defines the query scope, query fields and aliases, query field operators, etc., ensuring that the query is only performed within the specified data model and avoiding cross-model errors. The query configuration information dynamically generates query logic, ensuring the legality and validity of the query conditions and improving the flexibility of data queries.
[0012] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0013] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0014] Figure 1 This is a flowchart illustrating the data query method shown in the first embodiment of this disclosure;
[0015] Figure 2 This is a flowchart illustrating the data query method shown in the second embodiment of this disclosure;
[0016] Figure 3 This is a flowchart illustrating the data query method shown in the third embodiment of this disclosure;
[0017] Figure 4 This is a schematic flowchart of the data query method shown in the fourth embodiment of this disclosure;
[0018] Figure 5 This is a schematic diagram illustrating the principle of the data query method shown in the embodiments of this disclosure;
[0019] Figure 6 This is a schematic diagram of the structure of the data query device shown in the fifth embodiment of this disclosure;
[0020] Figure 7 This is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of the present disclosure. Detailed Implementation
[0021] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0022] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0023] It should be noted that the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in the technical solution disclosed herein are all carried out with the consent of the user, and all comply with the provisions of relevant laws and regulations, and do not violate public order and good morals.
[0024] The risk assessment method and apparatus of embodiments of this disclosure are described below with reference to the accompanying drawings.
[0025] Figure 1 This is a flowchart illustrating the data query method shown in the first embodiment of this disclosure.
[0026] like Figure 1 As shown, this data query method includes the following steps:
[0027] Step 101: Receive the data query request sent by the client.
[0028] The data query request includes data query conditions.
[0029] In this embodiment, the client can be a front-end application, a mobile application, or other back-end services. The data query request sent by the client can be an HTTP request, and the request body contains the conditions required for the query (e.g., time range, transaction type, etc.). The request body can include various types of request information, such as JSON objects, sorting requests, and pagination requests. The JSON object contains the main query conditions and parameters, the sorting request indicates the sorting method of the query results specified by the client, and the pagination request indicates the pagination information of the query results specified by the client.
[0030] Step 102: Based on the data query conditions, encapsulate the target business code that is compatible with the target business scenario to which the data query request belongs, and obtain the data query object.
[0031] To improve the flexibility of data queries, one possible approach is to separate the processing of query conditions from the data access logic, thereby reducing the coupling between the business logic layer and the data access layer.
[0032] In this embodiment, query conditions are extracted from the data query request sent by the client. Based on these conditions, a business scenario is determined. Different business scenarios correspond to different query logic. The query conditions and query logic are encapsulated in a data query object, resulting in the data query object. Therefore, when business requirements change, only the parts related to the query conditions need to be modified, without needing to modify the query logic, thus reducing code maintenance costs. The business scenarios include single-table queries or table join queries.
[0033] Step 103: Call the data query object to query the target data that matches the data query conditions from the target data model.
[0034] It is important to understand that the encapsulated data query object contains query conditions and query logic, and can be called as an independent unit. Therefore, by calling the data query object, the target data that matches the data query conditions can be retrieved from the target data model.
[0035] Step 104: Send the data query response carrying the target data to the client.
[0036] Furthermore, a data query response is generated based on the target data and sent to the client.
[0037] It should be noted that when the target data is not found, a query failure response and / or prompt message are sent to the client. The query failure response indicates that the query failed, and the prompt message indicates that the data query conditions should be re-entered.
[0038] In summary, by encapsulating the target business code based on data query conditions to obtain a data query object, the processing of query conditions and data access logic are separated, reducing the coupling between the business logic layer and the data access layer. This allows for changes in business scenarios without requiring modifications to a large amount of hard-coded query logic, reducing maintenance costs and improving query efficiency.
[0039] To clearly illustrate how the above embodiments encapsulate business code adapted to the business scenario to which the data query request belongs based on data query conditions to obtain the data query object, this disclosure proposes another data query method.
[0040] Figure 2 This is a flowchart illustrating the data query method shown in the second embodiment of this disclosure.
[0041] like Figure 2 As shown, this data query method includes the following steps:
[0042] Step 201: Receive the data query request sent by the client.
[0043] The data query request includes data query conditions.
[0044] Step 202: Determine the query condition object to carry the data query conditions based on the data query conditions.
[0045] To ensure the structured and standardized nature of query conditions, in this embodiment of the disclosure, an object is created to carry the data query conditions, namely a query condition object. For example, a query condition object AggregationQuery is created to carry the data query conditions; wherein the query condition object AggregationQuery encapsulates the data query conditions.
[0046] Step 203: Encapsulate the target business code based on the query condition object to obtain the data query object.
[0047] To improve the flexibility and configurability of data queries, while enhancing code maintainability and scalability, one possible approach is to combine query condition objects, query configuration information, and target business code to generate a data query object. This data query object is responsible for receiving the query condition objects and query configuration information, and calling the target business code to execute specific query operations. The query configuration information is used to define the query scope, query fields and query field aliases, query field operators, etc.
[0048] In this embodiment of the disclosure, query configuration information associated with the target data model is obtained from the local cache; based on the query condition object and the query configuration information, the target business code is encapsulated to obtain a data query object.
[0049] The query configuration information includes: model isolation scope adapted to the target data model and query field information. The query field information includes at least one of the following: the query field, its query field alias, and the query scope. The model isolation scope defines the data model involved in the query and its scope. This ensures that the query is only performed within a specific data model, avoiding accidental cross-model operations. The query field defines the specific fields used in the query, and the query field alias defines alternative names for the query field. Query field aliases can help hide or obscure the original field names, helping to protect sensitive data information.
[0050] In addition, it should be noted that, in order to improve data security, different query fields correspond to different operators. For example, if the query field is "name", the operators corresponding to "name" include: equal to, not equal to, and fuzzy matching. If the query field is "age", the operators corresponding to "age" include: equal to, greater than, less than, greater than or equal to, less than or equal to, etc.
[0051] Step 204: Invoke the data query object to query the target data that matches the data query conditions from the target data model.
[0052] To reduce the complexity of data queries, as an example, we can directly call the data query object to retrieve target data that matches the data query conditions from the target data model.
[0053] Step 205: Send the data query response carrying the target data to the client.
[0054] In summary, by determining the query condition object to carry the data query conditions based on the data query conditions, and encapsulating the target business code based on the query condition object to obtain the data query object, the data query object is called to query the target data that matches the data query conditions from the target data model. This achieves the separation of query conditions from business code, which facilitates the management and reuse of business code, improves the flexibility of data query, and allows for rapid response to different data needs by dynamically constructing and executing queries, thereby improving data query efficiency.
[0055] To define the data query scope and fields, in this embodiment of the disclosure, query configuration information is obtained from the cache, thereby obtaining the data query object based on the query configuration information. The query configuration information may include model isolation scope and query field information adapted to the target data model. The query configuration information can be generated based on the model isolation scope and query field information adapted to the target data model. The following describes the process in conjunction with... Figure 3 The embodiments are described in detail.
[0056] Figure 3 This is a flowchart illustrating the data query method shown in the third embodiment of this disclosure.
[0057] like Figure 3 As shown, the generation of query configuration information includes the following steps:
[0058] Step 301: Obtain the model isolation range and query field information that are compatible with the target data model.
[0059] The query field information includes at least one of the following: the query field, the query field alias, and the query range.
[0060] In this embodiment of the disclosure, the model isolation range, query fields, query field aliases, and query operator range set by the relevant developers on the target data model are obtained.
[0061] The specific steps for setting the model isolation range, query fields, query field aliases, and query operator range on the target data model are as follows:
[0062] 1. Obtain the target data model that matches the data tables in the database;
[0063] It's important to understand that when each data table in a database is an independent data table, one data table can correspond to one target data model. When there are relationships between multiple data tables in a database, multiple data tables can correspond to the same target data model.
[0064] 2. In response to field configuration operations, configure the query fields of the target data model to obtain the query fields of the target data model;
[0065] The query fields include: user ID, order ID, user's age, etc.
[0066] 3. In response to the model configuration operation, configure the isolation range of the target data model to obtain the model isolation range of the target data model;
[0067] The model isolation scope can be set in the following way: For some common fields, such as primary key ID, creation time, creator, modifier, etc., if it is necessary to limit its use to a data model, it is necessary to use @FilterScope on that data model to limit it.
[0068] 4. In response to the query configuration operation, configure the query information for the query fields and obtain the query information for the query fields.
[0069] The query information includes: the alias of the query field and the query range.
[0070] Step 302: Generate query configuration information based on the model isolation range and query field information.
[0071] In this embodiment of the disclosure, the model isolation range and query field information are combined to generate query configuration information.
[0072] In summary, by obtaining the model isolation range and query field information that are compatible with the target data model, and generating query configuration information based on the model isolation range and query field information, we can ensure that queries are only performed within the specified data model range, thus avoiding cross-model errors. By dynamically generating query logic through the query configuration information, we can ensure the legality and validity of query conditions.
[0073] Based on any of the above embodiments, and based on data query conditions, the target business code adapted to the target business scenario to which the data query request belongs is encapsulated to obtain a data query object, wherein, for example... Figure 4 As shown, the target business code is generated using the following steps:
[0074] Step 401: Parse the data query request to obtain the target request parameters.
[0075] As an example, key information is extracted and identified from the query request, including the data table, fields, conditions, sorting method, etc., which are collectively referred to as target request parameters.
[0076] Step 402: Determine the target business scenario to which the data query request belongs based on the target request parameters.
[0077] In this embodiment of the disclosure, by analyzing the specific information in the request parameters, such as the data table, fields, and conditions to be queried, and combining the business logic and actual needs, the business scenario corresponding to the data query request is determined, and the business scenario corresponding to the data query request is taken as the target business scenario.
[0078] Step 403: From multiple candidate business codes, determine the target business code that is compatible with the target business scenario.
[0079] It should be noted that, in order to improve the efficiency and flexibility of queries, business codes are dynamically generated according to business scenarios. Different business scenarios correspond to different business codes, and each business scenario corresponds to a candidate business code. Therefore, the target business code that is compatible with the target business scenario is selected from multiple candidate business codes.
[0080] The method for determining candidate business codes is as follows:
[0081] 1. Obtain multiple candidate business scenarios associated with the target data model.
[0082] 2. For any candidate business scenario, in response to the code editing operation, generate candidate business code that matches any candidate business scenario.
[0083] As an example, in response to any business scenario involving a single-table query, and in response to code configuration operations, business code containing a single-table query interface is generated; wherein, the single-table query interface code is used to query data models that do not have any relationships.
[0084] In other words, when the business scenario requires querying a single data table, in response to the code configuration operation, business code is generated that contains a single-table query interface code for querying data models that do not have any relationships.
[0085] As another example, in response to any business scenario query for a table join model, and in response to code configuration operations, business code generates high-level query interface code; whereby the high-level query interface code is used to query multiple data models with related relationships.
[0086] In other words, when a business scenario requires querying multiple related data tables, business code containing high-level query interface code is generated in response to the code configuration operation.
[0087] In summary, by parsing data query requests to obtain target request parameters, determining the target business scenario associated with the data query request based on these parameters, and selecting the target business code that matches the target business scenario from multiple candidate business codes, various query needs can be flexibly addressed through parsing request parameters and determining the business scenario. This eliminates the need to write fixed code for each query scenario, improving the adaptability and scalability of data queries. Furthermore, by selecting the appropriate target business code from multiple candidate business codes, the query logic adapted to the target business scenario can be quickly located and executed, reducing unnecessary computation and resource consumption and improving query efficiency.
[0088] Based on any of the above embodiments, such as Figure 5 As shown, the data query method of this disclosure embodiment is implemented based on the following steps:
[0089] Step 1: Define model fields / Set filter field aliases
[0090] Developers set filtering configurations on model fields according to filtering requirements, including aliases, operator ranges, and original field names;
[0091] Step 2: Set the model isolation range
[0092] For some common fields, such as primary key ID, creation time, modification time, creator, and modifier, which are shared by all models, if you need to use them on a single model, you need to mark the model with @FilterScope and then mark the filter field with the scope attribute on the filter request.
[0093] Step 3: Configure the chained API call code (candidate business code)
[0094] In this embodiment of the disclosure, the chained interface call code includes single-table query interface code and high-order query interface code. The single-table query interface code is used to query data models that do not have any relationship, and the high-order query interface code is used to query multiple data models that have a relationship.
[0095] Step 4: Automatically scan the alias fields on the model to generate filter configurations (query configuration information).
[0096] Scan all @FilterField fields, model entity classes, and @Scope information on all models and store them in the local cache to form query configuration information.
[0097] Step 5: Parse the data query request
[0098] Upon receiving a data query request from a client, the system parses the data query conditions in the request. Based on these conditions, it determines the AggregationQuery object to carry the query conditions. It then retrieves the query configuration information associated with the target data model from the local cache. In other words, based on the AggregationQuery object, the main table model, the associated table model, and the declarations of the main table fields and associated table fields, the system dynamically parses and generates the query configurations for the main table and associated tables, and checks whether the operators of the query fields are within the scope of field operators on the model.
[0099] Step 6: Encapsulate the data query object
[0100] Based on the query condition object and query configuration information, the target business code is encapsulated to obtain the data query object. In other words, according to the query configuration of the dynamically parsed main table model and related table model, the data query object (QueryWrapper) is dynamically generated, and the data query object can be directly used for querying.
[0101] Corresponding to the data query method provided in the above embodiments, this disclosure also provides a data query device. Since the data query device provided in this disclosure corresponds to the data query method provided in the above embodiments, the implementation of the data query method is also applicable to the data query device provided in this disclosure, and will not be described in detail in this disclosure.
[0102] Figure 6 This is a schematic diagram of the structure of the data query device shown in the fifth embodiment of this disclosure.
[0103] like Figure 6 As shown, the data query device 600 includes: a receiving module 610, an encapsulation module 620, a calling module 630, and a sending module 640.
[0104] The receiving module 610 is used to receive a data query request sent by the client, wherein the data query request includes data query conditions; the encapsulation module 620 is used to encapsulate the target business code adapted to the target business scenario to which the data query request belongs based on the data query conditions, thereby obtaining a data query object; the calling module 630 is used to call the data query object to query the target data matching the data query conditions from the target data model; and the sending module 640 is used to send the data query response carrying the target data to the client.
[0105] As one possible implementation of this disclosure, the encapsulation module 620 is used to determine a query condition object to carry the data query conditions based on the data query conditions; and to encapsulate the target business code based on the query condition object to obtain a data query object.
[0106] As one possible implementation of this disclosure, the encapsulation module 620 is used to obtain query configuration information associated with the target data model from the local cache; and to encapsulate the target business code based on the query condition object and the query configuration information to obtain a data query object.
[0107] As one possible implementation of this disclosure, the configuration information is generated using the following modules: a first acquisition module and a first generation module.
[0108] The first acquisition module is used to acquire model isolation range and query field information that are compatible with the target data model; wherein the query field information includes at least one of the following: query field, query field alias of the query field, and query range; the generation module is used to generate the query configuration information based on the model isolation range and the query field information.
[0109] As one possible implementation of this disclosure, the target business code is determined using the following modules: a parsing module and a determining module.
[0110] The parsing module is used to parse the data query request to obtain the target request parameters; the determination module is used to determine the target business scenario to which the data query request belongs based on the target request parameters; and to determine the target business code that is compatible with the target business scenario from multiple candidate business codes.
[0111] As one possible implementation of this disclosure, the candidate service code is determined using the following modules: a second acquisition module and a second generation module.
[0112] The second acquisition module is used to acquire multiple candidate business scenarios associated with the target data model; the second generation module is used to generate candidate business code that matches any candidate business scenario in response to a code editing operation.
[0113] As one possible implementation of this disclosure, the second generation module is configured to generate business code containing single-table query interface code in response to any business scenario being a single-table query and in response to a code configuration operation; wherein the single-table query interface code is used to query data models that do not have any related relationships; and to generate business code containing higher-order query interface code in response to any business scenario being a table join model query and in response to a code configuration operation; wherein the higher-order query interface code is used to query multiple data models that have related relationships.
[0114] As one possible implementation of this disclosure, the data query device 600 further includes a configuration module.
[0115] The configuration module is used to obtain the target data model that is compatible with the data tables in the database; in response to field configuration operations, it configures the query fields of the target data model to obtain the query fields of the target data model; in response to model configuration operations, it configures the isolation range of the target data model to obtain the model isolation range of the target data model; in response to query configuration operations, it configures the query information of the query fields to obtain the query information of the query fields; wherein, the query information includes: the query field alias and query range of the query fields.
[0116] As one possible implementation of this disclosure, the sending module 640 is further configured to send a query failure response and / or prompt information to the client in response to the failure to find the target data; wherein the query failure response is used to indicate that the query failed, and the prompt information is used to indicate that the data query conditions should be re-entered.
[0117] The data query device of this embodiment receives a data query request sent by a client, wherein the data query request includes data query conditions; based on the data query conditions, it encapsulates the target business code adapted to the target business scenario to which the data query request belongs to obtain a data query object; it calls the data query object to query target data matching the data query conditions from the target data model; and it sends a data query response carrying the target data to the client. Thus, by encapsulating the target business code based on the data query conditions to obtain a data query object, it separates the processing of query conditions from the data access logic, reduces the coupling between the business logic layer and the data access layer, and enables the use of the data query object without modifying a large amount of hard-coded query logic when business requirements change, thereby reducing maintenance costs and improving query efficiency.
[0118] In an exemplary embodiment, an electronic device is also proposed.
[0119] The electronic devices include:
[0120] processor;
[0121] Memory used to store processor-executable instructions;
[0122] The processor is configured to execute instructions to implement the data query method as proposed in any of the foregoing embodiments.
[0123] As an example, Figure 7 This is a schematic diagram of the structure of an electronic device 700 as shown in an exemplary embodiment of this disclosure, as follows: Figure 7 As shown, the aforementioned electronic device 700 may further include:
[0124] The system includes a memory 710 and a processor 720, and a bus 730 connecting different components (including the memory 710 and the processor 720). The memory 710 stores a computer program, and when the processor 720 executes the program, it implements the data query method described in the embodiments of this disclosure.
[0125] Bus 730 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0126] Electronic device 700 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by electronic device 700, including volatile and non-volatile media, removable and non-removable media.
[0127] The memory 710 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 740 and / or cache memory 750. The server 700 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 760 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 7 Not shown; usually referred to as a "hard drive"). Although Figure 7 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 730 via one or more data media interfaces. Memory 710 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this disclosure.
[0128] A program / utility 780 having a set (at least one) of program modules 770 may be stored in, for example, memory 710. Such program modules 770 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 770 typically perform the functions and / or methods described in the embodiments of this disclosure.
[0129] Electronic device 700 can also communicate with one or more external devices 790 (e.g., keyboard, pointing device, display 791, etc.), and with one or more devices that enable a user to interact with electronic device 700, and / or with any device that enables electronic device 700 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 792. Furthermore, electronic device 700 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 793. As shown, network adapter 793 communicates with other modules of electronic device 700 via bus 730. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0130] The processor 720 executes various functional applications and data processing by running programs stored in the memory 710.
[0131] It should be noted that the implementation process and technical principles of the electronic device in this embodiment are explained in the foregoing description of the data query method of this disclosure embodiment, and will not be repeated here.
[0132] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, which can be executed by a processor of an electronic device to perform the data query method proposed in any of the above embodiments. Optionally, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0133] In an exemplary embodiment, a computer program product is also provided, including a computer program / instructions, characterized in that the computer program / instructions, when executed by a processor, implement the data query method proposed in any of the above embodiments.
[0134] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0135] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A data query method, characterized in that, include: Receive a data query request sent by a client; wherein the data query request includes data query conditions; Based on the data query conditions, determine the query condition object to carry the data query conditions; obtain the query configuration information associated with the target data model from the local cache; based on the query condition object and the query configuration information, encapsulate the target business code to obtain the data query object; Invoke the data query object to query target data from the target data model that matches the data query conditions; The data query response carrying the target data is sent to the client.
2. The method according to claim 1, characterized in that, The query configuration information is generated using the following steps: Obtain the model isolation range and query field information that are adapted to the target data model; wherein, the query field information includes at least one of the following: query field, query field alias of the query field, and query range; The query configuration information is generated based on the model isolation range and the query field information.
3. The method according to claim 1, characterized in that, The target business code is determined using the following steps: The data query request is parsed to obtain the target request parameters; Based on the target request parameters, determine the target business scenario to which the data query request belongs; From multiple candidate business codes, determine the target business code that is compatible with the target business scenario.
4. The method according to claim 3, characterized in that, The candidate service codes are determined using the following steps: Obtain multiple candidate business scenarios associated with the target data model; For any candidate business scenario, in response to the code editing operation, candidate business code matching the candidate business scenario is generated.
5. The method according to claim 4, characterized in that, For any candidate business scenario, in response to a code editing operation, generating candidate business code that matches the candidate business scenario includes: In response to any of the candidate business scenarios being a single-table query, and in response to the code configuration operation, business code containing single-table query interface code is generated; wherein, the single-table query interface code is used to query data models that do not have any relationships. In response to any of the candidate business scenarios being a table join model query, and in response to the code configuration operation, business code that generates a high-level query interface is generated; wherein, the high-level query interface code is used to query multiple data models with related relationships.
6. The method according to claim 1, characterized in that, The method further includes: Obtain the target data model that matches the data tables in the database; In response to the field configuration operation, the query fields of the target data model are configured to obtain the query fields of the target data model; In response to the model configuration operation, the isolation range of the target data model is configured to obtain the model isolation range of the target data model; In response to the query configuration operation, query information is configured for the query field to obtain the query information of the query field; wherein, the query information includes: the query field alias and query range of the query field.
7. The method according to claim 1, characterized in that, The method further includes: In response to the failure to find the target data, a query failure response and / or prompt message are sent to the client; The query failure response indicates that the query failed, and the prompt message indicates that the data query conditions should be re-entered.
8. A data query device, characterized in that, include: A receiving module is used to receive data query requests sent by a client; wherein the data query request includes data query conditions; An encapsulation module is used to determine a query condition object to carry the data query conditions based on the data query conditions; obtain query configuration information associated with the target data model from the local cache; and encapsulate the target business code based on the query condition object and the query configuration information to obtain a data query object. The calling module is used to call the data query object to query target data that matches the data query conditions from the target data model; The sending module is used to send a data query response carrying the target data to the client.
Citation Information
Patent Citations
Data query method and data query device based on Gorm
CN118916407A
Application deployment for data intake and query system
US20170315796A1