A paging query method, device and equipment

By introducing interceptors into the Mybatis Plus framework, including query control classes, result set query classes, and total count query classes, the problem of users only querying the total number of results was solved, flexible pagination query function was implemented, independent query of total number of results and result set was supported, and system expansion was simplified.

CN116226167BActive Publication Date: 2026-04-10BEIJING VENUS INFORMATION SECURITY TECH +2
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING VENUS INFORMATION SECURITY TECH
Filing Date
2023-02-20
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

The Mybatis Plus framework does not support querying only the total number of results when the user only wants to query the total number of results.

Method used

In the Mybatis Plus framework, interceptors are introduced, including query control class, result set query class, and total query class. By obtaining the query type parameter, the total query class and result set query class are called respectively to achieve the function of querying only the total number of results or the result set.

Benefits of technology

This implementation enables the use of querying only the total number of results within the Mybatis Plus framework, avoiding the complexity of extending interfaces in existing systems and improving query flexibility and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116226167B_ABST
    Figure CN116226167B_ABST
Patent Text Reader

Abstract

The application discloses a paging query method, device and equipment, which can be applied to an interceptor of a Mybatis Plus framework, can respond to a user paging query operation, and executes a query control class to implement the following steps: a query type parameter is acquired, when the query type parameter is only query total, a total query class is called to perform result total query, and a first parameter is returned to a result set query class, wherein the first parameter is used to instruct the result set query class not to perform a result set query operation. According to the query requirement, the query type parameter is set, and the query type parameter is different when the query content is different. When the query type parameter is only query total, the query control class calls the total query class to perform result total query, and returns the first parameter to the result set query class, instructing the result set query class not to perform result set query. When the user only wants to query the result total, Mybatis Plus can support only query result total.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more specifically, to a pagination query method, apparatus, and device. Background Technology

[0002] In the information society, databases contain ever-growing amounts of information, and people frequently query them for various needs. If a large amount of data is retrieved from the database and displayed simultaneously on the page, it results in a cluttered page. Therefore, pagination can be used to display the retrieved data in batches, showing one "page" at a time, reducing the amount of data displayed on the user's page and making the page more concise.

[0003] Mybatis is a persistence layer framework that supports custom SQL, stored procedures, and advanced mappings. Mybatis Plus is an enhancement tool for MyBatis, building upon it without altering its core functionality. Mybatis Plus uses the Page class for pagination, with the front-end passing pagination parameters in a B / S architecture, such as: current (current page number), size (number of items displayed per page), and searchCount (whether to perform a count query).

[0004] In existing technology, Mybatis Plus performs pagination queries using one SQL query for the total number of results and another SQL query for the result set. When the `searchCount` parameter is true, the SQL query for the total number of results is executed first, followed by the SQL query for the result set, finally yielding both the paginated result set and the total number of results. When the `searchCount` parameter is false, only the SQL query for the result set is executed, resulting only in the paginated result set. However, it does not support querying only the total number of results when the user only wants to retrieve the total number of results. Summary of the Invention

[0005] In view of this, this application provides a pagination query method, apparatus, device, and storage medium to solve the problem that existing pagination query methods do not support querying only the total number of results when the user only wants the total number of results.

[0006] To achieve the above objectives, the following proposed solution is given:

[0007] A paginated query method is applied to an interceptor in the Mybatis Plus framework. The interceptor includes: a query control class, a result set query class, and a total count query class. The methods include:

[0008] In response to a user's paginated query operation, the query control class is executed to perform the following steps:

[0009] Retrieve query type parameters;

[0010] When the query type parameter is set to query only the total number, the total number query class is called to query the total number of results and obtain the total number of results.

[0011] Return a first parameter to the result set query class, the first parameter being used to instruct the result set query class not to perform a result set query operation.

[0012] Preferably, after obtaining the query type parameter, the method further includes:

[0013] When the query type parameter is query result set only, a second parameter is returned to the result set query class. The second parameter is used to instruct the result set query class to perform the result set query operation to obtain a paginated result set.

[0014] Preferably, after obtaining the query type parameter, the method further includes:

[0015] When the query type parameter is the total number of queries and the result set, the total number query class is called to query the total number of results, and the total number of results and the third parameter returned by the total number query class are obtained. The third parameter is the parameter returned by the total number query class to the query control class when the total number of results is greater than 0.

[0016] The second parameter is returned to the result set query class to instruct the result set query class to perform a result set query operation to obtain a paginated result set.

[0017] Preferably, after obtaining the query type parameter, the method further includes:

[0018] When the query type parameter is the total number of queries and the result set, the total number query class is called to perform a total number query, and the total number of results and the fourth parameter returned by the total number query class are obtained. The fourth parameter is the parameter returned by the total number query class to the query control class when the total number of results is equal to 0.

[0019] Return the first parameter to the result set query class to indicate that the result set query class does not perform the result set query operation.

[0020] Preferably, the total count query class includes:

[0021] The PaginationInnerInterceptor class in the Mybatis Plus framework.

[0022] Preferably, the third parameter is the same as the second parameter.

[0023] Preferably, the fourth parameter is the same as the first parameter.

[0024] Preferably, prior to the operation in response to a user's pagination query, the method further includes:

[0025] Create a parameter retrieval class, which is used to retrieve pagination parameters set by the user, including query type parameters;

[0026] The process of obtaining query type parameters includes:

[0027] The query type parameter in the parameter retrieval class is obtained.

[0028] A pagination query device includes: a query control unit, a result set query unit, and a total count query unit;

[0029] The query control unit includes:

[0030] The parameter retrieval sub-unit is used to retrieve query type parameters in response to user pagination query operations;

[0031] The first calling subunit is used to call the total count query class unit to perform a total result query when the query type parameter is "query only total count" to obtain the total result count.

[0032] A first instruction subunit is used to return a first parameter to the result set query class, the first parameter being used to instruct the result set query class unit not to perform a result set query operation.

[0033] A pagination query device includes: a memory and a processor;

[0034] The memory is used to store the interceptors, which include: query control class, result set query class, and total count query class;

[0035] The processor is used to execute the query control class and implement the various steps of the pagination query method described above.

[0036] As can be seen from the above technical solution, the pagination query method provided in this application embodiment can be applied to interceptors in the Mybatis Plus framework. The interceptor can include: a query control class, a result set query class, and a total count query class. In response to a user's pagination query operation, the query control class executes the following steps: obtaining the query type parameter; when the query type parameter is "query only the total count," calling the total count query class to perform a total count query, obtaining the total count, and returning a first parameter to the result set query class. The first parameter is used to instruct the result set query class not to perform a result set query. This application sets the query type parameter according to the user's query requirements; the query type parameter differs depending on the content queried by the user. When the query type parameter is "query only the total count," the query control class can call the total count query class to perform a total count query and return the first parameter to the result set query class, instructing the result set query class not to perform a result set query. Therefore, when a user only wants to query the total count, Mybatis Plus can support querying only the total count.

[0037] Furthermore, this application adds a query control class to the interceptor in the Mybatis Plus framework, enabling the interceptor to perform different types of queries. Therefore, it is only necessary to add a query type parameter that only queries the total number of results to the existing interface for calling pagination queries in the existing BS architecture system, without having to extend an interface to query only the total number of results. This avoids the existing BS architecture system becoming too large and difficult to extend to a separate interface for querying the total number of results. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0039] Figure 1 This is a flowchart of a pagination query control method disclosed in an embodiment of this application;

[0040] Figure 2 This is a schematic diagram of the structure of a pagination query device disclosed in an embodiment of this application;

[0041] Figure 3 This is a hardware structure block diagram of a pagination query device disclosed in an embodiment of this application. Detailed Implementation

[0042] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0043] This application solution can be implemented based on a terminal with pagination query function, such as a computer or server.

[0044] This application provides an improved pagination query method based on the Mybatis Plus framework, which can be applied to interceptors in the Mybatis Plus framework.

[0045] Specifically, the interceptor can include query control classes, result set query classes, and total count query classes. The query control class determines the desired query type based on the query type parameter and performs different queries accordingly, implementing different types of pagination queries. The result set query class calls the query control class and determines whether to perform a result set query based on the parameters returned by the query control class. When the parameters returned by the query control class instruct the result set query class to perform a result set query, the result set query class executes the SQL to query the result set, achieving the result set query and obtaining the paginated result set. The total count query class executes the SQL to query the total number of results, achieving the total number of results. For example, when using the Mybatis Plus framework for pagination queries, the `willDoQuery()` method in the `PaginationInnerInterceptor` class of the Mybatis Plus framework can perform a total count query operation to obtain the total number of results. Therefore, the total count query class in this application can be the `PaginationInnerInterceptor` class in the Mybatis Plus framework. Furthermore, this application can create a query control class that inherits from the PaginationInnerInterceptor class of the MybatisPlus framework, and rewrite the willDoQuery() method of the query control class so that the willDoQuery() method can determine the type of user query and perform the query based on the type of user query. Finally, the result set query class can determine whether to perform a result set query operation based on the parameters returned by the willDoQuery() method of the query control class. When the parameters returned by the willDoQuery() method of the query control class are used to instruct the result set query class to perform a result set query operation, the result set query class can execute the SQL to query the result set, realize the result set query, and obtain the paginated result set.

[0046] This application embodiment adds a query control class to the interceptors of the Mybatis Plus framework to control the query content. When the query type parameters are different, the query control class performs different types of queries based on the query type parameters. This enables the Mybatis Plus framework to support querying only the result set, querying only the total number of queries, querying the total number of queries, and querying only the result set.

[0047] This application, when a user performs a paginated query, can respond to the user's pagination query operation by executing the pagination query method implemented in the query control class, combined with the appendix. Figure 1 This section describes the steps involved in executing the pagination query control method within the query control class:

[0048] Step S01: Obtain the query type parameter.

[0049] Specifically, users can select the query type based on their query needs, such as: query only the result set, query only the total number of queries, or query total and result set. Variables can be set to retrieve parameters for the query type. For example, a variable `SearchType` can be set along with three query type parameters: `onlyTotal` (query total only), `onlyResult` (query result set only), and `totalResult` (query total and result set). Therefore, query type parameters can be obtained to determine the type of query the user wants to perform.

[0050] Step S02: When the query type parameter is "query only total count", the total count query class is called to query the total count of results and obtain the total count.

[0051] Specifically, when the obtained query type parameter is determined to be "query total only," it means that the user only wants to query the total number of results. Therefore, the query control class can call the total number query class to query the total number of results and obtain the total number of results. For example, taking the total number query class as PaginationInnerInterceptor as an example, since the willDoQuery() method in the PaginationInnerInterceptor class can perform a total number of results query, a query control class can be created that inherits from the PaginationInnerInterceptor class, and the willDoQuery() method in the query control class can be rewritten so that the willDoQuery() method in the query control class calls the willDoQuery() method of the parent class PaginationInnerInterceptor class to perform a total number of results query and obtain the total number of results.

[0052] Step S03: Return the first parameter to the result set query class. The first parameter is used to indicate that the result set query class should not perform the result set query operation.

[0053] Specifically, once the query type parameter is set to "query only total count," only the total number of results is needed, not the result set. Therefore, the query control class can return a first parameter to the result set query class. This first parameter instructs the result set query class not to perform a result set query. The first parameter can be in the form of `false`, `f`, `F`, etc., and its form can be determined by the technical personnel. When the result set query class receives the first parameter returned by the query control class, it will not perform a result set query and will directly receive an empty value. For example, with the first parameter set to `false`, a query control class can be created that inherits from the `PaginationInnerInterceptor` class, and the `willDoQuery()` method in the query control class can be overridden. When the query type parameter is "query only total count," the `willDoQuery()` method in the query control class will call the `willDoQuery()` method of the parent class `PaginationInnerInterceptor` to query the total number of results. Meanwhile, the willDoQuery() method in the query control class returns the first parameter false to the result set query class. When the result set query class receives the first parameter false returned by the willDoQuery() method in the query control class, it will no longer perform a result set query and will directly obtain an empty value.

[0054] The pagination query method provided in this application can be applied to interceptors in the Mybatis Plus framework. The interceptor can include a query control class, a result set query class, and a total count query class. In response to a user's pagination query operation, the query control class executes the following steps: obtaining a query type parameter; when the query type parameter is "query only total count," calling the total count query class to perform a total count query, obtaining the total count, and returning a first parameter to the result set query class. The first parameter instructs the result set query class not to perform a result set query. This application sets the query type parameter according to the user's query requirements; the query type parameter differs depending on the content queried by the user. When the query type parameter is "query only total count," the query control class can call the total count query class to perform a total count query and return the first parameter to the result set query class, instructing the result set query class not to perform a result set query. Therefore, Mybatis Plus can support querying only the total count when the user only wants to query the total count.

[0055] Considering that the query type can be any one of querying the total number of queries only, querying the result set only, or querying the total number of queries and the result set, the foregoing embodiments only introduced the case where the query type parameter is querying the total number of queries only. This application embodiment introduces the steps of implementing a categorized query by executing a query control class when the query type parameter is querying the result set only. After obtaining the query type parameter in step S01, the following step S04 can also be executed.

[0056] Step S04: When the query type parameter is query result set only, return the second parameter to the result set query class. The second parameter is used to instruct the result set query class to perform the result set query operation and obtain the paginated result set.

[0057] Specifically, when the query type parameter is "Query result set only," the user only wants to query the result set. Therefore, there's no need to query the total number of results. The query control class only needs to return a second parameter to the result set query class. This second parameter instructs the result set query class to perform the result set query operation and obtain a paginated result set. The second parameter can be in the form of `true`, `t`, `T`, etc., and technical personnel can determine its form according to their conventions. The form of the second parameter should be distinguishable from that of the first parameter. The query control class can return the second parameter to the result set query class. When the result set query class receives the second parameter returned by the query control class, it performs the result set query operation and obtains a paginated result set. For example, taking the second parameter as `true`, a query control class can be created that inherits from the `PaginationInnerInterceptor` class, and the `willDoQuery()` method in the query control class can be overridden. When the query type parameter is "Query result set only," the `willDoQuery()` method in the query control class can return the second parameter `true` to the result set query class. When the result set query class receives the second parameter `true` returned by the `willDoQuery()` method in the query control class, it performs the result set query operation and obtains a paginated result set.

[0058] In this embodiment, when the query type parameter is "query only result set," the query control class does not call the total count query class to perform a total result count query. Instead, it directly returns the second parameter to the result set query class. This second parameter instructs the result set query class to perform a result set query operation to obtain a paginated result set. Therefore, Mybatis Plus can support querying only the result set when the user only wants to query the result set.

[0059] Furthermore, the foregoing embodiments described the cases where the query type parameters are only the total number of queries and only the result set. Further, this application embodiment describes the steps for implementing paginated queries using a query control class when the query type parameters are the total number of queries and the result set. Therefore, after obtaining the query type parameters in step S01, steps S05-S06 can also be executed.

[0060] Step S05: When the query type parameter is the total number of queries and the result set, call the total number query class to query the total number of results and obtain the total number of results and the judgment parameter returned by the total number query class.

[0061] Specifically, when the query type parameters are total count and result set, both the total number of results and the result set need to be queried. The query control class can call the total count query class to query the total number of results and obtain the total number of results. Considering that the total count query class may return 0 or a value greater than 0, the total count query class can, after obtaining the total count, determine whether the total count is greater than 0 and return a judgment parameter to the query control class based on the judgment result.

[0062] When the total number of results is 0, it means that there are no corresponding query results, that is, there is no need to execute the query operation of the result set query class. In this case, the judgment parameter can be set to the fourth parameter. For example, the fourth parameter can be false.

[0063] When the total number of results is greater than 0, it means that there are corresponding query results, that is, the result set query class needs to perform a query operation. At this time, the judgment parameter can be set as the third parameter, for example, the third parameter can be true, etc.

[0064] Step S06: Return an indication parameter to the result set query class, indicating whether the result set query class should perform the result set query operation or not.

[0065] Specifically, when the query control class receives the fourth parameter returned by the total count query class, it returns the first parameter to the result set query class to instruct it not to perform a result set query. When the query control class receives the third parameter returned by the total count query class, it returns the second parameter to the result set query class to instruct it to perform a result set query and obtain the paginated result set. For example, assuming the fourth and first parameters are both false, and the third and second parameters are both true, when the total count query class returns the fourth parameter false to the query control class, the query control class returns the first parameter false to the result set query class. When the total count query class returns the third parameter true to the query control class, the query control class returns the second parameter true to the result set query class.

[0066] In this embodiment, when the query type parameters are total query count and result set, the total query class is first called to obtain the total result count. After obtaining the total result count, the total query class determines whether the total result count is greater than 0. If the total result count is greater than 0, a third parameter is returned to the query control class. Only after receiving the third parameter returned by the total query class will the query control class return a second parameter to instruct the result set query class to perform the result set query operation and obtain the paginated result set. When the query type parameters are total query count and result set, and the total result count is greater than 0, both the total result count and the paginated result set can be obtained. When the total result count is equal to 0, a fourth parameter is returned to the query control class. Only after receiving the fourth parameter returned by the total query class will the query control class return a first parameter to instruct the result set query class not to perform the result set query operation. This is because when the total result count is equal to 0, there are no query results in the paginated result set obtained by the result set query. In this embodiment, when the total result count is equal to 0, the result set query operation is not performed, and an empty value is returned directly, saving the time of result set query.

[0067] Considering that the existing Mybatis Plus framework uses the Page class to retrieve user-defined pagination parameters for pagination queries, and the Page class can include parameters such as current (current page number), size (number of items displayed per page), and searchCount (whether to perform a count query), but does not have a parameter indicating the query type, the following steps can be performed before responding to the user's pagination query operation:

[0068] Create a parameter retrieval class to retrieve the pagination parameters set by the user, including query type parameters.

[0069] Specifically, create a parameter retrieval class that can obtain query type parameters. For example, taking the PageParam named parameter retrieval class as an example, you can create a PageParam class that inherits from the Page class in the Mybatis Plus framework for retrieving pagination parameters, and then further add a variable in the PageParam class to retrieve the query type parameters.

[0070] When a user performs a paginated query, the user can set pagination parameters, such as query type, current page number, number of items to display per page, etc. The parameter retrieval class can retrieve the pagination parameters set by the user.

[0071] Based on this, step S01, the process of obtaining the query type parameters, can be as follows:

[0072] Get the query type parameters from the class.

[0073] Specifically, the query control class can obtain the query type parameter from the multiple pagination parameters obtained by the parameter retrieval class.

[0074] This application embodiment obtains pagination parameters, including query type parameters, set by the user through a parameter acquisition class. The query control class can obtain the required query type parameters from the pagination parameters obtained from the parameter acquisition class. The created parameter acquisition class extends the Page class in the Mybatis Plus framework used to obtain pagination parameters by adding query type parameters. This allows the query control class to obtain query type parameters, determine the type of query the user wants to perform, and then perform different content queries based on the query type set by the user.

[0075] The pagination query device provided in the embodiments of this application is described below. The pagination query device can be an interceptor in the Mybatis Plus framework. The pagination query device described below corresponds to the pagination query method described above.

[0076] First, combined Figure 2 The pagination query device will be introduced, such as... Figure 2 As shown, the pagination query device may include: a result set query unit 10, a query control unit 20, and a total count query unit 30;

[0077] The query control unit 20 includes:

[0078] The parameter retrieval subunit 201 is used to retrieve query type parameters in response to user pagination query operations;

[0079] The first calling subunit 202 is used to call the total number query class unit to perform a total result query when the query type parameter is only querying the total number, and to obtain the total result;

[0080] The first instruction subunit 203 is used to return a first parameter to the result set query class unit, the first parameter being used to instruct the result set query class unit not to perform the result set query operation.

[0081] Optionally, the query control unit may further include:

[0082] The second instruction subunit is used to return a second parameter to the result set query class unit after the parameter acquisition subunit has acquired the query type parameter. When the query type parameter is query result set only, the second parameter is used to instruct the result set query class unit to perform the result set query operation to obtain the paginated result set.

[0083] Optionally, the query control unit may further include:

[0084] The second calling subunit is used to call the total number query class unit to perform a total number result query when the query type parameter is the total number of queries and the result set, after the parameter acquisition subunit has acquired the query type parameter. The total number query class unit obtains the total number of results and the third parameter returned by the total number query class unit. The third parameter is the parameter returned by the total number query class unit to the query control class unit when the total number of results is greater than 0.

[0085] The third instruction subunit is used to return the second parameter to the result set query class unit to instruct the result set query class unit to perform a result set query operation to obtain a paginated result set.

[0086] Optionally, the query control unit may further include:

[0087] The third calling subunit is used to call the total number query class unit to perform a total number query after the parameter acquisition subunit has acquired the query type parameter. When the query type parameter is the total number of queries and the result set, the subunit obtains the total number of results and the fourth parameter returned by the total number query class unit. The fourth parameter is the parameter returned by the total number query class unit to the query control class unit when the total number of results is equal to 0.

[0088] The fourth instruction subunit is used to return the first parameter to the result set query class unit to instruct the result set query class unit not to perform the result set query operation.

[0089] Optionally, the pagination query device may further include:

[0090] The first creation unit is used to create a parameter acquisition class before the parameter acquisition subunit in the query control class unit acquires the query type parameters in response to the user's pagination query operation. The parameter acquisition class is used to acquire the pagination parameters set by the user, including the query type parameters.

[0091] Based on this, the process by which the parameter acquisition unit acquires the query type parameter may include:

[0092] The query type parameter in the parameter retrieval class is obtained.

[0093] The pagination query device provided in this application embodiment can be applied to pagination query equipment. Figure 3 The hardware structure block diagram of the pagination query device is shown below. Figure 3 The hardware structure of the device may include: at least one processor 1, at least one communication interface 2, at least one memory 3, and at least one communication bus 4;

[0094] In this embodiment of the application, the number of processor 1, communication interface 2, memory 3, and communication bus 4 is at least one, and processor 1, communication interface 2, and memory 3 communicate with each other through communication bus 4;

[0095] Processor 1 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.

[0096] Memory 3 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device;

[0097] The memory stores interceptors, including a query control class, a result set query class, and a total count query class. The processor can call the query control class stored in the memory, which is used to implement the various processing flows in the aforementioned pagination query scheme.

[0098] This application embodiment also provides a storage medium that can store a program suitable for execution by a processor, the program being used to implement the various processing flows in the aforementioned pagination query scheme.

[0099] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0100] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0101] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method of paging queries, the method comprising: The application relates to an interceptor applied to a Mybatis Plus framework, the interceptor comprising a query control class, a result set query class and a total number query class, and the method comprising the following steps: In response to a user's page query operation, the query control class is executed to implement the following steps: Obtaining a query type parameter; When the query type parameter is only a total number query, the total number query class is called to perform a result total number query, and a result total number is obtained; A first parameter is returned to the result set query class, and the first parameter is used to indicate that the result set query class does not perform a result set query operation.

2. The method of claim 1, wherein, After the query type parameter is obtained, the following steps are further included: When the query type parameter is only a result set query, a second parameter is returned to the result set query class, and the second parameter is used to indicate that the result set query class performs a result set query operation, and a page result set is obtained.

3. The method of claim 1, wherein, After the query type parameter is obtained, the following steps are further included: When the query type parameter is a total number query and a result set query, the total number query class is called to perform a result total number query, a result total number is obtained, and a third parameter returned by the total number query class is obtained, wherein the third parameter is a parameter returned by the total number query class to the query control class when the result total number is greater than 0; The second parameter is returned to the result set query class to indicate that the result set query class performs a result set query operation, and a page result set is obtained.

4. The method of claim 1, wherein, After the query type parameter is obtained, the following steps are further included: When the query type parameter is a total number query and a result set query, the total number query class is called to perform a total number query, a result total number is obtained, and a fourth parameter returned by the total number query class is obtained, wherein the fourth parameter is a parameter returned by the total number query class to the query control class when the result total number is equal to 0; The first parameter is returned to the result set query class to indicate that the result set query class does not perform a result set query operation.

5. The method of claim 1, wherein, The total number query class comprises: A PaginationInnerInterceptor class in the Mybatis Plus framework.

6. The method of claim 3, wherein, The third parameter is the same as the second parameter.

7. The method of claim 4, wherein, The fourth parameter is the same as the first parameter.

8. The method according to any one of claims 1 to 7, characterized in that, Before the operation in response to the user's page query, the following steps are further included: A parameter obtaining class is created, and the parameter obtaining class is used to obtain a page parameter set by a user, wherein the page parameter comprises a query type parameter; The query type parameter is obtained from the parameter obtaining class. Comprise:

9. A paging query apparatus, characterized by comprising: A query control class unit, a result set query class unit and a total number query class unit; The query control class unit comprises: A parameter obtaining subunit, which is used to obtain a query type parameter in response to a user's page query operation; A first calling subunit, which is used to call the total number query class unit to perform a result total number query when the query type parameter is only a total number query, and obtain a result total number; A first indicating subunit, which is used to return a first parameter to the result set query class unit, and the first parameter is used to indicate that the result set query class unit does not perform a result set query operation. Comprise:

10. A paging query device, characterized by A memory and a processor; ​ The memory is configured to store the interceptor, and the interceptor comprises a query control class, a result set query class and a total number query class. The processor is configured to execute the query control class to implement each step of the paging query method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Paging-query querying device and method based on primary key fields

    CN103886022A

  • Multi-table joint query efficiency improving method

    CN112069207A