Return data limiting method, system and equipment based on data query and medium

By performing thread isolation and quantitative configuration of MyBatis interceptor, intercepting and updating query instructions, the problem of MyBatis query is solved, and efficient data query and stable service are achieved.

CN120371866APending Publication Date: 2025-07-25SHENZHEN LEXIN SOFTWARE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510459289.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

In back-end project development, when using MyBatis for database queries, the return amount of data is large, resulting in low query efficiency, especially when business volume increases, which may lead to service crash.

Method used

By initializing the MyBatis interceptor for thread isolation and quantity configuration, intercept query instructions, analyze the quantity limit status, and conduct quantity limit updates on the query instructions, and finally perform data query and return data.

Benefits of technology

It improves the efficiency of data query, reduces the burden on the database, optimizes the user experience, avoids service crashes caused by large data volume return, and ensures the stability of the service.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371866A_ABST
    Figure CN120371866A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data query, and discloses a return data limiting method, system and device based on data query and a medium, and the method comprises the following steps: initializing a MyBatis interceptor, and carrying out thread isolation and interception number configuration on the MyBatis interceptor to obtain an independent interceptor; performing query instruction interception on a target database sent by a client by using an independent interceptor to obtain an intercepted query instruction; performing return quantity analysis on the interception query instruction to obtain a quantity limiting state; according to the independent interceptor and the number limiting state, carrying out number limiting updating on the intercepted query instruction to obtain an updated query instruction; and performing data query on a target database by utilizing the update query instruction to obtain query return data, and sending the query return data to the client. The method and the device can be applied to the field of data query, can limit the quantity of data returned by data query, and can improve the efficiency of data query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data query, and particularly to a method, system, device and medium for restricting returned data based on data query. Background Art

[0002] Database query is the process of obtaining data from a database. Database query can quickly retrieve the data stored in the database, and this data can be the core information required for the operation of an application. By querying the database, the stored data can be analyzed to obtain valuable business insights, which also makes data query play a crucial role in modern software systems. In the development of back-end projects, the persistence layer framework MyBatis is usually used for database query operations. When performing a list query, the amount of returned data may be very large. Especially in the case of continuous growth of business volume, the amount of data returned by the query may increase exponentially, which may lead to low efficiency when performing data query. Summary of the Invention

[0003] The present invention provides a method, system and computer-readable storage medium for restricting returned data based on data query, and its main purpose is to solve the problem of low efficiency when performing data query.

[0004] To achieve the above object, a method for restricting returned data based on data query provided by the present invention includes: Initializing a MyBatis interceptor, performing thread isolation and intercepting quantity configuration on the MyBatis interceptor to obtain an independent interceptor; Using the independent interceptor to intercept the query instruction for the target database sent by the client to obtain an intercepted query instruction; Performing return quantity analysis on the intercepted query instruction to obtain a quantity restriction status; Updating the quantity restriction of the intercepted query instruction according to the independent interceptor and the quantity restriction status to obtain an updated query instruction; Using the updated query instruction to perform data query on the target database to obtain query return data, and sending the query return data to the client.

[0005] Optionally, the performing thread isolation and intercepting quantity configuration on the MyBatis interceptor to obtain an independent interceptor includes: Initializing a thread switch, using the thread switch to perform thread isolation on the MyBatis interceptor to obtain a thread interceptor; Performing logical method extraction on the thread interceptor to obtain a thread interception method; Limit the return quantity of the thread interception method to obtain a limited interception method; Use the limited interception method to update the thread interceptor to obtain an updated interceptor; Configure and register the updated interceptor to obtain an independent interceptor.

[0006] Optionally, the using the independent interceptor to intercept a query instruction for a target database sent by a client to obtain an intercepted query instruction includes: Use the independent interceptor to intercept an access object for the target database to obtain a target intercepted object; Extract a query object from the target intercepted object to obtain a target query object; Extract a query instruction from the target query object to obtain an intercepted query instruction.

[0007] Optionally, the analyzing the return quantity of the intercepted query instruction to obtain a quantity limit status includes: Determine whether the intercepted query instruction is a nested query instruction; If so, determine that the quantity limit status is no need to limit; If not, determine whether the intercepted query instruction contains a quantity limit word; If so, determine that the quantity limit status is no need to limit; If not, determine that the quantity limit status is need to limit.

[0008] Optionally, the updating the quantity limit of the intercepted query instruction according to the independent interceptor and the quantity limit status to obtain an updated query instruction includes: Determine whether the quantity limit status is need to limit; If so, generate an interception warning, send the interception warning to the client, and update the quantity limit of the intercepted query instruction according to the independent interceptor to obtain an updated query instruction; If not, use the intercepted query instruction as the updated query instruction.

[0009] Optionally, the updating the quantity limit of the intercepted query instruction according to the independent interceptor to obtain an updated query instruction includes: Query the interception configuration of the independent interceptor to obtain an interception configuration file; Extract an interception value from the interception configuration file to obtain an interception threshold; Analyze the instruction type of the intercepted query instruction to obtain a query instruction type; Update the quantity limit of the intercepted query instruction according to the interception threshold and the query instruction type to obtain an updated query instruction.

[0010] Optionally, the data query of the target database using the updated query instruction to obtain query return data includes: Perform an interactive instance extraction operation on the target database to obtain a database interaction instance; Use the database interaction instance to perform an interface method extraction operation on the target database to obtain an interface query method; Perform a data query on the target database according to the interface query method and the updated query instruction to obtain query return data.

[0011] To solve the above problems, the present invention also provides a return data limit system based on data query, and the system includes: An interception configuration module, configured to initialize a MyBatis interceptor, perform thread isolation and interception quantity configuration on the MyBatis interceptor to obtain an independent interceptor; An instruction interception module, configured to use the independent interceptor to intercept a query instruction for a target database sent by a client to obtain an intercepted query instruction; A status detection module, configured to perform a return quantity analysis on the intercepted query instruction to obtain a quantity limit status; An instruction update module, configured to update the quantity limit of the intercepted query instruction according to the independent interceptor and the quantity limit status to obtain an updated query instruction; A data query module, configured to use the updated query instruction to perform a data query on the target database to obtain query return data, and send the query return data to the client.

[0012] To solve the above problems, the present invention also provides an electronic device, and the electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the above-mentioned return data limit method based on data query.

[0013] To solve the above problems, the present invention also provides a computer-readable storage medium, and at least one computer program is stored in the computer-readable storage medium, and the at least one computer program is executed by a processor in an electronic device to implement the above-mentioned return data limit method based on data query.

[0014] In the embodiments of the present invention, through thread isolation, it is possible to ensure the independence of the intercepted threads, reduce the impact on the program, achieve imperceptible interception restrictions, and thus improve the user experience. Through intercepting query instructions, it is possible to intercept all access operations to the database and the corresponding query statements under the persistence layer framework, thereby facilitating subsequent query restriction operations. Through analyzing the returned quantity, obtaining the quantity restriction status, it is possible to determine whether the intercepted query instruction needs to be restricted in terms of the returned quantity, thereby facilitating subsequent optimization of the returned quantity restriction for query statements.

[0015] By updating the quantity restriction of the intercepted query instruction, it is possible to limit the amount of data returned in the query, improve the efficiency of data query, reduce the burden on the database at the same time, and optimize the user experience. Through data query, it is possible to avoid service crashes caused by the return of a large amount of data, ensure the stability of the service, and at the same time achieve data query with a limited return amount, improving the efficiency of data query. Therefore, the method, system, device, and medium for returning data restriction based on data query proposed by the present invention can solve the problem of low efficiency in data query. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a schematic flowchart of a method for returning data restriction based on data query provided by an embodiment of the present invention; Figure 2 It is a schematic flowchart of generating an independent interceptor provided by an embodiment of the present invention; Figure 3 It is a schematic flowchart of generating an updated query instruction provided by an embodiment of the present invention; Figure 4 It is a system architecture diagram of a system for returning data restriction based on data query provided by an embodiment of the present invention; Figure 5 It is a schematic structural diagram of an electronic device for implementing the method for returning data restriction based on data query provided by an embodiment of the present invention.

[0017] The implementation, functional features, and advantages of the object of the present invention will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0018] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0019] An embodiment of the present application provides a method for restricting returned data based on data query. The execution subject of the method for restricting returned data based on data query includes, but is not limited to, at least one of electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided by the embodiment of the present application. In other words, the method for restricting returned data based on data query can be executed by software or hardware installed on a terminal device or a server device. The server includes, but is not limited to: a single server, a server cluster, a cloud server, or a cloud server cluster, etc. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms.

[0020] Referring to Figure 1 As shown, it is a schematic flowchart of the method for restricting returned data based on data query provided by an embodiment of the present invention. In this embodiment, the method for restricting returned data based on data query includes: S1. Initialize the MyBatis interceptor, perform thread isolation and interception quantity configuration on the MyBatis interceptor to obtain an independent interceptor.

[0021] Specifically, the MyBatis interceptor is an interception plugin created for the persistence layer framework MyBatis to intercept all query methods of MyBatis. Among them, MyBatis is a persistence layer framework that supports custom structured query statements, stored procedures, and advanced mappings. By binding entity classes to structured query statements in the form of extensible markup language or annotations, it can greatly reduce the duplicate code and maintenance cost of Java Database Connectivity (JDBC). The MyBatis interceptor is initialized through the Interceptor interface of the MyBatis framework.

[0022] In the embodiment of the present invention, referring to Figure 2 As shown, the performing thread isolation and interception quantity configuration on the MyBatis interceptor to obtain an independent interceptor includes: S21. Initialize the thread switch, and use the thread switch to perform thread isolation on the MyBatis interceptor to obtain a thread interceptor; S22. Extract the logical method from the thread interceptor to obtain a thread interception method; S23. Perform return quantity restriction on the thread interception method to obtain a restricted interception method; S24. Update the thread interceptor using the limit interception method to obtain an updated interceptor; S25. Configure and register the updated interceptor to obtain an independent interceptor.

[0023] Specifically, the thread switch refers to the ThreadLocal switch, and the thread isolation means using ThreadLocal to separately configure the opening and closing of the MyBatis interceptor. ThreadLocal is a thread-local variable tool provided by Java, which allows each thread to have its own independent variable copy and multiple threads will not affect each other.

[0024] Specifically, the process of isolating the MyBatis interceptor using the thread switch to obtain a thread interceptor includes: initializing the thread of the MyBatis interceptor using the thread switch to obtain an initial interceptor; obtaining the status of the initial interceptor to get the interceptor switch status; and starting the thread of the initial interceptor according to the interceptor switch status to obtain a thread interceptor.

[0025] Specifically, ThreadLocal.withInitial(() -> false) can be used for thread initialization, that is, the initial interceptor is enabled by default. The status acquisition refers to obtaining the status of the initial interceptor being enabled or disabled. The getLimitSwitchLocal method of the LimitSwitch class can be used to obtain the status of the initial interceptor. The interceptor switch status includes two states: interceptor enabled and interceptor disabled. The clear method of the LimitSwitch class can be used to start the thread by setting the switch status of the current thread to false.

[0026] Specifically, the logical method extraction refers to extracting the interception method in the MyBatis interceptor, that is, extracting the intercept method of the Interceptor interface. The thread interception method can be the intercept method.

[0027] Specifically, the return quantity limit means adding a function in the thread interception method to detect the amount of returned data and limit the data for excessive returned data. Updating the thread interceptor using the limit interception method means replacing and updating the thread interception method in the thread interceptor using the limit interception method. The configuration registration means registering the updated interceptor in the configuration file of the persistence layer framework MyBatis to obtain an independent interceptor.

[0028] In the embodiments of the present invention, by performing thread isolation, it is possible to ensure the independence of the intercepted thread, reduce the impact on the program, achieve a seamless interception limit, and thus improve the user experience.

[0029] S2. Use the independent interceptor to intercept the query instruction for the target database sent by the client to obtain an intercepted query instruction.

[0030] Specifically, the intercepted query instruction refers to the query instruction intercepted by the independent interceptor for the user to perform data query on the target database, and the intercepted query instruction can be an SQL query instruction.

[0031] In the embodiments of the present invention, the step of using the independent interceptor to intercept the query instruction for the target database sent by the client to obtain an intercepted query instruction includes: using the independent interceptor to intercept the access object for the target database to obtain a target intercepted object; extracting the query object from the target intercepted object to obtain a target query object; and extracting the query instruction from the target query object to obtain an intercepted query instruction.

[0032] Specifically, the access object interception refers to intercepting the database access object. The getTarget() method of the Invocation object can be used for access object interception. The target intercepted object can be a StatementHandler object, and the StatementHandler is the object called by the MyBatis framework during the query operation.

[0033] Specifically, the query object extraction refers to extracting the object used for database access operation in the target intercepted object. The getBoundSql() method can be used for query object extraction. The target query object can be a BoundSql object, and the BoundSql object contains the currently executed SQL statement and the corresponding parameters. The query instruction extraction refers to extracting the SQL statement from the target query object, and the getSql() method can be used for query instruction extraction.

[0034] In the embodiments of the present invention, by performing query instruction interception, it is possible to intercept all access operations to the database and the corresponding query statements under the persistence layer framework, thus facilitating subsequent query limit operations.

[0035] S3. Analyze the return quantity of the intercepted query instruction to obtain a quantity limit status.

[0036] Specifically, the quantity limit status includes two statuses: needing to be limited and not needing to be limited. Among them, "needing to be limited" means that the intercepted query instruction does not have a return quantity limit and needs to be limited, and "not needing to be limited" means that the intercepted query instruction specifies the return quantity or performs a query through nesting or other forms, so there is no need to limit the return quantity of the query.

[0037] Specifically, analyzing the return quantity of the intercepted query instruction to obtain the quantity limit status includes: determining whether the intercepted query instruction is a nested query instruction; if so, determining that the quantity limit status is not needing to be limited; if not, determining whether the intercepted query instruction contains a quantity limit word; if so, determining that the quantity limit status is not needing to be limited; if not, determining that the quantity limit status is needing to be limited.

[0038] Specifically, methods such as nested keyword detection, subquery location, and parenthesis matching can be used to determine whether the intercepted query instruction is a nested query instruction. The nested query instruction refers to a query instruction in which there is a nested query statement in the intercepted query instruction.

[0039] Specifically, the nested keyword detection refers to detecting whether there are subquery keywords such as "SELECT" in the intercepted query instruction. The subquery location refers to analyzing and detecting clauses such as FROM, WHERE, HAVING, and SELECT in the intercepted query instruction to determine whether these clauses contain nested SELECT statements. The parenthesis matching refers to matching the parentheses in the intercepted query instruction to query whether the parentheses contain nested SELECT statements.

[0040] Specifically, the quantity limit word refers to a restrictive word used to limit the return quantity of a query statement. The quantity limit words include words such as LIMIT, TOP, and ROWNUM.

[0041] In the embodiment of the present invention, by performing return quantity analysis to obtain the quantity limit status, it is possible to determine whether the intercepted query instruction needs to be limited in terms of return quantity, thus facilitating subsequent optimization of the return quantity limit for the query statement.

[0042] S4. Update the quantity limit of the intercepted query instruction according to the independent interceptor and the quantity limit status to obtain an updated query instruction.

[0043] Specifically, the updated query instruction refers to an intercepted query instruction that has been modified and can update the return quantity of the query instruction.

[0044] In an embodiment of the present invention, the step of performing quantity limit update on the interception query instruction according to the independent interceptor and the quantity limit status to obtain an updated query instruction includes: determining whether the quantity limit status is a status that requires limitation; if so, generating an interception warning, sending the interception warning to the client, and performing quantity limit update on the interception query instruction according to the independent interceptor to obtain an updated query instruction; if not, using the interception query instruction as the updated query instruction.

[0045] Specifically, the interception warning is a warning message used to notify the client that the independent interceptor starts interception work. In another embodiment of the present invention, the client can update the interception configuration file of the independent interceptor according to the warning message, so as to adjust the interception threshold.

[0046] In detail, referring to Figure 3 as shown, the step of performing quantity limit update on the interception query instruction according to the independent interceptor to obtain an updated query instruction includes: S31. Query the interception configuration of the independent interceptor to obtain an interception configuration file; S32. Extract the interception value from the interception configuration file to obtain an interception threshold; S33. Analyze the instruction type of the interception query instruction to obtain a query instruction type; S34. Perform quantity limit update on the interception query instruction according to the interception threshold and the query instruction type to obtain an updated query instruction.

[0047] In detail, the interception configuration query refers to obtaining the configuration file of the independent interceptor, and the interception configuration query can be performed by methods such as redis cache query, mysql data query or remote configuration file query. The interception configuration file is a configuration file used to limit the maximum number of returned data.

[0048] Specifically, the interception value extraction refers to extracting the specific limited return quantity in the interception configuration file, and the interception value extraction can be performed by using the keyword detection method. The interception threshold is the maximum number of data that can be returned by a pre-set query instruction. The instruction type analysis refers to analyzing the database syntax type to which the interception query instruction belongs, and the database syntax types include SQL Server type, MySQL type, PostgreSQL type, Oracle type, etc.

[0049] Specifically, the quantity limit update of the intercepted query instruction according to the interception threshold and the query instruction type means generating a restricted quantity keyword according to the query instruction type, generating a restricted clause according to the restricted quantity keyword and the interception threshold, and using the restricted clause to perform the quantity limit update. For example, when the query instruction type is SQL Server type, the restricted quantity keyword is TOP; when the query instruction type is MySQL type and PostgreSQL type, the restricted quantity keyword is LIMIT; when the query instruction type is Oracle type, the restricted quantity keyword is ROWNUM. In the embodiment of the present invention, by performing the quantity limit update on the intercepted query instruction, the return quantity of the query data can be restricted, the data query efficiency can be improved, the burden on the database can be reduced, and the user experience is optimized.

[0050] S5. Use the updated query instruction to perform data query on the target database to obtain query return data, and send the query return data to the client.

[0051] Specifically, the query return data refers to the data returned by the target database for the updated query instruction.

[0052] In the embodiment of the present invention, the use of the updated query instruction to perform data query on the target database to obtain query return data includes: performing an interaction instance extraction operation on the target database to obtain a database interaction instance; using the database interaction instance to perform an interface method extraction operation on the target database to obtain an interface query method; and performing data query on the target database according to the interface query method and the updated query instruction to obtain query return data.

[0053] Specifically, the interaction instance extraction refers to obtaining the interaction instance of the target database. The interaction instance extraction operation can be performed using the SqlSessionFactory class, and the database interaction instance can be a SqlSession instance.

[0054] Specifically, the interface method extraction operation refers to obtaining the interface method for data query interaction of the target database. The interface method extraction operation can be performed using the getMapper method of the SqlSession instance, and the interface query method can be the corresponding method of the Mapper interface.

[0055] In the embodiment of the present invention, by performing data query, the service crash caused by the return of a large amount of data can be avoided, the stability of the service can be ensured, and at the same time, the data query with a restricted return quantity is realized, and the data query efficiency is improved.

[0056] In the embodiment of the present invention, through thread isolation, it is possible to ensure the independence of the intercepted thread, reduce the impact on the program, achieve a non-perceptible interception limit, and thus improve the user experience. Through query instruction interception, it is possible to intercept all access operations to the database and the corresponding query statements under the MyBatis framework, facilitating subsequent query limit operations. Through return quantity analysis to obtain the quantity limit status, it is possible to determine whether the intercepted query instruction needs to be restricted in terms of the return quantity, facilitating subsequent optimization of the return quantity limit for the query statement.

[0057] By updating the quantity limit for the intercepted query instruction, it is possible to limit the return quantity of the query data, improve the efficiency of data query, reduce the burden on the database, and optimize the user experience. Through data query, it is possible to avoid service crashes caused by the return of a large amount of data, ensure the stability of the service, and at the same time achieve data query with a limited return quantity, improving the efficiency of data query. Therefore, the return data limit method based on data query proposed by the present invention can solve the problem of low efficiency in data query.

[0058] As Figure 4 shown, it is the system architecture diagram of the return data limit system based on data query provided by an embodiment of the present invention.

[0059] The return data limit system 100 based on data query of the present invention can be installed in an electronic device. According to the functions implemented, the return data limit system 100 based on data query can include an interception configuration module 101, an instruction interception module 102, a status detection module 103, an instruction update module 104, and a data query module 105. The modules of the present invention can also be referred to as units, which refer to a series of computer program segments that can be executed by the processor of an electronic device and can complete fixed functions, and are stored in the memory of the electronic device.

[0060] In this embodiment, the functions of each module / unit are as follows: The interception configuration module 101 is used to initialize the MyBatis interceptor, perform thread isolation and interception quantity configuration on the MyBatis interceptor to obtain an independent interceptor; The instruction interception module 102 is used to use the independent interceptor to intercept the query instruction for the target database sent by the client to obtain an intercepted query instruction; The status detection module 103 is used to perform return quantity analysis on the intercepted query instruction to obtain the quantity limit status; The instruction update module 104 is configured to update the quantity limit of the interception query instruction according to the independent interceptor and the quantity limit status, so as to obtain an updated query instruction; The data query module 105 is configured to query data from the target database by using the updated query instruction, obtain query return data, and send the query return data to the client.

[0061] Specifically, each module in the return data limit system 100 based on data query in the embodiment of the present invention adopts the same technical means as those Figures 1 to 3 described in the return data limit method based on data query above, and can produce the same technical effects, which will not be elaborated here.

[0062] As Figure 5 shown, it is a schematic structural diagram of an electronic device for implementing the return data limit method based on data query provided by an embodiment of the present invention.

[0063] The electronic device 1 may include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and may further include a computer program stored in the memory 11 and executable on the processor 10, such as a return data limit program based on data query.

[0064] Among them, the processor 10 may be composed of integrated circuits in some embodiments. For example, it may be composed of a single packaged integrated circuit, or may be composed of multiple integrated circuits with the same or different functions, including a combination of one or more central processing units (Central Processing Unit, abbreviated as CPU), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control core (ControlUnit) of the electronic device, connects various components of the entire electronic device through various interfaces and lines, and executes various functions of the electronic device and processes data by running or executing programs or modules stored in the memory 11 (such as executing a return data limit program based on data query, etc.), and calling data stored in the memory 11.

[0065] The memory 11 includes at least one type of readable storage medium, which includes flash memory, mobile hard disks, multimedia cards, card-type memories (such as SD or DX memories, etc.), magnetic memories, magnetic disks, optical disks, etc. The memory 11 can be an internal storage unit of an electronic device in some embodiments, such as the mobile hard disk of the electronic device. The memory 11 can also be an external storage device of the electronic device in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the electronic device. Further, the memory 11 can also include both an internal storage unit and an external storage device of the electronic device. The memory 11 can be used not only to store application software installed on the electronic device and various types of data, such as the code of the return data limit program based on data query, etc., but also to temporarily store data that has been output or will be output.

[0066] The communication bus 12 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. The bus is set to enable connection communication between the memory 11 and at least one processor 10, etc.

[0067] The communication interface 13 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface can include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), and is generally used to establish a communication connection between this electronic device and other electronic devices. The user interface can be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface can also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display can be an LED display, a liquid crystal display, a touch liquid crystal display, and an Organic Light-Emitting Diode (OLED) toucher, etc. Among them, the display can also be appropriately referred to as a display screen or a display unit, and is used to display information processed in the electronic device and to display a visual user interface.

[0068] Only an electronic device with components is shown in the figure. Those skilled in the art can understand that the structure shown in the figure does not constitute a limitation on the electronic device, and it may include fewer or more components than shown in the figure, or combine some components, or have different component arrangements.

[0069] For example, although not shown, the electronic device may further include a power source (such as a battery) for powering each component. Preferably, the power source can be logically connected to the at least one processor 10 through a power management system, so as to implement functions such as charge management, discharge management, and power consumption management through the power management system. The power source may also include any components such as one or more DC or AC power sources, a recharge system, a power failure detection circuit, a power converter or inverter, a power status indicator, etc. The electronic device may also include a variety of sensors, a Bluetooth module, a Wi-Fi module, etc., which will not be elaborated here.

[0070] It should be understood that the above embodiments are only for illustrative purposes and are not limited by this structure in the scope of the patent application.

[0071] The text analysis program optimized based on length stored in the memory 11 in the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can implement: Initialize the MyBatis interceptor, perform thread isolation and interception quantity configuration on the MyBatis interceptor to obtain an independent interceptor; Use the independent interceptor to intercept the query instruction for the target database sent by the client to obtain an intercepted query instruction; Analyze the return quantity of the intercepted query instruction to obtain a quantity limit status; Update the quantity limit of the intercepted query instruction according to the independent interceptor and the quantity limit status to obtain an updated query instruction; Use the updated query instruction to query data from the target database to obtain query return data, and send the query return data to the client.

[0072] Specifically, the specific implementation method of the above instructions by the processor 10 can refer to the description of the relevant steps in the corresponding embodiments of the accompanying drawings and will not be elaborated here.

[0073] Furthermore, if the modules / units integrated in the electronic device 1 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or system capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disc, a computer memory, a read-only memory (ROM for short).

[0074] The present invention also provides a computer-readable storage medium. The readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, it can implement: Initialize the MyBatis interceptor, perform thread isolation and interception quantity configuration on the MyBatis interceptor to obtain an independent interceptor; Use the independent interceptor to intercept the query instruction for the target database sent by the client to obtain an intercepted query instruction; Analyze the return quantity of the intercepted query instruction to obtain a quantity limit status; Update the quantity limit of the intercepted query instruction according to the independent interceptor and the quantity limit status to obtain an updated query instruction; Use the updated query instruction to query data from the target database to obtain query return data, and send the query return data to the client.

[0075] In several embodiments provided by the present invention, it should be understood that the disclosed devices, systems and methods can be implemented in other ways. For example, the system embodiments described above are only illustrative. For example, the division of the modules is only a logical function division, and there can be other division methods in actual implementation.

[0076] The modules described as separate components may or may not be physically separated. The components shown as modules may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0077] In addition, in each embodiment of the present invention, the functional modules can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of a combination of hardware and software functional modules.

[0078] For those skilled in the art, it is obvious that the present invention is not limited to the details of the above-described exemplary embodiments, and the present invention can be implemented in other specific forms without departing from the spirit or basic characteristics of the present invention.

[0079] Therefore, from any point of view, the embodiments should be regarded as exemplary and non-limiting. The scope of the present invention is defined by the appended claims rather than the above description. Therefore, all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be embraced within the present invention. Any reference signs in the claims should not be construed as limiting the claims involved.

[0080] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI for short) is a theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to obtain the best results.

[0081] In addition, it is obvious that the term "including" does not exclude other units or steps, and the singular does not exclude the plural. The multiple units or systems described in the system embodiments can also be implemented by one unit or system through software or hardware. The terms such as "first" and "second" are used to denote names and do not represent any specific order.

[0082] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not restrictive. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. A method for restricting returned data based on data query, characterized in that, The method includes: Initializing a MyBatis interceptor, performing thread isolation and intercepting quantity configuration on the MyBatis interceptor to obtain an independent interceptor; Using the independent interceptor to intercept a query instruction for a target database sent by a client to obtain an intercepted query instruction; Performing return quantity analysis on the intercepted query instruction to obtain a quantity limit status; Updating the quantity limit of the intercepted query instruction according to the independent interceptor and the quantity limit status to obtain an updated query instruction; Using the updated query instruction to query data from the target database to obtain query return data, and sending the query return data to the client.

2. The method for restricting returned data based on data query according to claim 1, wherein The performing thread isolation and intercepting quantity configuration on the MyBatis interceptor to obtain an independent interceptor includes: Initializing a thread switch, using the thread switch to perform thread isolation on the MyBatis interceptor to obtain a thread interceptor; Extracting a logical method from the thread interceptor to obtain a thread intercepting method; Performing return quantity limitation on the thread intercepting method to obtain a limited intercepting method; Using the limited intercepting method to update the thread interceptor to obtain an updated interceptor; Performing configuration registration on the updated interceptor to obtain an independent interceptor.

3. The method for restricting returned data based on data query according to claim 1, characterized in that, The using the independent interceptor to intercept a query instruction for a target database sent by a client to obtain an intercepted query instruction includes: Using the independent interceptor to intercept an access object for the target database to obtain a target intercepted object; Extracting a query object from the target intercepted object to obtain a target query object; Extracting a query instruction from the target query object to obtain an intercepted query instruction.

4. The method for restricting returned data based on data query according to claim 1, wherein The performing return quantity analysis on the intercepted query instruction to obtain a quantity limit status includes: Judging whether the intercepted query instruction is a nested query instruction; If so, determining that the quantity limit status is no need for limitation; If not, judging whether the intercepted query instruction contains a quantity limit word; If so, determining that the quantity limit status is no need for limitation; If not, determining that the quantity limit status is need for limitation.

5. The method for restricting returned data based on data query according to claim 1, wherein The updating the quantity limit of the intercepted query instruction according to the independent interceptor and the quantity limit status to obtain an updated query instruction includes: Judging whether the quantity limit status is need for limitation; If so, generating an intercept warning, sending the intercept warning to the client, and updating the quantity limit of the intercepted query instruction according to the independent interceptor to obtain an updated query instruction; If not, using the intercepted query instruction as the updated query instruction.

6. The method for restricting returned data based on data query according to claim 5, wherein The updating the quantity limit of the intercepted query instruction according to the independent interceptor to obtain an updated query instruction includes: Querying an intercept configuration for the independent interceptor to obtain an intercept configuration file; Extracting an intercept value from the intercept configuration file to obtain an intercept threshold; Analyzing the instruction type of the intercepted query instruction to obtain a query instruction type; Updating the quantity limit of the intercepted query instruction according to the intercept threshold and the query instruction type to obtain an updated query instruction.

7. The method for restricting return data based on data query according to claim 1, wherein Performing data query on the target database using the update query instruction to obtain query return data, including: Performing an interaction instance extraction operation on the target database to obtain a database interaction instance; Performing an interface method extraction operation on the target database using the database interaction instance to obtain an interface query method; Performing data query on the target database according to the interface query method and the update query instruction to obtain query return data.

8. A return data restriction system based on data query, characterized in that, The system includes: An interception configuration module, configured to initialize a MyBatis interceptor, perform thread isolation and interception quantity configuration on the MyBatis interceptor to obtain an independent interceptor; An instruction interception module, configured to use the independent interceptor to intercept a query instruction for the target database sent by a client to obtain an intercepted query instruction; A status detection module, configured to perform a return quantity analysis on the intercepted query instruction to obtain a quantity limit status; An instruction update module, configured to perform quantity limit update on the intercepted query instruction according to the independent interceptor and the quantity limit status to obtain an update query instruction; A data query module, configured to perform data query on the target database using the update query instruction to obtain query return data, and send the query return data to the client.

9. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the return data limitation method based on data query according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the return data limitation method based on data query according to any one of claims 1 to 7.