Paging processing method, device, electronic device and storage medium

By parsing and storing paging parameters on the client, and using Java reflection technology to automatically judge and process paging query requests, the problems of inefficiency and code redundancy in traditional paging processing methods are solved, and more efficient paging processing and better code maintenance are achieved.

CN114840765BActive Publication Date: 2025-04-15CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210573843.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-24
Publication Date
2025-04-15
Estimated Expiration
2042-05-24

AI Technical Summary

Technical Problem

In traditional paging processing, developers need to manually parse and pass paging parameters and call paging operations manually, resulting in inefficiency, redundant code, poor readability and difficulty in maintaining.

Method used

By analyzing the paging parameters in the client's access request and storing the local thread variables, Java reflection technology is used to determine whether the access request is a paging query request, so as to directly obtain the target paging parameters and call the paging operation, and return the paging query result.

Benefits of technology

It improves the efficiency of paging processing, reduces redundant code, improves the readability and maintainability of the code, and avoids the tedious process of developers manually parsing and calling paging operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114840765B_ABST
    Figure CN114840765B_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, and provides a paging processing method, device, electronic device and storage medium. When receiving an access request from a client, firstly, a paging parameter in the access request is obtained and the paging parameter is transmitted in the whole calling process through a local thread variable, thereby solving the problem that a developer needs to manually parse the paging parameter and transmit it as a method parameter in a traditional paging method. Then, after determining that the access request is a paging query request through Java reflection technology, a target paging parameter corresponding to the paging query request is directly obtained from the local thread variable, a paging operation is called and a paging query result corresponding to the target paging parameter is returned, thereby solving the problem that a developer needs to manually call the paging operation in a traditional solution and improving the efficiency of paging processing.
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 processing, and in particular to a paging processing method, device, electronic equipment and storage medium. Background Art

[0002] Paging processing of massive data is an indispensable method. Paging processing can not only greatly reduce the time of data processing, but also save various hardware resources of the front-end and back-end, greatly improve the system response time and user experience of using the system. Paging scenarios can be seen everywhere, such as the dynamics loaded in WeChat Moments, the news loaded in the headlines every time, the details in the bank consumption records, etc.

[0003] The inventor found in the process of implementing the present invention that, in the web system with SSM (Spring MVC, Spring boot and Mybatis) as the architecture, the common practice is to use PageHelper plug-in, before calling data query at the application layer, first obtain paging parameters, then call paging operation, and finally perform business data query. These operations have nothing to do with business logic, but the same coding is required every time, so that the system is full of a large amount of redundant code, resulting in extremely low paging processing efficiency and very easy to make mistakes. In addition, a large amount of redundant code greatly reduces the readability and maintainability of the code, and also brings disaster to system maintenance. Summary of the invention

[0004] In view of the above, it is necessary to propose a paging processing method, device, electronic device and storage medium, which can improve the efficiency of paging processing.

[0005] A first aspect of the present invention provides a paging processing method, the method comprising:

[0006] In response to an access request from a client, the access request is parsed to obtain a paging parameter;

[0007] Storing the paging parameters in local thread variables;

[0008] Determine whether the access request is a paging query request by using Java reflection technology;

[0009] When it is determined through the Java reflection technology that the access request is the paging query request, obtaining a target paging parameter corresponding to the paging query request from the local thread variable;

[0010] Returns paginated query results according to the target pagination parameters.

[0011] In an optional implementation, parsing the access request to obtain the paging parameter includes:

[0012] Add Spring MVC filter based on Spring MVC framework;

[0013] Intercepting the access request by the Spring MVC filter;

[0014] The paging parameters are obtained by parsing the URL corresponding to the access request.

[0015] In an optional implementation, the determining whether the access request is a paging query request by using Java reflection technology includes:

[0016] Add Mybatis interceptor;

[0017] Intercept the access request of each data layer through the Mybatis interceptor;

[0018] According to the calling method of the Dao layer for the access request, the return type of the calling method is obtained through Java reflection technology;

[0019] It is determined whether the access request is a paging query request according to the return type.

[0020] In an optional implementation, judging whether the access request is a paging query request according to the return type includes:

[0021] Determine whether the return type is a paging type;

[0022] If the return type is a paging type, determining that the access request is the paging query request;

[0023] If the return type is not a paging type, it is determined that the access request is not a paging query request.

[0024] In an optional implementation, returning the paging query result according to the target paging parameter includes:

[0025] Get the specified page number in the target paging parameter;

[0026] Determine whether the specified page number is greater than the page number of the last page in the paginated query result;

[0027] If the specified page number is greater than the page number of the last page in the paginated query result, the data of the last page is returned;

[0028] If the specified page number is not greater than the page number of the last page in the paging query result, the data of the specified page number is returned.

[0029] In an optional implementation, after returning the data of the specified page number, the method further includes:

[0030] Obtaining the updated data of the specified page number and the paging identifier corresponding to the specified page number;

[0031] Storing the updated data of the specified page number in a local database;

[0032] Acquire the object corresponding to the updated data according to the paging identifier corresponding to the specified page number, search for other pages where the object is located, and acquire the corresponding paging identifiers of the other pages;

[0033] When the designated page number is closed, according to the page identifiers corresponding to the other pages, the refresh methods of the other pages are called to obtain the updated data from the local database and pass the updated data to the other pages;

[0034] Refresh the objects of the other pages according to the updated data to obtain the updated data of the other pages.

[0035] In an optional embodiment, the method further comprises:

[0036] An array is created, wherein the array includes a plurality of structures, each of which includes a paging identifier and an object corresponding to the paging identifier.

[0037] A second aspect of the present invention provides a paging processing device, the device comprising:

[0038] A parsing module, used to respond to an access request from a client, parse the access request, and obtain paging parameters;

[0039] A storage module, used for storing the paging parameters into a local thread variable;

[0040] A judgment module, used to judge whether the access request is a paging query request through Java reflection technology;

[0041] An acquisition module, configured to acquire a target paging parameter corresponding to the paging query request from the local thread variable when the access request is determined to be the paging query request through the Java reflection technology;

[0042] The query module is used to return the paging query result according to the target paging parameter.

[0043] A third aspect of the present invention provides an electronic device, the electronic device comprising a processor, the processor being configured to implement the paging processing method when executing a computer program stored in a memory.

[0044] A fourth aspect of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the paging processing method is implemented.

[0045] In summary, the paging processing method, device, electronic device and storage medium described in the present invention, when receiving an access request from a client, first obtains the paging parameters in the access request and passes the paging parameters through local thread variables in the entire calling process, which solves the problem that developers need to manually parse the paging parameters in the traditional paging method and pass them as method parameters. Then, after determining that the access request is a paging query request through Java reflection technology, the target paging parameters corresponding to the paging query request are directly obtained from the local thread variable, the paging operation is called and the paging query results corresponding to the target paging parameters are returned, which solves the problem that developers need to manually call the paging operation in the traditional solution, and improves the efficiency of paging processing. In addition, the background developer no longer needs to write paging code that is not related to the business, which greatly reduces the amount of redundant code in the system template, improves the readability of the code to a certain extent, and reduces the code compilation time. Less code means higher maintainability. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 It is a flow chart of the paging processing method provided in the first embodiment of the present invention.

[0047] Figure 2 It is a structural diagram of a paging processing device provided in Embodiment 2 of the present invention.

[0048] Figure 3 It is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION

[0049] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.

[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing embodiments in an optional embodiment and are not intended to limit the present invention.

[0051] The paging processing method provided by the embodiment of the present invention is executed by an electronic device, and accordingly, the paging processing device runs in the electronic device.

[0052] Embodiment 1

[0053] Figure 1 This is a flow chart of a paging processing method provided by Embodiment 1 of the present invention. The paging processing method specifically includes the following steps. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted.

[0054] S11, in response to an access request from a client, parsing the access request to obtain paging parameters.

[0055] The user may request access to data through the client's browser, for example, by inputting a page number in the client's browser to trigger an access request, thereby requesting access to data corresponding to the input page number.

[0056] The access request initiated by the client may be a GET request or a POST request. After receiving the access request from the client, the electronic device responds to the access request and parses the access request, thereby parsing the access request to obtain paging parameters.

[0057] The paging parameters refer to parameters for how to paginate the paging query results, and may include, but are not limited to: the number of paging pages (PageNo) and the paging size (PageSize). The paging size refers to the number of query data contained in each page.

[0058] In an optional implementation, parsing the access request to obtain the paging parameter includes:

[0059] Add Spring MVC filter based on Spring MVC framework;

[0060] Intercepting the access request by the Spring MVC filter;

[0061] The paging parameters are obtained by parsing the URL corresponding to the access request.

[0062] Spring MVC is a lightweight Web development framework based on the MVC design pattern provided by Spring, which is essentially equivalent to Servlet. Add OncePerRequestFilter in the Spring MVC framework as a Spring MVC filter.

[0063] After the access request is intercepted by the Spring MVC filter, the URL (Uniform Resource Locator) corresponding to the access request can be obtained, and then the paging parameters can be obtained by parsing the URL. When the access request is a GET request, the string corresponding to the URL can be parsed to obtain the paging parameters. When the access request is a POST request, the paging parameters can be obtained by parsing the request body of the POST request.

[0064] In an optional implementation, if the paging parameters cannot be obtained, the paging parameters are set to default values. Setting the paging parameters to default values ​​includes setting pageNo and pageSize to default values. For example, pageNo is set to 1 by default, and pageSize is set to 10 by default.

[0065] S12, storing the paging parameter in a local thread variable.

[0066] The paging parameters are stored in the local thread variables. In this way, there is no need to pass the paging parameters in the method call. In the subsequent paging operation, they can be taken out from the local thread variables at any time, which reduces the parameter passing process between methods and reduces the amount of code.

[0067] S13, determining whether the access request is a paging query request by using Java reflection technology.

[0068] First, determine which of the local thread variables are paging query requests, and after determining the paging query requests, call the paging operation.

[0069] In an optional implementation, the determining whether the access request is a paging query request by using Java reflection technology includes:

[0070] Add Mybatis interceptor;

[0071] Intercept the access request of each data layer through the Mybatis interceptor;

[0072] According to the calling method of the Dao layer for the access request, the return type of the calling method is obtained through Java reflection technology;

[0073] It is determined whether the access request is a paging query request according to the return type.

[0074] MyBatis is a persistence framework that supports customized SQL, stored procedures, and advanced mapping. MyBatis can use simple XML or annotations to configure and map native information, mapping interfaces and Java POJOs (Plain Ordinary Java Objects) into records in the database.

[0075] When each database query request reaches the data operation layer, the database query statement is written in the Dao layer. According to the calling method of the Dao layer, the return type of the calling method is obtained through Java reflection technology, so as to judge whether the access request is a paging query request based on the return type.

[0076] In an optional implementation, judging whether the access request is a paging query request according to the return type includes:

[0077] Determine whether the return type is a paging type;

[0078] If the return type is a paging type, determining that the access request is the paging query request;

[0079] If the return type is not a paging type, it is determined that the access request is not a paging query request.

[0080] If the return type is the paging type com.github.pagehelper.Page, it is determined that the access request is a paging query request.

[0081] If the return type is not the paging type com.github.pagehelper.Page, it is determined that the access request is not a paging query request.

[0082] S14, when it is determined through the Java reflection technology that the access request is the paging query request, obtaining a target paging parameter corresponding to the paging query request from the local thread variable.

[0083] If it is determined that the access request is a paging query request, the paging parameter is obtained from the local thread variable, and the paging code is inserted into the paging query request to call the paging operation.

[0084] If it is determined that the access request is not a paging query request, the access operation corresponding to the access request is executed and the access result is returned.

[0085] S15, returning paging query results according to the target paging parameters.

[0086] For the backend service system that uses MyBatis for database operations, it is inevitable to perform frequent query operations on the database. If all the data in the database is queried at once every time, the system performance will inevitably be greatly reduced. Especially for queries with a large amount of data, querying all the data at once will not only reduce system performance but also cause the system to crash. In this case, the paging query function is needed to query only part of the data at a time, which can not only improve system efficiency but also improve data utilization.

[0087] In an optional implementation, returning the paging query result according to the target paging parameter includes:

[0088] Get the specified page number in the target paging parameter;

[0089] Determine whether the specified page number is greater than the page number of the last page in the paginated query result;

[0090] If the specified page number is greater than the page number of the last page in the paginated query result, the data of the last page is returned;

[0091] If the specified page number is not greater than the page number of the last page in the paging query result, the data of the specified page number is returned.

[0092] In a scenario where multiple people are operating, it is easy for others to delete part of the data during the query, causing the page number being queried to exceed the maximum page number. In this embodiment, when the specified page number is greater than the last page during the paging query, the last page of data is queried. After this processing, the data cannot be found due to an error in the page number. The data cannot be found only when there is no data, thus avoiding the situation where the non-empty data query is empty.

[0093] In an optional implementation, after returning the data of the specified page number, the:

[0094] Obtaining the updated data of the specified page number and the paging identifier corresponding to the specified page number;

[0095] Storing the updated data of the specified page number in a local database;

[0096] Acquire the object corresponding to the updated data according to the paging identifier corresponding to the specified page number, search for other pages where the object is located, and acquire the corresponding paging identifiers of the other pages;

[0097] When the designated page number is closed, according to the page identifiers corresponding to the other pages, the refresh methods of the other pages are called to obtain the updated data from the local database and pass the updated data to the other pages;

[0098] Refresh the objects of the other pages according to the updated data to obtain the updated data of the other pages.

[0099] The designated page number refers to pageNo, and the paging identifier is used to distinguish different pages. In a specific implementation manner, the paging identifier is the URL of the page.

[0100] The refresh method can be "RefreshByRootPage()".

[0101] After the data of the specified page number is updated, it is saved in the database. In a specific application scenario, when the user updates the data of the specified page number and clicks Save, the updated data of the specified page number is stored in the database, and the paging identifier of the specified page number is obtained. The object is obtained according to the paging identifier of the specified page number, and the other pages where the object is located are found, and the paging identifiers of the other pages are obtained. At the same time, the specified page number is manually or automatically closed. According to the paging identifiers of other pages, the refresh method of other pages is called to refresh the objects of other pages from the database, thereby obtaining the refresh data of other pages, without waiting for the scheduled refresh or the user manually clicking refresh on other pages. When the user sees other pages, he can see the updated data of other pages that have been refreshed.

[0102] In the above optional implementation, by obtaining the updated data of the specified page number, finding the paging associated with the object according to the object of the specified page number and obtaining its paging identifier, calling the refresh method of the associated paging to refresh the associated paging, after the data of the specified page number is updated, the other associated paging can automatically and timely update the data without the need for manual refresh by the user.

[0103] In an optional embodiment, the method further comprises:

[0104] An array is created, wherein the array includes a plurality of structures, each of which includes a paging identifier and an object corresponding to the paging identifier.

[0105] A corresponding structure is established for the paging identifier and object of each page, that is, each structure includes two attributes, the paging identifier and the object.

[0106] In the above optional implementation, by establishing a structure including a paging identifier and an object, the object corresponding to the update data can be quickly obtained according to the paging identifier corresponding to the specified page number, so that the data can be quickly updated.

[0107] The paging processing method provided by the embodiment of the present invention, upon receiving an access request from a client, first obtains the paging parameters in the access request and passes the paging parameters through the local thread variables in the entire calling process, thereby solving the problem that developers need to manually parse the paging parameters and pass them as method parameters in the traditional paging method. Then, after determining that the access request is a paging query request through Java reflection technology, the target paging parameters corresponding to the paging query request are directly obtained from the local thread variables, the paging operation is called and the paging query results corresponding to the target paging parameters are returned, thereby solving the problem that developers need to manually call the paging operation in the traditional solution and improving the efficiency of paging processing. In addition, the backend developers no longer need to write paging codes that are not related to the business, which greatly reduces the amount of redundant code in the system template style, improves the readability of the code to a certain extent, and reduces the code compilation time. Less code means higher maintainability.

[0108] Embodiment 2

[0109] Figure 2 It is a structural diagram of a paging processing device provided in Embodiment 2 of the present invention.

[0110] In some embodiments, the paging processing device 20 may include a plurality of functional modules composed of computer program segments. The computer programs of the various program segments in the paging processing device 20 may be stored in a memory of an electronic device and executed by at least one processor to execute (see Figure 1 Description) Functionality for paging processing.

[0111] In this embodiment, the paging processing device 20 can be divided into multiple functional modules according to the functions it performs. The functional modules may include: a parsing module 201, a storage module 202, a judgment module 203, an acquisition module 204, a query module 205 and a refresh module 206. The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0112] The parsing module 201 is used to respond to the access request of the client, parse the access request and obtain the paging parameters.

[0113] The user may request access to data through the client's browser, for example, by inputting a page number in the client's browser to trigger an access request, thereby requesting access to data corresponding to the input page number.

[0114] The access request initiated by the client may be a GET request or a POST request. After receiving the access request from the client, the electronic device responds to the access request and parses the access request, thereby parsing the access request to obtain paging parameters.

[0115] The paging parameters refer to parameters for how to paginate the paging query results, and may include, but are not limited to: the number of paging pages (PageNo) and the paging size (PageSize). The paging size refers to the number of query data contained in each page.

[0116] In an optional implementation, the parsing module 201 parses the access request to obtain paging parameters including:

[0117] Add Spring MVC filter based on Spring MVC framework;

[0118] Intercepting the access request by the Spring MVC filter;

[0119] The paging parameters are obtained by parsing the URL corresponding to the access request.

[0120] Spring MVC is a lightweight Web development framework based on the MVC design pattern provided by Spring, which is essentially equivalent to Servlet. Add OncePerRequestFilter in the Spring MVC framework as a Spring MVC filter.

[0121] After the access request is intercepted by the Spring MVC filter, the URL (Uniform Resource Locator) corresponding to the access request can be obtained, and then the paging parameters can be obtained by parsing the URL. When the access request is a GET request, the string corresponding to the URL can be parsed to obtain the paging parameters. When the access request is a POST request, the paging parameters can be obtained by parsing the request body of the POST request.

[0122] In an optional implementation, if the paging parameters cannot be obtained, the paging parameters are set to default values. Setting the paging parameters to default values ​​includes setting pageNo and pageSize to default values. For example, pageNo is set to 1 by default, and pageSize is set to 10 by default.

[0123] The storing module 202 is used to store the paging parameters into local thread variables.

[0124] The paging parameters are stored in the local thread variables. In this way, there is no need to pass the paging parameters in the method call. In the subsequent paging operation, they can be taken out from the local thread variables at any time, which reduces the parameter passing process between methods and reduces the amount of code.

[0125] The determination module 203 is used to determine whether the access request is a paging query request by using Java reflection technology.

[0126] First, determine which of the local thread variables are paging query requests, and after determining the paging query requests, call the paging operation.

[0127] In an optional implementation, the determining module 203 determines whether the access request is a paging query request by using Java reflection technology, including:

[0128] Add Mybatis interceptor;

[0129] Intercept the access request of each data layer through the Mybatis interceptor;

[0130] According to the calling method of the Dao layer for the access request, the return type of the calling method is obtained through Java reflection technology;

[0131] It is determined whether the access request is a paging query request according to the return type.

[0132] MyBatis is a persistence framework that supports customized SQL, stored procedures, and advanced mapping. MyBatis can use simple XML or annotations to configure and map native information, mapping interfaces and Java POJOs (Plain Ordinary Java Objects) into records in the database.

[0133] When each database query request reaches the data operation layer, the database query statement is written in the Dao layer. According to the calling method of the Dao layer, the return type of the calling method is obtained through Java reflection technology, so as to judge whether the access request is a paging query request based on the return type.

[0134] In an optional implementation, judging whether the access request is a paging query request according to the return type includes:

[0135] Determine whether the return type is a paging type;

[0136] If the return type is a paging type, determining that the access request is the paging query request;

[0137] If the return type is not a paging type, it is determined that the access request is not a paging query request.

[0138] If the return type is the paging type com.github.pagehelper.Page, it is determined that the access request is a paging query request.

[0139] If the return type is not the paging type com.github.pagehelper.Page, it is determined that the access request is not a paging query request.

[0140] The acquisition module 204 is used to acquire the target paging parameter corresponding to the paging query request from the local thread variable when it is determined that the access request is the paging query request through the Java reflection technology.

[0141] If it is determined that the access request is a paging query request, the paging parameter is obtained from the local thread variable, and the paging code is inserted into the paging query request to call the paging operation.

[0142] If it is determined that the access request is not a paging query request, the access operation corresponding to the access request is executed and the access result is returned.

[0143] The query module 205 is used to return a paging query result according to the target paging parameter.

[0144] For the backend service system that uses MyBatis for database operations, it is inevitable to perform frequent query operations on the database. If all the data in the database is queried at once every time, the system performance will inevitably be greatly reduced. Especially for queries with a large amount of data, querying all the data at once will not only reduce system performance but also cause the system to crash. In this case, the paging query function is needed to query only part of the data at a time, which can not only improve system efficiency but also improve data utilization.

[0145] In an optional implementation, the query module 205 returns the paging query result according to the target paging parameter, including:

[0146] Get the specified page number in the target paging parameter;

[0147] Determine whether the specified page number is greater than the page number of the last page in the paginated query result;

[0148] If the specified page number is greater than the page number of the last page in the paginated query result, the data of the last page is returned;

[0149] If the specified page number is not greater than the page number of the last page in the paging query result, the data of the specified page number is returned.

[0150] In a scenario where multiple people are operating, it is easy for others to delete part of the data during the query, causing the page number being queried to exceed the maximum page number. In this embodiment, when the specified page number is greater than the last page during the paging query, the last page of data is queried. After this processing, the data cannot be found due to an error in the page number. The data cannot be found only when there is no data, thus avoiding the situation where the non-empty data query is empty.

[0151] In an optional implementation, after returning the data of the specified page number, the refresh module 206 is used to:

[0152] Obtaining the updated data of the specified page number and the paging identifier corresponding to the specified page number;

[0153] Storing the updated data of the specified page number in a local database;

[0154] Acquire the object corresponding to the updated data according to the paging identifier corresponding to the specified page number, search for other pages where the object is located, and acquire the corresponding paging identifiers of the other pages;

[0155] When the designated page number is closed, according to the page identifiers corresponding to the other pages, the refresh methods of the other pages are called to obtain the updated data from the local database and pass the updated data to the other pages;

[0156] Refresh the objects of the other pages according to the updated data to obtain the updated data of the other pages.

[0157] The designated page number refers to pageNo, and the paging identifier is used to distinguish different pages. In a specific implementation manner, the paging identifier is the URL of the page.

[0158] The refresh method can be "RefreshByRootPage()".

[0159] After the data of the specified page number is updated, it is saved in the database. In a specific application scenario, when the user updates the data of the specified page number and clicks Save, the updated data of the specified page number is stored in the database, and the paging identifier of the specified page number is obtained. The object is obtained according to the paging identifier of the specified page number, and the other pages where the object is located are found, and the paging identifiers of the other pages are obtained. At the same time, the specified page number is manually or automatically closed. According to the paging identifiers of other pages, the refresh method of other pages is called to refresh the objects of other pages from the database, thereby obtaining the refresh data of other pages, without waiting for the scheduled refresh or the user manually clicking refresh on other pages. When the user sees other pages, he can see the updated data of other pages that have been refreshed.

[0160] In the above optional implementation, by obtaining the updated data of the specified page number, finding the paging associated with the object according to the object of the specified page number and obtaining its paging identifier, calling the refresh method of the associated paging to refresh the associated paging, after the data of the specified page number is updated, the other associated paging can automatically and timely update the data without the need for manual refresh by the user.

[0161] In an optional implementation, the refresh module 206 is further configured to:

[0162] An array is created, wherein the array includes a plurality of structures, each of which includes a paging identifier and an object corresponding to the paging identifier.

[0163] A corresponding structure is established for the paging identifier and object of each page, that is, each structure includes two attributes, the paging identifier and the object.

[0164] In the above optional implementation, by establishing a structure including a paging identifier and an object, the object corresponding to the update data can be quickly obtained according to the paging identifier corresponding to the specified page number, so that the data can be quickly updated.

[0165] The paging processing device provided by the embodiment of the present invention, upon receiving an access request from a client, first obtains the paging parameters in the access request and passes the paging parameters through local thread variables in the entire calling process, thereby solving the problem that developers need to manually parse the paging parameters and pass them as method parameters in the traditional paging method. Then, after determining that the access request is a paging query request through Java reflection technology, the target paging parameters corresponding to the paging query request are directly obtained from the local thread variables, the paging operation is called and the paging query results corresponding to the target paging parameters are returned, thereby solving the problem that developers need to manually call the paging operation in the traditional solution and improving the efficiency of paging processing. In addition, the backend developers no longer need to write paging codes that are not related to the business, which greatly reduces the amount of redundant code in the system template style, improves the readability of the code to a certain extent, and reduces the code compilation time. Less code means higher maintainability.

[0166] Embodiment 3

[0167] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned paging processing method embodiment are implemented, for example: Figure 1 S11-S15 shown:

[0168] S11, in response to an access request from a client, parsing the access request to obtain a paging parameter;

[0169] S12, storing the paging parameter in a local thread variable;

[0170] S13, determining whether the access request is a paging query request by using Java reflection technology;

[0171] S14, when it is determined through the Java reflection technology that the access request is the paging query request, obtaining a target paging parameter corresponding to the paging query request from the local thread variable;

[0172] S15, returning paging query results according to the target paging parameters.

[0173] Alternatively, when the computer program is executed by a processor, the functions of each module / unit in the above-mentioned device embodiment are realized, for example Figure 2 Modules 201-206:

[0174] The parsing module 201 is used to respond to the access request of the client, parse the access request and obtain the paging parameters;

[0175] The storage module 202 is used to store the paging parameters into local thread variables;

[0176] The judging module 203 is used to judge whether the access request is a paging query request by using Java reflection technology;

[0177] The acquisition module 204 is used to acquire the target paging parameter corresponding to the paging query request from the local thread variable when the access request is determined to be the paging query request through the Java reflection technology;

[0178] The query module 205 is used to return a paging query result according to the target paging parameter.

[0179] When the computer program is executed by the processor, the refresh module 206 in the above device embodiment is also implemented. For details, please refer to the second embodiment and its related description.

[0180] Embodiment 4

[0181] See also Figure 3 FIG. 2 is a schematic diagram of the structure of an electronic device provided by Embodiment 4 of the present invention. In a preferred embodiment of the present invention, the electronic device 3 includes a memory 31 , at least one processor 32 , at least one communication bus 33 and a transceiver 34 .

[0182] Those skilled in the art should understand that Figure 3The structure of the electronic device shown does not constitute a limitation of the embodiments of the present invention, and may be a bus structure or a star structure. The electronic device 3 may also include more or less other hardware or software than shown in the figure, or a different component arrangement.

[0183] In some embodiments, the electronic device 3 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices. The electronic device 3 may also include client devices, which include but are not limited to any electronic product that can interact with a client through a keyboard, mouse, remote control, touchpad, or voice-controlled device, such as a personal computer, tablet computer, smart phone, digital camera, etc.

[0184] It should be noted that the electronic device 3 is only an example, and other existing or future electronic products that are suitable for the present invention should also be included in the protection scope of the present invention and included here by reference.

[0185] In some embodiments, the memory 31 stores a computer program, and when the computer program is executed by the at least one processor 32, all or part of the steps in the paging processing method are implemented. The memory 31 includes a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0186] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.

[0187] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0188] In some embodiments, the at least one processor 32 is the control core (ControlUnit) of the electronic device 3, and uses various interfaces and lines to connect various components of the entire electronic device 3, and executes various functions and processes data of the electronic device 3 by running or executing programs or modules stored in the memory 31, and calling data stored in the memory 31. For example, when the at least one processor 32 executes the computer program stored in the memory, it implements all or part of the steps of the paging processing method described in the embodiment of the present invention; or implements all or part of the functions of the paging processing device. The at least one processor 32 can be composed of an integrated circuit, for example, it can be composed of a single packaged integrated circuit, or it can be composed of multiple integrated circuits with the same function or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and a combination of various control chips.

[0189] In some embodiments, the at least one communication bus 33 is configured to implement connection and communication between the memory 31 and the at least one processor 32, etc.

[0190] Although not shown, the electronic device 3 may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 32 through a power management device, so that the power management device can manage charging, discharging, and power consumption management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device 3 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.

[0191] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, electronic device, or network device, etc.) or a processor to execute a part of the method described in each embodiment of the present invention.

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

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

[0194] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0195] It is obvious to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "including" does not exclude other units or, and the singular does not exclude the plural. Multiple units or devices stated in the specification may also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.

[0196] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.

Claims

1. A paging processing method, characterized in that: The method comprises: In response to an access request from a client, the access request is parsed to obtain paging parameters, including: adding a Spring MVC filter based on a Spring MVC framework; intercepting the access request by the Spring MVC filter; parsing the URL corresponding to the access request to obtain the paging parameters; when the access request is a GET request, parsing the string corresponding to the URL to obtain the paging parameters; when the access request is a POST request, parsing the request body of the POST request to obtain the paging parameters; Storing the paging parameters in local thread variables; Determining whether the access request in the local thread variable is a paging query request by using Java reflection technology, including: adding a Mybatis interceptor; intercepting the access request of each data layer by using the Mybatis interceptor; obtaining the return type of the calling method by using Java reflection technology according to the calling method of the Dao layer for the access request; determining whether the access request is a paging query request according to the return type; When it is determined through the Java reflection technology that the access request is the paging query request, obtaining a target paging parameter corresponding to the paging query request from the local thread variable; Returns paginated query results according to the target pagination parameters.

2. The paging processing method according to claim 1, characterized in that: The determining, according to the return type, whether the access request is a paging query request comprises: Determine whether the return type is a paging type; If the return type is a paging type, determining that the access request is the paging query request; If the return type is not a paging type, it is determined that the access request is not a paging query request.

3. The paging processing method according to any one of claims 1 to 2, characterized in that: The returning of the paging query result according to the target paging parameter comprises: Get the specified page number in the target paging parameter; Determine whether the specified page number is greater than the page number of the last page in the paginated query result; If the specified page number is greater than the page number of the last page in the paginated query result, the data of the last page is returned; If the specified page number is not greater than the page number of the last page in the paging query result, the data of the specified page number is returned.

4. The paging processing method according to claim 3, characterized in that: After returning the data of the specified page number, the method further includes: Obtaining the updated data of the specified page number and the paging identifier corresponding to the specified page number; Storing the updated data of the specified page number in a local database; Acquire the object corresponding to the updated data according to the paging identifier corresponding to the specified page number, search for other pages where the object is located, and acquire the corresponding paging identifiers of the other pages; When the designated page number is closed, according to the page identifiers corresponding to the other pages, the refresh methods of the other pages are called to obtain the updated data from the local database and pass the updated data to the other pages; Refresh the objects of the other pages according to the updated data to obtain the updated data of the other pages.

5. The paging processing method according to claim 4, characterized in that: The method further comprises: An array is created, wherein the array includes a plurality of structures, each of which includes a paging identifier and an object corresponding to the paging identifier.

6. A paging processing device, characterized in that: The device comprises: A parsing module is used to respond to an access request from a client, parse the access request, and obtain paging parameters, including: adding a Spring MVC filter based on the Spring MVC framework; intercepting the access request through the Spring MVC filter; parsing the URL corresponding to the access request to obtain the paging parameters; when the access request is a GET request, parsing the string corresponding to the URL to obtain the paging parameters; when the access request is a POST request, parsing the request body of the POST request to obtain the paging parameters; A storage module, used for storing the paging parameters into a local thread variable; A judgment module, used for judging whether the access request in the local thread variable is a paging query request through Java reflection technology, including: adding a Mybatis interceptor; intercepting the access request of each data layer through the Mybatis interceptor; obtaining the return type of the calling method through Java reflection technology according to the calling method of the Dao layer for the access request; judging whether the access request is a paging query request according to the return type; An acquisition module, configured to acquire a target paging parameter corresponding to the paging query request from the local thread variable when the access request is determined to be the paging query request through the Java reflection technology; The query module is used to return the paging query result according to the target paging parameter.

7. An electronic device, characterized in that: The electronic device comprises a processor and a memory, and the processor is used to implement the paging processing method as claimed in any one of claims 1 to 5 when executing a computer program stored in the memory.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the paging processing method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Multi-table joint query efficiency improving method

    CN112069207A