Data filtering method and system based on annotations and base classes

By introducing data filtering annotations and base classes into the programming language base class, and combining Mybatis interceptors and aspect classes, the structured query language is dynamically assembled, solving the problems of low data filtering efficiency and inconvenient development, and realizing efficient and flexible data filtering functions.

CN115687473BActive Publication Date: 2025-12-26IND BANK CO +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211214055.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-30
Publication Date
2025-12-26
Estimated Expiration
2042-09-30

AI Technical Summary

Technical Problem

Existing data filtering technologies are inefficient and inconvenient for developers, making it difficult to quickly and accurately filter out valuable data.

Method used

A data filtering method based on annotations and base classes is adopted. By writing filtering-related fields in the base class of the programming language, and using Mybatis interceptor classes and aspect classes to handle business logic, the dynamic assembly and execution of the structured query language is realized.

Benefits of technology

It improves developers' coding and bug-fixing speed, reduces labor costs, increases the flexibility and efficiency of data filtering, and reduces reliance on markup language files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115687473B_ABST
    Figure CN115687473B_ABST
Patent Text Reader

Abstract

The application provides an annotation and base class-based data screening method and system, comprising: establishing a programming language base class; establishing an aspect module and performing corresponding business logic assignment processing on fields according to the programming language base class and actual business requirements; assembling base class fields in the programming language base class into structured query language query conditions through the established Mybatis interception module, and then executing the structured query language to obtain corresponding results. The application puts all data screening related fields into a certain base class and extracts all assignment and business logic processing parts of the fields to an aspect class based on the industry mainstream open source framework SpringBoot, and the aspect class uniformly processes, so that the project group screening function code sharing is realized, the code is non-invasive, the coding speed of the developer is greatly improved, and the bug repair speed is also improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, in particular, to a data screening method and system based on annotations and base classes. BACKGROUND

[0002] With the development of computers, the amount of data in the big data environment is increasing, and different enterprises or departments have different data needs. However, in the big data environment, data accumulates rapidly, and it is very important to analyze the value contained in the massive data and screen out valuable data. Data screening plays a crucial role in the entire data processing process. The increase in data volume and the complexity of the structure make it necessary to consume more resources for big data-oriented data screening, so it is necessary to choose the right algorithm to quickly and accurately screen out valuable data.

[0003] Patent document CN110781180A discloses a data screening method and a data screening device. In the method, the dispatcher receives each node parameter corresponding to the DAG scheduling structure obtained by the business server parsing the target data expression satisfying one or more screening conditions; the DAG scheduling structure is called according to each node parameter, the DAG scheduling structure includes a preset number of parent nodes, the parent nodes include a first node and a second node, the second node is a leaf node, the first node is used to receive operator parameters when it has child nodes, and the first node is used to receive operand parameters when it has no child nodes, and the second node is used to receive operand parameters; according to the acquisition state of the operand parameters of the second node of the target parent node, the scheduling processing is performed to select the root node to exit and obtain the target data.

[0004] However, in the existing data screening technology, the data screening efficiency and the development method more convenient for developers still have room for improvement. SUMMARY

[0005] In view of the defects in the prior art, the purpose of the present application is to provide a data screening method and system based on annotations and base classes.

[0006] According to the data screening method and system based on annotations and base classes provided by the present application, the following steps are included:

[0007] Step S1: Establishing a programming language base class;

[0008] Step S2: Establishing an aspect module and performing corresponding business logic assignment processing on the fields according to the programming language base class and actual business requirements;

[0009] Step S3: Assembling the base class fields in the programming language base class into the query condition of the structured query language through the established Mybatis intercepting module, and then executing the structured query language to obtain the corresponding result.

[0010] Preferably, step S1 comprises writing the fields related to data filtering in the programming language base class, and providing corresponding methods for accessing and modifying the attribute values.

[0011] The fields can be dynamically extended.

[0012] Preferably, step S2 comprises:

[0013] Step S2.1: Setting the data filtering annotation and the target of the annotation;

[0014] Step S2.2: Establishing an aspect class, first introducing the data filtering annotation and then introducing corresponding declaration modes for the data filtering annotation;

[0015] In the declaration modes, the programming language base class is acquired before the control target is executed, and the fields are subjected to corresponding business logic assignment processing according to the actual business requirements.

[0016] Preferably, step S3 comprises:

[0017] Step S3.1: Establishing an annotation for identifying the methods in the mapper interface that need to be subjected to data filtering;

[0018] Step S3.2: Establishing a Mybatis interceptor class to realize the interface Interceptor;

[0019] Step S3.3: Overriding the intercept method in the Interceptor interface, and judging in the matched method body whether the executed method is identified by the annotation; if not, directly proceeding; if yes, triggering step S3.4;

[0020] Step S3.4: Acquiring the structured query language statement written, assembling the base class fields into the query condition of the structured query language statement, and then obtaining a new structured query language statement;

[0021] Step S3.5: Executing the new structured query language to obtain the corresponding result.

[0022] Preferably, when the base class fields in the programming language base class change, only the Mybatis interceptor needs to be modified, without the need to pay attention to the structured query language statement in the markup language file.

[0023] According to the data filtering system based on the annotation and the base class provided by the application, the system comprises:

[0024] Module M1: Establishing a programming language base class;

[0025] Module M2: Establishing an aspect module and performing corresponding business logic assignment processing on fields according to the programming language base class and actual business requirements;

[0026] Module M3: Assembling base class fields in the programming language base class into query conditions of a structured query language through the established Mybatis interception module, and then executing the structured query language to obtain corresponding results.

[0027] Preferably, module M1 includes: writing data filtering related fields in the programming language base class, and providing a corresponding system for accessing and modifying attribute values;

[0028] The fields can be dynamically extended.

[0029] Preferably, module M2 includes:

[0030] Module M2.1: Setting data filtering annotations and the target of the annotations;

[0031] Module M2.2: Establishing an aspect class, first introducing the data filtering annotations and then introducing corresponding declaration methods for the data filtering annotations;

[0032] In the declaration method and before the control target is executed, the programming language base class is first obtained, and then corresponding business logic assignment processing is performed on the fields according to actual business requirements.

[0033] Preferably, module M3 includes:

[0034] Module M3.1: Establishing an annotation for identifying systems in a mapper interface that need to be subjected to data filtering;

[0035] Module M3.2: Establishing a Mybatis interceptor class to implement an interface Interceptor;

[0036] Module M3.3: Overriding the intercept system in the Interceptor interface to determine whether the executed system is annotated; if not, directly proceed; if yes, trigger module M3.4;

[0037] Module M3.4: Obtaining a structured query language statement, assembling base class fields into query conditions of the structured query language statement, and then obtaining a new structured query language statement;

[0038] Module M3.5: Executing the new structured query language to obtain corresponding results.

[0039] Preferably, when the base class field in the programming language base class changes, only the Mybatis interceptor needs to be modified, without paying attention to the structured query language statement in the markup language file.

[0040] Compared with the prior art, the application has the following beneficial effects:

[0041] 1、The application puts all data screening related fields into a certain base class, extracts the assignment and business logic processing of these fields to an aspect class, and processes them uniformly by the aspect class, so as to realize code sharing of the screening function in the project group, greatly improve the coding speed of the developer, and improve the bug repair speed.

[0042] 2、The application only needs to modify the Mybatis interceptor when the base class field in the programming language base class changes, without paying attention to the structured query language statement in the markup language file, so as to bring convenience to the technical personnel and improve the efficiency.

[0043] 3、The application introduces data screening annotations in the data screening related method, realizes the non-invasive data screening function, reduces the labor cost, and increases the flexibility of data screening. BRIEF DESCRIPTION OF DRAWINGS

[0044] Other characteristics, objects and advantages of the application will become more apparent through the following detailed description of non-limiting embodiments, made with reference to the accompanying drawings:

[0045] Figure 1 The flowchart of the application. DETAILED DESCRIPTION

[0046] The application will be described in detail below with reference to specific embodiments. The following embodiments will help those skilled in the art to further understand the application, but do not limit the application in any form. It should be pointed out that, for those skilled in the art, without departing from the concept of the application, a number of changes and improvements can be made. These all belong to the protection scope of the application.

[0047] Example 1

[0048] According to the data screening method based on annotations and base classes provided by the application, the method comprises the following steps:

[0049] Step S1: establishing a programming language base class. Step S1 comprises: writing data screening related fields in the programming language base class, and providing corresponding methods for accessing and modifying attribute values; the fields can be dynamically expanded.

[0050] Step S2: establishing a cutting module and assigning corresponding business logic to the fields according to the programming language base class and actual business requirements. Step S2 includes: step S2.1: setting data filtering annotations and the target of the annotations. Step S2.2: establishing a cutting class, first introducing the data filtering annotations and then introducing corresponding declaration modes for the data filtering annotations. In the declaration mode and before the control target is executed, the programming language base class is first obtained, and then the fields are assigned corresponding business logic according to actual business requirements.

[0051] Step S3: assembling the base class fields in the programming language base class into the query conditions of the structured query language through the established Mybatis interception module, and then executing the structured query language to obtain the corresponding results. Step S3 includes:

[0052] Step S3.1: establishing an annotation for identifying the methods in the mapper interface that need to be data filtered.

[0053] Step S3.2: establishing a Mybatis interceptor class to implement the interface Interceptor.

[0054] Step S3.3: overriding the intercept method in the Interceptor interface to determine whether the executed method is annotated; if not, directly proceed; if yes, trigger step S3.4.

[0055] Step S3.4: obtaining the structured query language statement written, assembling the base class fields into the query conditions of the structured query language statement, and then obtaining a new structured query language statement.

[0056] Step S3.5: executing the new structured query language to obtain the corresponding results.

[0057] When the base class fields in the programming language base class change, only the Mybatis interceptor needs to be modified, without the need to focus on the structured query language statements in the markup language file.

[0058] Further, the present application is specifically described below taking the development of a Java language as an example:

[0059] When developing the data filtering function of a Java project, all data filtering related fields are placed in a certain base class or independent class, the fields can be dynamically expanded, and the related classes can be inherited or referenced. At the same time, based on the industry mainstream open source framework SpringBoot, the assignment and business logic processing of these fields are all extracted to a cutting class, which is uniformly processed by the cutting class. In actual use, only an annotation needs to be added to the method. The specific steps are as follows:

[0060] Step one: Establish Java base class. First, write a java base class, then write all data filtering related fields in the base class, and provide getter, setter method. Among them: field supports dynamic expansion.

[0061] Step two: Establish aspect module. First, customize a data filtering annotation, and set the value of @Target to ElementType.METHOD. Then, create an aspect class, first introduce the data filtering annotation through the annotation @Pointcut, and then introduce the method declared in the annotation @Pointcut in the method declared in the annotation @Around. Then, in the method body declared in the annotation @Around, and before calling the proceed method of ProceedingJoinPoint, first get the java base class defined in step one, and then assign the corresponding business logic to the field according to the actual business requirements.

[0062] The application introduces data filtering annotations in the related method of data filtering, which can realize the function of non-invasive data filtering of code.

[0063] Step three: Establish Mybatis interception module. First, create an annotation to identify the methods in the mapper interface that need to be data filtered. Then, create a Mybatis interceptor class that implements the interface Interceptor. Then override the intercept method in the Interceptor interface. In the method body, determine whether the executed method is annotated. If there is no annotation, release it directly; if there is an annotation, get the sql statement, and then assemble the base class fields in step one into the where condition of the sql statement. For example: "1=1and a=‘’and b=‘’......", assemble a new sql statement. Finally, execute the sql to get the desired result. When the base class field in step one changes, only the Mybatis interceptor needs to be modified, without the need to focus on the sql statement in the xml file.

[0064] Embodiment two

[0065] The application also provides a data filtering system based on annotations and base classes. Those skilled in the art can implement the data filtering system based on annotations and base classes by executing the step flow of the data filtering method based on annotations and base classes, that is, the data filtering method based on annotations and base classes can be understood as the preferred embodiment of the data filtering system based on annotations and base classes.

[0066] According to the data filtering system based on annotations and base classes provided by the application,

[0067] Module M1: Establishing a programming language base class. Specifically, fields related to data filtering are written in the programming language base class, and a corresponding system for accessing and modifying attribute values is provided. The fields can be dynamically extended.

[0068] Module M2: Establishing an aspect module and assigning corresponding business logic to the fields according to the programming language base class and actual business requirements. Specifically, first, data filtering annotations and the target of the annotations are set. Then, an aspect class is established, the data filtering annotations are first introduced, and then corresponding declaration methods are introduced. In the declaration method and before the control target is executed, the programming language base class is first obtained, and then corresponding business logic is assigned to the fields according to actual business requirements.

[0069] Module M3: The base class fields in the programming language base class are assembled into structured query language query conditions through the established Mybatis interceptor module, and then the structured query language is executed to obtain the corresponding results. Module M3 includes: Module M3.1: Establishing an annotation to identify the system in the mapper interface that needs to be filtered. Module M3.2: Establishing a Mybatis interceptor class to implement the interface Interceptor. Module M3.3: Overriding the intercept system in the Interceptor interface to determine whether the executed system is annotated; if not, it directly goes to the next step; if yes, it triggers module M3.4. Module M3.4: Obtaining the structured query language statement written, assembling the base class fields into the query conditions of the structured query language statement, and then obtaining a new structured query language statement. Module M3.5: Executing the new structured query language to obtain the corresponding results.

[0070] When the base class fields in the programming language base class change, only the Mybatis interceptor needs to be modified, and the structured query language statements in the markup language file do not need to be concerned.

[0071] Those skilled in the art know that in addition to implementing the system, device and each module thereof provided by the present application in a pure computer readable program code manner, the same program can be realized in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, the system, device and each module thereof provided by the present application can be considered as a hardware component, and the modules included therein for implementing various programs can also be considered as structures within the hardware component; the modules for implementing various functions can also be considered as both software programs for implementing methods and structures within hardware components.

[0072] The specific embodiments of the present application have been described. It is to be understood that the application is not limited to particular details described herein and that various modifications can be made therein without departing from the scope of the claimed application. Embodiments and features disclosed in this document, including in the examples, can be combined with each other, unless specifically contradicted by or inconsistent with each other.

Claims

1. A data filtering method based on annotation and base class, characterized in that, Comprise: Step S1: establish a programming language base class; Step S2: establish a aspect module and according to the programming language base class and actual business requirements to field corresponding business logic assignment processing; Step S3: through the establishment of MyBatis intercept module will the base class field in the programming language base class into structured query language query condition, and then execute the structured query language obtains the corresponding result; Step S2 includes: Step S2.1: set data filtering annotation and the effect target of annotation; Step S2.2: establish aspect class, first introduce the data filtering annotation and then introduce corresponding declaration mode to the data filtering annotation; Wherein, in the declaration mode and before the control target executes, first obtain the programming language base class, and then according to the actual business requirements to field corresponding business logic assignment processing; Step S3 includes: Step S3.1: establish an annotation, which is used to identify the method in the mapper interface that needs to be data filtered; Step S3.2: establish MyBatis interceptor class, implement interface Interceptor; Step S3.3: override the intercept method in the Interceptor interface, determine whether there is an annotation mark on the executed method in the matched method body; if not, directly proceed; if yes, trigger step S3.4; Step S3.4: obtain the structured query language statement written, assemble the base class field into the query condition of the structured query language statement, and then obtain a new structured query language statement; Step S3.5: execute the new structured query language to obtain the corresponding result.

2. The annotation and base class based data filtering method of claim 1, wherein, Step S1 includes: writing data filtering related fields in the programming language base class, and providing corresponding methods for accessing and modifying attribute values; The field can be dynamically extended.

3. The annotation and base class based data filtering method of claim 1, wherein, When the base class field in the programming language base class changes, only the MyBatis interceptor needs to be modified, without the need to focus on the structured query language statement in the markup language file.

4. A data filtering system based on annotations and base classes, characterized by, Comprise: Module M1: establish a programming language base class; Module M2: establish an aspect module and according to the programming language base class and actual business requirements to field corresponding business logic assignment processing; Module M3: through the establishment of MyBatis intercept module will the base class field in the programming language base class into structured query language query condition, and then execute the structured query language obtains the corresponding result; Module M2 includes: Module M2.1: set data filtering annotation and the effect target of annotation; Module M2.2: establish aspect class, first introduce the data filtering annotation and then introduce corresponding declaration mode to the data filtering annotation; Wherein, in the declaration mode and before the control target executes, first obtain the programming language base class, and then according to the actual business requirements to field corresponding business logic assignment processing; Module M3 includes: Module M3.1: establish an annotation, which is used to identify the method in the mapper interface that needs to be data filtered; Module M3.2: establish MyBatis interceptor class, implement interface Interceptor; Module M3.3: override the intercept system in the Interceptor interface, determine whether there is an annotation mark on the executed system in the matched system body; if not, directly pass; if yes, trigger module M3.4; Module M3.4: obtain the written structured query language statement, assemble the base class field into the query condition of the structured query language statement, and then obtain a new structured query language statement; Module M3.5: execute the new structured query language to obtain the corresponding result.

5. The annotation and base class based data filtering system of claim 4, wherein, Module M1 includes writing data filtering related fields in the programming language base class, and providing corresponding systems for accessing and modifying attribute values; The field can be dynamically extended.

6. The annotation and base class based data filtering system of claim 4, wherein, When the base class field in the programming language base class changes, only the Mybatis interceptor needs to be modified, without the need to focus on the structured query language statement in the markup language file.

Citation Information

Patent Citations

  • Data screening method and data screening device

    CN110781180A

  • Parameter verification method and device

    CN110765422A

  • AOP section management method, system, device and medium

    CN114942778A