Method and system for dynamically filtering list data

By adding filtering identifiers to the interface and setting multiple sets of filtering parameters, the total filtering conditions are dynamically generated, which solves the problems in the existing technology of being unable to independently modify the interface filtering rules and insufficient flexibility, achieving flexible and accurate data filtering, and adapting to complex requirements of business scenarios.

CN118733573APending Publication Date: 2024-10-01西藏众陶联供应链服务有限公司 +4
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410747649.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

The existing technology cannot support independent modification of the filtering rules of the interface and lacks flexibility, resulting in the inability to meet diverse needs in complex business scenarios and affecting the efficiency of data filtering and user experience.

Method used

By adding filtering identifiers to interfaces and setting multiple sets of filtering parameters, total filtering conditions are dynamically generated, allowing dynamic configuration and adjustment of filtering conditions according to needs, and supporting custom annotations and meta-annotations to control filtering behavior and scope.

Benefits of technology

It realizes customized filtering for different interfaces, improves the accuracy and efficiency of data filtering, reduces unnecessary data transmission and processing costs, and adapts to the needs of different application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733573A_ABST
    Figure CN118733573A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data filtering, and provides a method and system for dynamically filtering list data, and the method comprises the steps: adding a filtering identifier for an interface; setting filtering parameters according to requirements, adding a plurality of groups of filtering parameters for the interface, and storing an interface path corresponding to the interface and mapping of the filtering parameters into a storage space; accessing an interface needing data filtering, obtaining a plurality of groups of filtering parameters corresponding to the interface needing data filtering from a storage space, generating a plurality of sub-filtering conditions, and generating a total filtering condition according to the sub-filtering conditions, and filtering the data to be returned in the interface needing data filtering according to the total filtering condition. Aiming at the characteristics and data requirements of different interfaces, the most suitable filtering condition is designed, and the accuracy and efficiency of data filtering are improved; by dynamically generating the total filtering condition and filtering the data, unnecessary data transmission and processing cost can be effectively reduced at the server side.
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 filtering, and in particular to a method and system for dynamically filtering list data. Background Art

[0002] In existing data processing and interface design, data filtering is often a key function that allows the system to limit the data returned to the requester based on specific rules or conditions. However, there are some limitations and deficiencies in current technical implementations that affect the flexibility and efficiency of data filtering.

[0003] Most systems only support simple filtering based on user identity, such as filtering data based on user ID. Although this method is suitable for some scenarios, it cannot meet the diverse needs of complex business scenarios. For example, in an e-commerce system, it may be necessary to filter order data based on multiple dimensions such as order number, amount, and product category, but existing technologies cannot provide such flexibility.

[0004] Secondly, existing technologies generally do not support modifying the filtering rules of a certain interface individually. Once the data filtering rules of an interface are defined, the entire system needs to be modified to change the rule. This not only increases the complexity of development and maintenance, but also may cause unnecessary system downtime or performance degradation. In a rapidly changing business environment, this limitation may cause the system to be unable to respond to business changes in a timely manner, thereby affecting user experience and business efficiency.

[0005] However, in actual development, how to efficiently filter the list data returned by the interface has become an urgent problem to be solved. Summary of the invention

[0006] In view of the above defects, the purpose of the present invention is to propose a method and system for dynamically filtering list data to solve the problems of not supporting the modification of filtering rules of a certain interface individually and not being able to dynamically compile rules and lack of flexibility.

[0007] To achieve this object, the present invention adopts the following technical solutions:

[0008] A method for dynamically filtering list data, comprising:

[0009] Add a filter identifier to the interface that needs data filtering, and the filter identifier is used to determine whether the data of the interface needs to be filtered;

[0010] Several groups of filtering parameters are set according to the requirements, several groups of filtering parameters are added to the interfaces that need to perform data filtering, and the mapping of the interface paths corresponding to the interfaces that need to perform data filtering and the filtering parameters is stored in the storage space, and each group of filtering parameters corresponds to a sub-filtering condition;

[0011] Access the interface that needs to perform data filtering, obtain several groups of filtering parameters corresponding to the interface that needs to perform data filtering from the storage space and generate several sub-filtering conditions, generate a total filtering condition based on the sub-filtering conditions, and filter the data to be returned in the interface that needs to perform data filtering according to the total filtering condition.

[0012] Preferably, adding a filtering identifier to the interface that needs to filter data includes:

[0013] Create a custom annotation, declare the properties of the custom annotation, and use the custom annotation as the filter identifier;

[0014] Add a meta-annotation to the custom annotation, where the meta-annotation is used to control the behavior and scope of the custom annotation;

[0015] The custom annotation is added to the interface that needs to perform data filtering, and the interface path is set as the attribute value of the attribute.

[0016] Preferably, the obtaining the filter parameter from the storage space further comprises: using a first annotation to declare a pointcut for an interface containing the filter identifier;

[0017] Using the second annotation, the filter parameter is obtained from the storage space before and after the method matched by the pointcut is executed.

[0018] Preferably, the filtering parameters include: a filter name, a filter field, a filter comparison operator, a filter field value, and a filter connector;

[0019] The filter connector is used to connect the sub-filter conditions into the overall filter condition.

[0020] Preferably, before adding a plurality of groups of filtering parameters to the interface that needs to perform data filtering, the method includes:

[0021] Acquire from the storage space the filtering parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering;

[0022] Generate several sub-filter conditions to be added according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters to be added, and generate several comparison sub-filter conditions according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering;

[0023] According to each of the sub-filtering conditions to be added and its corresponding filter connector, it is judged whether conflicts occur with the compared sub-filtering conditions one by one. If conflicts occur, it is prompted that the filter parameters corresponding to the conflicts are added incorrectly, otherwise the addition is successful.

[0024] Preferably, the obtaining of several groups of filtering parameters corresponding to the interfaces requiring data filtering from the storage space and generating several sub-filtering conditions, and generating the overall filtering condition according to the sub-filtering conditions comprises:

[0025] Acquire the attribute value of the custom annotation of the interface that needs to perform data filtering, and acquire several groups of filtering parameters corresponding to the interface that needs to perform data filtering from the storage space according to the attribute value;

[0026] The filter field, filter comparison operator and filter field value in the filter parameter corresponding to the interface that needs to filter data are concatenated to generate a sub-filter condition;

[0027] The sub-filtering conditions are connected according to the filter connector to generate the overall filter condition.

[0028] A system for dynamically filtering list data, comprising:

[0029] A filter identifier adding module is used to add filter identifiers to interfaces that require data filtering;

[0030] A filtering parameter setting module, used to set several groups of filtering parameters according to requirements, add several groups of filtering parameters for the interfaces that need to perform data filtering, and store the mapping between the interface path corresponding to the interface that needs to perform data filtering and the filtering parameters in a storage space;

[0031] The filter condition generation module is used to obtain several groups of filter parameters corresponding to the interfaces that need to be filtered from the storage space and generate several sub-filter conditions, generate a total filter condition based on the sub-filter conditions, and filter the data to be returned from the interfaces that need to be filtered based on the total filter condition.

[0032] Furthermore, the filter identifier adding module is specifically used to:

[0033] Create a custom annotation, declare the attributes of the custom annotation, and use the custom annotation as the filtering identifier; add a meta-annotation to the custom annotation, where the meta-annotation is used to control the behavior and scope of the custom annotation; add the custom annotation to the interface that needs to filter data, and set the interface path as the attribute value of the attribute;

[0034] The filter parameters include: a filter name, a filter field, a filter comparison operator, a filter field value, and a filter connector; the filter connector is used to connect the sub-filter conditions into the overall filter condition.

[0035] Furthermore, the filtering parameter setting module is specifically used to:

[0036] Using the first annotation to declare a pointcut for the interface containing the filter identifier; using the second annotation to obtain the filter parameter from the storage space before and after the method matched by the pointcut is executed;

[0037] Acquire from the storage space the filtering parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering;

[0038] Generate several sub-filter conditions to be added according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters to be added, and generate several comparison sub-filter conditions according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering;

[0039] According to each of the sub-filtering conditions to be added and its corresponding filter connector, it is judged whether conflicts occur with the compared sub-filtering conditions one by one. If conflicts occur, it is prompted that the filter parameters corresponding to the conflicts are added incorrectly, otherwise the addition is successful.

[0040] The filtering condition generating module is specifically used for:

[0041] Acquire the attribute value of the custom annotation of the interface that needs to perform data filtering, and acquire several groups of filtering parameters corresponding to the interface that needs to perform data filtering from the storage space according to the attribute value;

[0042] The filter field, filter comparison operator and filter field value in the filter parameter corresponding to the interface that needs to filter data are concatenated to generate a sub-filter condition;

[0043] The sub-filtering conditions are connected according to the filter connector to generate the overall filter condition.

[0044] One of the above technical solutions has the following advantages or beneficial effects:

[0045] By adding filter identifiers and setting filter parameters for interfaces, data filter conditions can be dynamically configured and adjusted according to needs, making the filter strategy more flexible and adaptable to different application scenarios and needs; multiple groups of filter parameters can be set according to actual needs, and each group of parameters corresponds to a sub-filter condition, so as to achieve customized filtering for different interfaces. In this way, the most suitable filter conditions can be designed according to the characteristics and data requirements of different interfaces, improving the accuracy and efficiency of data filtering; by dynamically generating total filter conditions and filtering data, unnecessary data transmission and processing costs can be effectively reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0047] Figure 1 is a flowchart of a method for dynamically filtering list data provided by an embodiment of the present invention;

[0048] Figure 2 It is a structural diagram of a system for dynamically filtering list data provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0049] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.

[0050] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.

[0051] like Figure 1 As shown, a preferred embodiment of the present application includes:

[0052] Step S1: adding a filtering identifier to an interface that needs to perform data filtering, wherein the filtering identifier is used to determine whether data on the interface needs to be filtered.

[0053] The filter identifier can be a field, metadata or annotation. When accessing the interface, check whether the interface has a filter identifier. If not, there is no need to filter the data of the interface. If there is a filter identifier, data filtering is required.

[0054] Specifically, a field may be added to the definition or configuration of the interface to set a filter identifier; or metadata or annotations of the interface may be used as a filter identifier to indicate whether data filtering is required.

[0055] Step S2: Set several groups of filtering parameters according to needs, add several groups of filtering parameters for the interfaces that need data filtering, store the mapping of the interface path corresponding to the interface that needs data filtering and the filtering parameters into the storage space, and each group of filtering parameters corresponds to a sub-filtering condition.

[0056] Specifically, the data types obtained by different page access interfaces are consistent, but different pages have different requirements for the same type of data, so different pages can set different groups of filtering parameters, and save the mapping relationship between the interface path corresponding to the interface that needs data filtering and multiple groups of filtering parameters to the storage space. When setting the filtering parameters, the filtering parameters are set in the filtering parameter setting page. It is worth noting that the storage space can be a tool for storing the mapping relationship between the interface path and the filtering parameters, such as a database, a cache or other storage medium. For example, this mapping relationship can be represented by a table of a mysql database. In the mysql database, the interface path of the user interface and the first group of filtering parameters are placed in the same row to represent the first sub-filtering condition of the user interface, and the interface path of the user interface and the second group of filtering parameters are placed in another row to represent the second sub-filtering condition of the user interface.

[0057] Step S3: Access the interface that needs to perform data filtering, obtain several groups of filtering parameters corresponding to the interface that needs to perform data filtering from the storage space and generate several sub-filtering conditions, generate a total filtering condition based on the sub-filtering conditions, and filter the data to be returned in the interface that needs to perform data filtering according to the total filtering condition.

[0058] Specifically, when a visitor accesses an interface that requires data filtering, the interface path of the interface that requires data filtering is first used to obtain filtering parameters corresponding to the interface that requires data filtering from the storage space. The filtering parameters are one or more groups, and each group of filtering parameters corresponds to a sub-filtering condition. For example, the sub-filtering condition corresponding to the first group of filtering parameters is that the user number is greater than 3, and the sub-filtering condition corresponding to the second group of filtering parameters is that the user number is less than 5. The total filtering condition is that the user number is greater than 3 and less than 5. The total filtering condition is used to hide the data with user numbers greater than 3 and less than 5 in the data to be returned by the interface, and not send it to the visitor.

[0059] By adding filter identifiers and setting filter parameters for interfaces, data filter conditions can be dynamically configured and adjusted according to needs, making the filter strategy more flexible and adaptable to different application scenarios and needs; multiple groups of filter parameters can be set according to actual needs, and each group of parameters corresponds to a sub-filter condition, so as to achieve customized filtering for different interfaces. In this way, the most suitable filter conditions can be designed according to the characteristics and data requirements of different interfaces, improving the accuracy and efficiency of data filtering; by dynamically generating total filter conditions and filtering data, unnecessary data transmission and processing costs can be effectively reduced on the server side.

[0060] In another preferred embodiment of the present application, adding a filter identifier to an interface that needs to filter data includes step S101: creating a custom annotation, declaring the properties of the custom annotation, and using the custom annotation as the filter identifier;

[0061] Step S102: adding a meta-annotation to the custom annotation, wherein the meta-annotation is used to control the behavior and scope of the custom annotation;

[0062] Step S103: Add the custom annotation to the interface that needs to perform data filtering, and set the interface path as the attribute value of the attribute.

[0063] Among them, custom annotations are special tags defined by users in Java to describe metadata information of programs. Attributes are member variables in custom annotations, which can set default values ​​or specify specific values ​​when the annotations are used. Meta-annotations are special annotations used to modify other annotations, which can control the behavior and scope of the modified annotations.

[0064] Specifically, use the @interface keyword to create a custom annotation to mark the interface that needs to be filtered, and declare the attributes of the annotation. Add meta-annotations to the custom annotation, such as @Target, which is used to specify the program element type to which the modified annotation can be applied, such as class, field, method, etc., and @Retention, which is used to specify the retention strategy of the modified annotation, that is, when the annotation is valid, including three retention strategies: SOURCE, CLASS and RUNTIME. This embodiment uses RUNTIME to specify the usage and scope of the annotation. Annotate the interface that needs to be filtered, and specify the attribute value of the annotation. The attribute value corresponds to the interface path of the interface, that is, the attribute value is used to distinguish the filtering conditions required for different interfaces. Combined with Java annotations, the interface that needs to be filtered is marked by custom annotations in the Java program, and the data filtering identifier is marked on the interface through annotations, so that the logic of data filtering can be separated from the business logic. Doing so helps to reduce the coupling between modules and improve the maintainability and scalability of interface functions.

[0065] Furthermore, the step of obtaining the filter parameter from the storage space further includes step S301: using a first annotation to declare a pointcut for an interface containing the filter identifier;

[0066] Step S302: using the second annotation, obtaining the filter parameter from the storage space before and after the method matched by the cut point is executed.

[0067] The first annotation is @Pointcut, and the second annotation is @Around. The @Pointcut annotation is used to define pointcuts, that is, to select specific connection points in the application, and to select connection points that match specific conditions, that is, to match interfaces with filter identifiers. Some cross-cutting concerns can be applied before or after method execution, such as permission verification, logging, and other operations. The @Around annotation is used to define an around notification, which can execute additional logic before and after a method call, including whether to execute the original method and when to execute it.

[0068] Specifically, pointcuts are defined using annotations provided by Spring, for example, @Pointcut("@annotation(org.jeecg.common.aspect.annotation.Permission UrlData), where PermissionUrlData is a custom annotation used as a filter identifier. This pointcut expression matches all PermissionUrlData annotations under the package path org.jeecg.common.aspect.annotation, which means that all interface methods with PermissionUrlData annotations will be affected by the pointcut. Use @Around to define an around notification, and get the filter parameters from the storage space before and after the interface method that needs to filter data is executed. For example, use @Around("pointcut()") to act on the pointcut defined by the pointcut() method, that is, the custom annotation containing PermissionUrlData as a filter identifier, to get the filter parameters from the storage space before and after the interface method that needs to filter data is executed. This can solve the need to get the filter parameters before and after the method is executed, and realize the ability to dynamically process the filter conditions. It can cope with the situation where the filter conditions change before and after the interface is accessed. The modular management of cross-cutting concerns is realized through AOP, which reduces the writing of duplicate code and improves the scalability and flexibility of the system.

[0069] Furthermore, the filtering parameters include: a filter name, a filter field, a filter comparison operator, a filter field value, and a filter connector;

[0070] The filter connector is used to connect the sub-filter conditions into the overall filter condition.

[0071] Specifically, taking the above-mentioned MySQL database as an example, the fields contained in the MySQL database include filter name ruleName, filter field ruleFiled, filter comparison operator ruleCondition, filter field value ruleValue and filter connector ruleConnector, which are collectively referred to as filter parameters and are stored in the MySQL database in a one-to-one correspondence with the interface path pagePath. Among them, the filter name ruleName is used to identify the name or description of the sub-filter condition, which can be any string; the filter field ruleFiled specifies the database field name to be filtered; the filter comparison operator ruleCondition represents the comparison symbol of the filter condition, such as equal to, greater than, less than and greater than or equal to, etc. Their corresponding values ​​are =, >, < and >=, and the filter field value ruleValue specifies the value of the filter condition, that is, the specific numerical value or string to be filtered. If an interface has two sub-filtering conditions, the first one is name=Xiao Ming, then the corresponding filtering parameters are ruleFiled: name, ruleCondition: =, ruleValue: Xiao Ming, then the corresponding ruleName: name is Xiao Ming, ruleConnector is and, and the other one is age>10, then the corresponding filtering parameters are ruleFiled: age, ruleCondition: >, ruleValue: 10, then the corresponding ruleName: age is greater than 10 years old, ruleConnector is and, the filter connector and corresponding to age greater than 10 years old is connected with the previous sub-filtering condition, then the total filtering condition is name=Xiao Ming and age>10, that is, filtering the data whose age is greater than 10 years old and whose name is Xiao Ming.

[0072] The step of adding a plurality of groups of filtering parameters to the interface that needs to filter data includes:

[0073] Step S201: Acquire, from a storage space, a filtering parameter corresponding to an interface path corresponding to the interface that needs to perform data filtering.

[0074] Step S202: Generate several sub-filter conditions to be added according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters to be added, and generate several comparison sub-filter conditions according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering.

[0075] Step S203: judging whether conflicts occur with the compared sub-filtering conditions one by one according to each of the sub-filtering conditions to be added and its corresponding filter connector. If conflicts occur, prompting that the filter parameters corresponding to the conflicts are added incorrectly, otherwise, the addition is successful.

[0076] Specifically, first, it is necessary to obtain the filter parameters associated with the interface path corresponding to the interface that needs to filter data from the storage space. The storage space can be a database or a cache. In the mysql database, use the sql statement to use the interface path as the query condition in the database to obtain one or more groups of filter parameters. For example, the obtained filter parameters are two groups, and the generated comparison sub-filter conditions are age>11 and id<6 respectively. At the same time, the filter parameters to be added are also two groups, and the corresponding generated sub-filter conditions to be added are age>10 and id>7. When judging, the first sub-filter condition to be added, age>10, is judged with age>11. Since the filter fields and filter comparison symbols of the filter parameters to be added and the existing filter parameters in the database are the same, it is determined that this group of filter parameters conflicts with the original filter conditions, and it is prompted that the group of filter parameters is added. Since age>11 conflicts with the original filter condition, no further judgment is required. Similarly, id>7 and age>11 are judged. Since their filter fields are different, there is no conflict. Then the next comparison sub-filter condition id<6 is judged. If the filter connector corresponding to id>7 is and, and id<6and id>7 are contradictory, id>7 will also have a conflict. Through the above method, it can be ensured that when adding filter parameters to the interface that needs data filtering, the relevant parameters can be accurately obtained from the storage space, and whether there is a conflict according to the specified logic judgment conditions, thereby ensuring the validity of the filter parameters.

[0077] The step of obtaining from the storage space several groups of filter parameters corresponding to the interfaces that need to be filtered and generating several sub-filter conditions, and generating the overall filter condition according to the sub-filter conditions includes step S303: obtaining the attribute value of the custom annotation of the interface that needs to be filtered, and obtaining from the storage space several groups of filter parameters corresponding to the interfaces that need to be filtered according to the attribute value;

[0078] Step S304: concatenate the filter field, filter comparison operator and filter field value in the filter parameter corresponding to the interface that needs to filter data, to generate a sub-filter condition;

[0079] Step S305: Connect the sub-filtering conditions according to the filter connector to generate the overall filter condition.

[0080] Specifically, according to the reflection mechanism of Java, the getAnnotation method is used to obtain the attribute value containing the custom annotation as the filter identifier, that is, the interface path corresponding to the interface that needs to filter data, and one or more groups of filter parameters are obtained in the storage space according to the interface path. In Java, the filter parameters are converted into strings, and the strings are assigned to a query condition constructor QueryWrapper provided by MyBatis Plus, and then the string is converted into a List, represented as an ordered collection, and then chained through the .stream() method. One or more sub-filter conditions are generated according to the filter field, filter comparison operator and filter field value. The generation of sub-filter conditions is consistent with the above description, and will not be repeated here. Use the filter connector to connect one or more sub-filter conditions to generate a total filter condition for filtering interface data.

[0081] In addition, this embodiment also proposes a system for dynamically filtering list data. The method described in the above embodiment can be implemented by applying the system provided by this embodiment, including a filtering identifier adding module 501, which is used to add a filtering identifier to an interface that needs to filter data;

[0082] The filtering parameter setting module 502 is used to set several groups of filtering parameters according to the requirements, add several groups of filtering parameters for the interfaces that need to perform data filtering, and store the mapping between the interface path corresponding to the interfaces that need to perform data filtering and the filtering parameters in the storage space;

[0083] The filter condition generation module 503 is used to obtain several groups of filter parameters corresponding to the interfaces that need to be filtered from the storage space and generate several sub-filter conditions, generate a total filter condition based on the sub-filter conditions, and filter the data to be returned in the interfaces that need to be filtered based on the total filter condition.

[0084] Through the system of dynamically filtering list data, filter identifiers and filter parameters can be dynamically added according to the needs without modifying the code of the interface itself. This flexibility enables the system to adapt to different data filtering needs while reducing the invasiveness of the code. The filter identifier adding module 501 and the filter parameter setting module 502 in the system allow new filter identifiers and filter parameters to be added as needed, which makes the system have good scalability. As the needs change, the functions of the system can be easily expanded to meet the ever-changing business needs. The filter condition generation module 503 obtains the filter parameters from the storage space and generates the filter conditions. This method can improve the efficiency of the system. Compared with recalculating the filter conditions for each request, obtaining the set filter parameters from the storage space can reduce the calculation and processing time and improve the response speed of the system.

[0085] Furthermore, the filter identifier adding module 501 is specifically used for:

[0086] Create a custom annotation, declare the attributes of the custom annotation, and use the custom annotation as the filtering identifier; add a meta-annotation to the custom annotation, where the meta-annotation is used to control the behavior and scope of the custom annotation; add the custom annotation to the interface that needs to filter data, and set the interface path as the attribute value of the attribute;

[0087] The filter parameters include: a filter name, a filter field, a filter comparison operator, a filter field value, and a filter connector; the filter connector is used to connect the sub-filter conditions into the overall filter condition.

[0088] Specifically, the filter identifier adding module 501 creates a custom annotation through the java @interface keyword, and uses meta-annotations to control the behavior and scope of this custom annotation, such as RUNTIME to indicate that the custom annotation will be retained at runtime, that is, the information of the annotation can be obtained and processed at runtime through reflection, TYPE is used to indicate that the custom annotation can be applied to classes, interfaces, enumerations or record types, and METHOD indicates that the custom annotation can be applied to methods. In general, according to business needs, the filter identifier adding module 501 will add the above-created custom annotation to the interface to be filtered, and set the interface path to the attribute value of the custom annotation so as to determine the filtering conditions when filtering. These filtering parameters are used to define specific filtering conditions, such as the fields to be filtered, comparison conditions, and field values. The filter connector is used to connect multiple sub-filtering conditions to form a total filtering condition so as to comprehensively filter the data.

[0089] Furthermore, the filtering parameter setting module 502 is specifically used to:

[0090] Using the first annotation to declare a pointcut for the interface containing the filter identifier; using the second annotation to obtain the filter parameter from the storage space before and after the method matched by the pointcut is executed;

[0091] Acquire from the storage space the filtering parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering;

[0092] Generate several sub-filter conditions to be added according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters to be added, and generate several comparison sub-filter conditions according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering;

[0093] According to each of the sub-filtering conditions to be added and its corresponding filter connector, it is judged whether conflicts occur with the compared sub-filtering conditions one by one. If conflicts occur, it is prompted that the filter parameters corresponding to the conflicts are added incorrectly, otherwise the addition is successful.

[0094] Specifically, the first annotation is used to declare a pointcut for the interface containing a filter identifier, and then the second annotation is used to obtain the filter parameters from the storage space before and after the execution of the method matched by the pointcut. These filter parameters will be used to determine the filtering operation to be performed on the data. The filter parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering are obtained from the storage space. These parameters will be used to construct the filtering conditions so as to determine the specific filtering rules when filtering data. According to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters to be added, several sub-filter conditions to be added are generated. According to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters corresponding to the interface path of the interface for data filtering, several comparison sub-filter conditions are generated to judge whether the filter parameters will conflict with the original filter parameters later, so as to ensure the validity of the filter parameters. Each sub-filter condition to be added is compared with its corresponding filter connector and comparison sub-filter condition one by one to judge whether a conflict occurs. If a conflict occurs, it is prompted that the corresponding filter parameter is added incorrectly; otherwise, it is considered that the addition is successful, thereby effectively managing the data filtering operation.

[0095] Furthermore, the filtering condition generating module 503 is specifically used for:

[0096] Acquire the attribute value of the custom annotation of the interface that needs to perform data filtering, and acquire several groups of filtering parameters corresponding to the interface that needs to perform data filtering from the storage space according to the attribute value;

[0097] The filter field, filter comparison operator and filter field value in the filter parameter corresponding to the interface that needs to filter data are concatenated to generate a sub-filter condition;

[0098] The sub-filtering conditions are connected according to the filter connector to generate the overall filter condition.

[0099] Specifically, the filter condition generation module 503 will parse the custom annotations on the interface to obtain the corresponding attribute values, which are used to obtain the filter parameters in the storage space later. The filter condition generation module 503 uses the attribute values ​​as query conditions to obtain the filter parameters corresponding to the interface that needs to filter data from the database, cache or other data storage. After obtaining the filter parameters, the module will convert these parameters into sub-filter conditions, that is, combine the information such as the filter field, filter comparison symbol and filter field value together to form sub-filter conditions. These sub-filter conditions describe how to filter out data that meets specific conditions. The generated sub-filter conditions will be connected according to the filter connector to form a total filter condition. The filter condition generation module 503 can dynamically generate filter conditions applicable to different interfaces, thereby meeting the application's needs for data screening. This flexibility and customizability enable the application to define and apply filter conditions according to different scenarios and requirements.

[0100] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0101] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.

Claims

1. A method for dynamically filtering list data, characterized in that: include: Add a filter identifier to the interface that needs data filtering, and the filter identifier is used to determine whether the data of the interface needs to be filtered; Several groups of filtering parameters are set according to the requirements, several groups of filtering parameters are added to the interfaces that need to perform data filtering, and the mapping of the interface paths corresponding to the interfaces that need to perform data filtering and the filtering parameters is stored in the storage space, and each group of filtering parameters corresponds to a sub-filtering condition; Access the interface that needs to perform data filtering, obtain several groups of filtering parameters corresponding to the interface that needs to perform data filtering from the storage space and generate several sub-filtering conditions, generate a total filtering condition based on the sub-filtering conditions, and filter the data to be returned in the interface that needs to perform data filtering according to the total filtering condition.

2. The method for dynamically filtering list data according to claim 1, characterized in that: Adding a filter identifier to the interface that needs to filter data includes: Create a custom annotation, declare the properties of the custom annotation, and use the custom annotation as the filter identifier; Add a meta-annotation to the custom annotation, where the meta-annotation is used to control the behavior and scope of the custom annotation; The custom annotation is added to the interface that needs to perform data filtering, and the interface path is set as the attribute value of the attribute.

3. The method for dynamically filtering list data according to claim 2, characterized in that: The acquiring the filtering parameter from the storage space further includes: Use the first annotation to declare a pointcut for the interface containing the filter identifier; Using the second annotation, the filter parameter is obtained from the storage space before and after the method matched by the pointcut is executed.

4. The method for dynamically filtering list data according to claim 2, characterized in that: The filtering parameters include: filter name, filter field, filter comparison operator, filter field value and filter connector; The filter connector is used to connect the sub-filter conditions into the overall filter condition.

5. The method for dynamically filtering list data according to claim 4, characterized in that: Before adding a plurality of groups of filtering parameters to the interface that needs to filter data, the method includes: Acquire from the storage space the filtering parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering; Generate several sub-filter conditions to be added according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters to be added, and generate several comparison sub-filter conditions according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering; According to each of the sub-filtering conditions to be added and its corresponding filter connector, it is judged whether conflicts occur with the compared sub-filtering conditions one by one. If conflicts occur, it is prompted that the filter parameters corresponding to the conflicts are added incorrectly, otherwise the addition is successful.

6. The method for dynamically filtering list data according to claim 4, characterized in that: The step of acquiring from the storage space a plurality of groups of filtering parameters corresponding to the interfaces that require data filtering and generating a plurality of sub-filtering conditions, and generating a total filtering condition according to the sub-filtering conditions comprises: Acquire the attribute value of the custom annotation of the interface that needs to perform data filtering, and acquire several groups of filtering parameters corresponding to the interface that needs to perform data filtering from the storage space according to the attribute value; The filter field, filter comparison operator and filter field value in the filter parameter corresponding to the interface that needs to filter data are concatenated to generate a sub-filter condition; The sub-filtering conditions are connected according to the filter connector to generate the overall filter condition.

7. A system for dynamically filtering list data, characterized in that: include: A filter identifier adding module is used to add filter identifiers to interfaces that require data filtering; A filtering parameter setting module, used to set several groups of filtering parameters according to requirements, add several groups of filtering parameters for the interfaces that need to perform data filtering, and store the mapping between the interface path corresponding to the interface that needs to perform data filtering and the filtering parameters in a storage space; The filter condition generation module is used to obtain several groups of filter parameters corresponding to the interfaces that need to be filtered from the storage space and generate several sub-filter conditions, generate a total filter condition based on the sub-filter conditions, and filter the data to be returned from the interfaces that need to be filtered based on the total filter condition.

8. The system for dynamically filtering list data according to claim 7, characterized in that: The filtering identifier adding module is specifically used for: Create a custom annotation, declare the properties of the custom annotation, and use the custom annotation as the filter identifier; add a meta-annotation to the custom annotation, where the meta-annotation is used to control the behavior and scope of the custom annotation; Add the custom annotation to the interface that needs to perform data filtering, and set the interface path as the attribute value of the attribute; The filtering parameters include: filter name, filter field, filter comparison operator, filter field value and filter connector; The filter connector is used to connect the sub-filter conditions into the overall filter condition.

9. The system for dynamically filtering list data according to claim 8, characterized in that: The filtering parameter setting module is specifically used for: Using the first annotation to declare a pointcut for the interface containing the filter identifier; using the second annotation to obtain the filter parameter from the storage space before and after the method matched by the pointcut is executed; Acquire from the storage space the filtering parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering; Generate several sub-filter conditions to be added according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters to be added, and generate several comparison sub-filter conditions according to the filter fields, filter comparison operators, and filter field values ​​in the filter parameters corresponding to the interface path corresponding to the interface that needs to perform data filtering; According to each of the sub-filtering conditions to be added and its corresponding filter connector, it is judged whether conflicts occur with the compared sub-filtering conditions one by one. If conflicts occur, it is prompted that the filter parameters corresponding to the conflicts are added incorrectly, otherwise the addition is successful.

10. The system for dynamically filtering list data according to claim 9, characterized in that: The filtering condition generating module is specifically used for: Acquire the attribute value of the custom annotation of the interface that needs to perform data filtering, and acquire several groups of filtering parameters corresponding to the interface that needs to perform data filtering from the storage space according to the attribute value; The filter field, filter comparison operator and filter field value in the filter parameter corresponding to the interface that needs to filter data are concatenated to generate a sub-filter condition; The sub-filtering conditions are connected according to the filter connector to generate the overall filter condition.

Citation Information

Patent Citations

  • Data interface generation method and device, storage medium and mobile terminal

    CN113032473A

  • Interface configuration method and device, electronic equipment and computer readable medium

    CN113515270A

  • Interface data filtering method and device, computer equipment and readable storage medium

    CN115270196A