Data query method and device
By receiving the client's data query request and encapsulating the business code based on the query conditions, the call and response of the data query object is realized, and the problem of poor design flexibility of traditional data query interfaces is solved, reducing the difficulty of code governance, and improving query efficiency and flexibility.
Patent Information
- Application Number
- CN202411733712.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-28
Smart Images

Figure CN119576990A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a data query method and device. Background Art
[0002] In the financial industry, data query is an important part of business operations and decision support. Financial institutions need to efficiently and accurately process a large number of data query requests to support risk management, transaction monitoring, customer management, report generation and other business needs.
[0003] In the related technology, data query is implemented based on 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. In addition, this design method may increase the difficulty of code governance and even become uncontrollable when facing ever-changing business needs and multi-team collaborative development, thereby reducing data query efficiency. Summary of the invention
[0004] The present disclosure provides a data query method and device to solve one of the technical problems in the related art at least to a certain extent. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment 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 a data query condition; based on the data query condition, encapsulating a target business code adapted to a target business scenario to which the data query request belongs to obtain a data query object; calling the data query object to query target data matching the data query condition 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 an embodiment of the present disclosure, a data query device is provided, comprising: a receiving module, used to receive a data query request sent by a client; wherein the data query request includes a data query condition; an encapsulation module, used to encapsulate a target business code adapted to a target business scenario to which the data query request belongs, based on the data query condition, to obtain a data query object; a calling module, used to call the data query object to query target data matching the data query condition from a target data model; and a sending module, used to send a data query response carrying the target data to the client.
[0007] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the data query method as described in the embodiment of the first aspect of the present disclosure.
[0008] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the data query method as described in the embodiment of the first aspect of the present disclosure.
[0009] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising: a computer program, wherein when the computer program is executed by a processor, the data query method as described in the embodiment of the first aspect of the present disclosure is implemented.
[0010] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0011] In the technical scheme, a data query request sent by a client is received; wherein the data query request includes a data query condition; based on the data query condition, a target business code adapted to a target business scenario to which the data query request belongs is encapsulated to obtain a data query object; the data query object is called to query the target data matching the data query condition from the target data model; a data query response carrying the target data is sent to the client, thereby encapsulating the target business code based on the data query condition to obtain a data query object, realizing the separation of query condition processing and data access logic, reducing the coupling between the business logic layer and the data access layer, and realizing that when business requirements change, a large amount of hard-coded query logic does not need to be modified, reducing maintenance costs and improving query efficiency; wherein, the query condition object, query configuration information and the target business code are combined to generate a data query object, and the query configuration information is used to define the query scope, query field and query field alias, query field operator, etc., to ensure that the query is only performed within the specified data model scope, avoiding cross-model erroneous operations; through the query configuration information, the query logic is dynamically generated to ensure the legality and validity of the query condition, while improving the flexibility of data query.
[0012] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0014] Figure 1 is a flowchart of a data query method shown in the first embodiment of the present disclosure;
[0015] Figure 2 is a flow chart of a data query method shown in the second embodiment of the present disclosure;
[0016] Figure 3 is a flowchart of a data query method shown in the third embodiment of the present disclosure;
[0017] Figure 4 is a flowchart of a data query method shown in the fourth embodiment of the present disclosure;
[0018] Figure 5 It is a schematic diagram of the principle of the data query method shown in the embodiment of the present disclosure;
[0019] Figure 6 is a structural diagram of a data query device shown in the fifth embodiment of the present disclosure;
[0020] Figure 7 It is a schematic structural diagram of an electronic device shown in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0021] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0023] It should be noted that in the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information are all carried out with the user's consent, and are in compliance with relevant laws and regulations and do not violate public order and good morals.
[0024] The risk assessment method and device according to the embodiments of the present disclosure are described below with reference to the accompanying drawings.
[0025] Figure 1 It is a flowchart of the data query method shown in the first embodiment of the present disclosure.
[0026] like Figure 1 As shown, the data query method includes the following steps:
[0027] Step 101: receiving a data query request sent by a client.
[0028] The data query request includes data query conditions.
[0029] In the disclosed embodiments, the client may be a front-end application, a mobile application, other back-end services, etc. The data query request sent by the client may be an HTTP request, and the request body includes the conditions required for the query (such as time range, transaction type, etc.), wherein the request body may include multiple types of request information, such as JSON objects, sorting requests, and paging requests. Among them, the JSON object includes the main conditions and parameters of the query, the sorting request is used to indicate the sorting method of the query results specified by the client, and the paging request is used to indicate the paging information of the query results specified by the client.
[0030] Step 102: based on the data query condition, encapsulate the target business code adapted to the target business scenario to which the data query request belongs, and obtain a data query object.
[0031] In order to improve the flexibility of data query, as a possible implementation method, the query condition processing and data access logic are separated to reduce the coupling between the business logic layer and the data access layer.
[0032] In the disclosed embodiment, the query conditions are extracted from the data query request sent by the client, and the business scenario is determined according to the data query conditions. Different business scenarios correspond to different query logics. The query conditions and query logic are encapsulated in a data query object to obtain the data query object. Therefore, when the business requirements change, only the part related to the query conditions needs to be modified without modifying the query logic, thereby reducing the code maintenance cost. Among them, the business scenario includes single table mode query or table connection model query.
[0033] Step 103: call the data query object to query the target data matching the data query condition from the target data model.
[0034] It is important to understand that the encapsulated data query object includes query conditions and query logic and can be called as an independent unit. Therefore, by calling the data query object, target data matching the data query conditions can be queried from the target data model.
[0035] Step 104: Send a data query response carrying the target data to the client.
[0036] Furthermore, a data query response is generated according to the target data, and the data query response is sent to the client.
[0037] It should be noted that when the target data is not found, a query failure response and / or prompt information is sent to the client, wherein the query failure response is used to indicate the query failure, and the prompt information is used to instruct to re-enter the data query conditions.
[0038] In summary, by encapsulating the target business code based on the data query conditions, we can obtain the data query object, separate the query condition processing from the data access logic, reduce the coupling between the business logic layer and the data access layer, and achieve that when the business scenario changes, there is no need to modify a large amount of hard-coded query logic, thereby reducing maintenance costs and improving query efficiency.
[0039] In order to clearly explain how the business code adapted to the business scenario to which the data query request belongs is encapsulated based on the data query conditions in the above embodiment to obtain the data query object, the present disclosure proposes another data query method.
[0040] Figure 2 It is a flowchart of a data query method shown in the second embodiment of the present disclosure.
[0041] like Figure 2 As shown, the data query method includes the following steps:
[0042] Step 201: receiving a data query request sent by a client.
[0043] The data query request includes data query conditions.
[0044] Step 202: Determine a query condition object for carrying the data query condition according to the data query condition.
[0045] In order to ensure the structuring and standardization of query conditions, in the embodiment of the present disclosure, based on the data query conditions, an object for carrying the data query conditions, i.e., a query condition object, is created. For example, a query condition object AggregationQuery for carrying the data query conditions is created; 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 a data query object.
[0047] In order to improve the flexibility and configurability of data query, and enhance the maintainability and extensibility of the code, as a possible implementation method, the query condition object, query configuration information and target business code are combined to generate a data query object. This data query object is responsible for receiving the query condition object and query configuration information, and calling the target business code to perform specific query operations. Among them, the query configuration information is used to define the query scope, query field and query field alias, query field operator, etc.
[0048] In the disclosed embodiment, 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: the model isolation scope and query field information adapted to the target data model. The query field information includes at least one of the following: query field, query field alias of the query field and query scope. The model isolation scope is used to define the data model and its scope involved in the query. Ensure that the query is only performed within a specific data model scope to avoid cross-model misoperation; the query field defines the specific field used in the query, and the query field alias of the query field is used to define an alternative name for the query field. The query field alias can help hide or obscure the original field name, which helps protect sensitive information of the data.
[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: call the data query object to query the target data matching the data query condition from the target data model.
[0052] In order to reduce the complexity of data query, as an example, the data query object is directly called to query the target data matching the data query condition from the target data model.
[0053] Step 205: Send a data query response carrying the target data to the client.
[0054] In summary, by determining the query condition object used to carry the data query condition according to the data query condition; encapsulating the target business code based on the query condition object to obtain the data query object, and calling the data query object to query the target data matching the data query condition from the target data model, thereby achieving the separation of query conditions and business codes, facilitating the management and reuse of business codes, and improving the flexibility of data queries. At the same time, by dynamically building and executing queries, it is possible to quickly respond to different data requirements and improve data query efficiency.
[0055] In order to define the data query scope and field, in the embodiment of the present disclosure, the query configuration information is obtained from the cache, so as to obtain the data query object based on the query configuration information, wherein the query configuration information may include the model isolation scope and query field information adapted to the target data model, and the query configuration information may be generated based on the model isolation scope and query field information adapted to the target data model. Figure 3 The embodiments are described in detail.
[0056] Figure 3 It is a flowchart of a data query method shown in the third embodiment of the present disclosure.
[0057] like Figure 3 As shown, the generation of query configuration information includes the following steps:
[0058] Step 301, obtaining the model isolation scope and query field information adapted to the target data model.
[0059] The query field information includes at least one of a query field, a query field alias of the query field, and a query range.
[0060] In an embodiment of the present disclosure, the model isolation scope, query field, query field alias, query operator scope, etc. set by relevant developers on the target data model are obtained.
[0061] The specific steps for setting the model isolation scope, query field, query field alias, and query operator scope on the target data model are as follows:
[0062] 1. Obtain the target data model that matches the data table in the database;
[0063] It should be understood that when each data table in the database is an independent data table, one data table may correspond to one target data model, and when there is an association relationship between multiple data tables in the database, multiple data tables correspond to the same target data model.
[0064] 2. In response to the field configuration operation, the query field of the target data model is configured to obtain the query field of the target data model;
[0065] The query fields include: user ID, order ID, user age, etc.
[0066] 3. In response to the model configuration operation, configuring the isolation scope of the target data model to obtain the model isolation scope of the target data model;
[0067] Among them, 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 you need to limit their use to a data model, you need to use @FilterScope on the data model to limit them.
[0068] 4. In response to the query configuration operation, query information is configured for the query field to obtain query information for the query field.
[0069] The query information includes: the query field alias and query range of the query field.
[0070] Step 302: Generate query configuration information according to the model isolation scope and query field information.
[0071] In the disclosed embodiment, the model isolation scope and the query field information are combined to generate query configuration information.
[0072] In summary, by obtaining the model isolation scope and query field information that are adapted to the target data model; generating query configuration information based on the model isolation scope and query field information, thereby achieving the goal of ensuring that queries are only performed within the specified data model scope through model isolation scope, avoiding cross-model erroneous operations; and dynamically generating query logic through query configuration information to ensure the legality and validity of query conditions.
[0073] On the basis of any of the above embodiments, based on the data query condition, 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, Figure 4 As shown, the target business code is generated using the following steps:
[0074] Step 401, parse the data query request to obtain target request parameters.
[0075] As an example, key information is extracted and identified from the query request, including the data table, field, condition, sorting method, etc. required to be queried. These key information are collectively referred to as target request parameters.
[0076] Step 402: Determine the target business scenario to which the data query request belongs according to the target request parameters.
[0077] In the disclosed embodiment, by analyzing the specific information in the request parameters, such as the queried data table, fields, conditions, etc., combined with 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 used as the target business scenario.
[0078] Step 403: Determine a target service code that is compatible with the target service scenario from among multiple candidate service codes.
[0079] It should be noted that in order to improve the efficiency and flexibility of the query, 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, from multiple candidate business codes, the target business code that is adapted to the target business scenario is selected.
[0080] The candidate business code is determined 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 a code editing operation, generate a candidate business code matching any candidate business scenario.
[0083] As an example, in response to any business scenario being a single-table mode query, in response to a code configuration operation, a business code including a single-table query interface code is generated; wherein the single-table query interface code is used to query a data model that has no association relationship.
[0084] That is, when a business scenario requires querying a single data table, in response to the code configuration operation, a business code including a single-table query interface code for querying a data model having no association relationship is generated.
[0085] As another example, in response to any business scenario being a table connection model query, in response to a code configuration operation, a business code of a high-order query interface code is generated; wherein the high-order query interface code is used to query multiple data models with associated relationships.
[0086] That is, when the business scenario requires querying multiple data tables with association relationships, a business code including a high-order query interface code is generated in response to the code configuration operation.
[0087] In summary, the data query request is parsed to obtain the target request parameters; according to the target request parameters, the target business scenario to which the data query request belongs is determined; from multiple candidate business codes, the target business code adapted to the target business scenario is determined. Thus, by parsing the request parameters and determining the business scenario, it is possible to flexibly respond to various query requirements without having to write fixed codes for each query scenario, thereby improving the adaptability and scalability of data queries; at the same time, by selecting an adapted target business code from multiple candidate business codes, it is possible to quickly locate and execute the query logic adapted to the target business scenario, thereby reducing unnecessary calculations and resource consumption and improving query efficiency.
[0088] Based on any of the above embodiments, Figure 5 As shown, the data query method of the embodiment of the present disclosure is implemented based on the following steps:
[0089] Step 1: Define model fields / set filter field aliases
[0090] Developers can set filtering configurations on model fields according to filtering requirements, including aliases, operator scopes, 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, modifier, etc., which are shared by all models, if you need to use them on a model, you need to mark @FilterScope on the model, and then mark the filter field with the isolation scope attribute in the filter request;
[0093] Step 3: Configure the chain interface call code (candidate business code)
[0094] In an embodiment of the present disclosure, the chain interface calling code includes a single-table query interface code and a high-order query interface code, wherein the single-table query interface code is used to query data models that have no association relationship, and the high-order query interface code is used to query multiple data models that have association relationship.
[0095] Step 4: Automatically scan the alias fields on the model to form a filtering configuration (query configuration information)
[0096] Scan all @FilterField fields, model entity classes, @Scope and other information on the model into the local cache to form query configuration information.
[0097] Step 5: Parse the data query request
[0098] When receiving a data query request sent by a client, the data query conditions in the data query request are parsed, and based on the data query conditions, the query condition object AggregationQuery used to carry the data query conditions is determined, and the query configuration information associated with the target data model is obtained from the local cache. That is, based on the AggregationQuery object and the main table model and the associated table model, the declaration of the main table field and the associated table field, the query configuration of the main table and the associated table is dynamically parsed and generated, and it is checked whether the operator of the query field is within the field operator range 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. That is to say, according to the query configuration of the dynamically parsed main table model and the associated table model, the data query object (QueryWrapper) object is dynamically generated and can be directly used for query.
[0101] Corresponding to the data query method provided in the above embodiment, the present disclosure also provides a data query device. Since the data query device provided in the embodiment of the present disclosure corresponds to the data query method provided in the above embodiment, the implementation method of the data query method is also applicable to the data query device provided in the embodiment of the present disclosure, and will not be described in detail in the embodiment of the present disclosure.
[0102] Figure 6 It is a structural diagram of a data query device shown in the fifth embodiment of the present disclosure.
[0103] like Figure 6 As shown, the data query device 600 includes: a receiving module 610, a packaging module 620, a calling module 630 and a sending module 640.
[0104] Among them, the receiving module 610 is used to receive a data query request sent by the client; wherein the data query request includes a data query condition; 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 condition to obtain 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 condition from the target data model; the sending module 640 is used to send the data query response carrying the target data to the client.
[0105] As a possible implementation method of the embodiment of the present disclosure, the encapsulation module 620 is used to determine the query condition object used to carry the data query condition according to the data query condition; and encapsulate the target business code based on the query condition object to obtain the data query object.
[0106] As a possible implementation method of the embodiment of the present disclosure, the encapsulation module 620 is used to obtain query configuration information associated with the target data model 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.
[0107] As a possible implementation manner of the embodiment of the present disclosure, the query configuration information is generated by using the following modules: a first acquisition module and a first generation module.
[0108] Among them, the first acquisition module is used to obtain the model isolation scope and query field information adapted to the target data model; wherein the query field information includes: at least one of the query field, the query field alias of the query field and the query scope; the generation module is used to generate the query configuration information according to the model isolation scope and the query field information.
[0109] As a possible implementation manner of the embodiment of the present disclosure, the target service code is determined by using the following modules: a parsing module and a determining module.
[0110] Among them, 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 determine the target business code that is adapted to the target business scenario from multiple candidate business codes.
[0111] As a possible implementation manner of the embodiment of the present disclosure, the candidate service code is determined by using the following modules: a second acquisition module and a second generation module.
[0112] Among them, 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 a candidate business code matching any candidate business scenario in response to a code editing operation.
[0113] As a possible implementation method of the embodiment of the present disclosure, the second generation module is used to respond to any business scenario being a single-table mode query and to respond to a code configuration operation to generate a business code including a single-table query interface code; wherein the single-table query interface code is used to query data models that do not have an associated relationship; respond to any business scenario being a table connection model query and to respond to a code configuration operation to generate a business code including a high-order query interface code; wherein the high-order query interface code is used to query multiple data models that have an associated relationship.
[0114] As a possible implementation of the embodiment of the present disclosure, the data query device 600 further includes: a configuration module.
[0115] Among them, the configuration module is used to obtain a target data model that is adapted to a data table in a database; in response to a field configuration operation, the query field of the target data model is configured to obtain the query field of the target data model; in response to a model configuration operation, the isolation scope of the target data model is configured to obtain the model isolation scope of the target data model; in response to a query configuration operation, query information is configured for the query field to obtain query information of the query field; wherein the query information includes: a query field alias and a query scope of the query field.
[0116] As a possible implementation method of the embodiment of the present disclosure, the sending module 640 is also used to send a query failure response and / or prompt information to the client in response to failure to find the target data; wherein the query failure response is used to indicate the query failure, and the prompt information is used to indicate the need to re-enter the data query conditions.
[0117] The data query device of the disclosed embodiment receives a data query request sent by a client; wherein the data query request includes a data query condition; based on the data query condition, encapsulates a target business code adapted to a target business scenario to which the data query request belongs to obtain a data query object; calls the data query object to query target data matching the data query condition from a target data model; and sends a data query response carrying the target data to the client, thereby encapsulating the target business code based on the data query condition to obtain a data query object, thereby separating the processing of the query condition from the data access logic, reducing the coupling between the business logic layer and the data access layer, and achieving the situation that when business requirements change, there is no need to modify a large amount of hard-coded query logic, thereby reducing maintenance costs and improving query efficiency.
[0118] In an exemplary embodiment, an electronic device is also provided.
[0119] Among them, electronic equipment includes:
[0120] processor;
[0121] a memory for storing processor-executable instructions;
[0122] The processor is configured to execute instructions to implement the data query method proposed in any of the aforementioned embodiments.
[0123] As an example, Figure 7 is a schematic diagram of the structure of an electronic device 700 shown in an exemplary embodiment of the present disclosure, such as Figure 7 As shown, the electronic device 700 may further include:
[0124] The memory 710 and the processor 720, 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, the data query method described in the embodiment of the present disclosure is implemented.
[0125] Bus 730 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.
[0126] The electronic device 700 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by the 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 called 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, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 730 via one or more data medium interfaces. The memory 710 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present disclosure.
[0128] A program / utility 780 having a set (at least one) of program modules 770 may be stored, for example, in the memory 710, such program modules 770 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 770 generally perform the functions and / or methods of the embodiments described in the present disclosure.
[0129] The electronic device 700 may also communicate with one or more external devices 790 (e.g., keyboard, pointing device, display 791, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 700, and / or communicate with any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 792. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 793. As shown, the network adapter 793 communicates with other modules of the electronic device 700 through a bus 730. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the 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 the programs stored in the memory 710 .
[0131] It should be noted that the implementation process and technical principles of the electronic device of this embodiment refer to the aforementioned explanation of the data query method of the embodiment of the present disclosure, 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, and the above instructions can be executed by a processor of an electronic device to complete the data query method proposed in any of the above embodiments. Optionally, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0133] In an exemplary embodiment, a computer program product is also provided, including a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, the data query method proposed in any of the above embodiments is implemented.
[0134] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0135] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A data query method, characterized in that: include: Receiving a data query request sent by a client; wherein the data query request includes a data query condition; Based on the data query condition, encapsulate the target business code adapted to the target business scenario to which the data query request belongs to obtain a data query object; Calling the data query object to query target data matching the data query condition from the target data model; A data query response carrying the target data is sent to the client.
2. The method according to claim 1, characterized in that The encapsulating, based on the data query condition, the business code adapted to the business scenario to which the data query request belongs to obtain a data query object, includes: According to the data query condition, determining a query condition object for carrying the data query condition; The target business code is encapsulated based on the query condition object to obtain a data query object.
3. The method according to claim 2, characterized in that The encapsulating the target business code based on the query condition object to obtain a data query object includes: Acquire query configuration information associated with the target data model from a 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.
4. The method according to claim 3, characterized in that The query configuration information is generated by the following steps: Acquire a model isolation scope and query field information adapted to the target data model; wherein the query field information includes: at least one of a query field, a query field alias of the query field, and a query scope; The query configuration information is generated according to the model isolation scope and the query field information.
5. The method according to claim 1, characterized in that The target service code is determined by the following steps: Parsing the data query request to obtain target request parameters; Determine, according to the target request parameters, a target business scenario to which the data query request belongs; A target service code adapted to the target service scenario is determined from multiple candidate service codes.
6. The method according to claim 5, characterized in that The candidate service code is determined by the following steps: Acquire multiple candidate business scenarios associated with the target data model; For any candidate business scenario, in response to a code editing operation, a candidate business code matching the any candidate business scenario is generated.
7. The method according to claim 6, characterized in that The step of generating, for any candidate business scenario, a candidate business code matching any candidate business scenario in response to a code editing operation includes: In response to any of the business scenarios being a single-table mode query, in response to a code configuration operation, a business code including a single-table query interface code is generated; wherein the single-table query interface code is used to query a data model that has no association relationship; In response to any of the business scenarios being a table connection model query, in response to a code configuration operation, a business code of a high-order query interface code is generated; wherein the high-order query interface code is used to query multiple data models with associated relationships.
8. The method according to claim 1, characterized in that The method further comprises: Obtain a target data model that matches the data table in the database; In response to the field configuration operation, configuring the query field of the target data model to obtain the query field of the target data model; In response to the model configuration operation, configuring the isolation scope of the target data model to obtain the model isolation scope of the target data model; In response to the query configuration operation, query information is configured for the query field to obtain query information of the query field; wherein the query information includes: a query field alias and a query range of the query field.
9. The method according to claim 1, characterized in that: The method further comprises: In response to failure to find the target data, sending a query failure response and / or prompt information to the client; The query failure response is used to indicate query failure, and the prompt information is used to instruct to re-enter the data query condition.
10. A data query device, characterized in that: include: A receiving module, used to receive a data query request sent by a client; wherein the data query request includes a data query condition; An encapsulation module, configured to encapsulate a target business code adapted to a target business scenario to which the data query request belongs based on the data query condition, to obtain a data query object; A calling module, used for calling the data query object to query target data matching the data query condition from a target data model; A sending module is used to send a data query response carrying the target data to the client.
Citation Information
Patent Citations
Data query method, data query device, electronic equipment and storage medium
CN117009397A
Business query method and device, equipment and storage medium
CN117149830A
Method and device for generating query statement and query service data, equipment and medium
CN118193567A
Query object mapping method and device and product
CN118227626A
Database query method and device, electronic equipment and medium
CN118520013A