Data layering method and system based on AOP section programming

By adopting a data stratification method based on AOP sectional programming in merchant operation scenarios, the problems of merchant data management complexity and high storage costs are solved, and low coupling, efficient data management and strong audit capabilities are achieved.

CN119512515APending Publication Date: 2025-02-25HAIER CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411458400.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In the merchant operation scenario, it is difficult for the existing technology to effectively manage large and complex merchant data, resulting in high code coupling, insufficient data hierarchy, excessive data tables and fields, lack of automation and high storage costs.

Method used

The data hierarchy method based on AOP section programming is adopted to overview the data components through AOP section programming, abstractly establish a business model, monitor business object changes, perform data hierarchical control, and generate a change log based on the configured data change diff algorithm.

Benefits of technology

It realizes low-coupling and efficient data management, enhances data traceability and audit capabilities, reduces data storage costs, and improves the automation level of data changes and audits.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512515A_ABST
    Figure CN119512515A_ABST
Patent Text Reader

Abstract

The invention relates to a data layering method and system based on AOP section programming, and belongs to the field of data processing, and the method comprises the following steps: (1) using AOP section programming to overview data components; (2) abstractly establishing a business model for layering the data component based on the overview data component; (3) monitoring business object change, and executing data hierarchical control; and (4) based on the configured data change diff algorithm, comparing data changes before and after approval, and generating a change log. The method and the system have the advantages that the method and the system can be introduced in a low-coupling and high-efficiency manner in a business function implementation process, so that the effects of business management, auditing and production data layering can be achieved, the quick change of business data is met, and the isolation of management process data and production data is completed; and meanwhile, through adjustment of a data change configuration protocol, affordable change auditing can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a data stratification method based on AOP aspect programming and an implementation system thereof, and belongs to the field of data processing. Background Art

[0002] In the process of scene merchant operation, the business information, legal person information, business information, loan account number and other information of the merchant need to be changed. The change needs to be reviewed before it can affect the production business. In this process, how to manage merchant data reliably and traceably is a difficult problem. At the same time, because there are so many business information fields in the scene merchant data, a lot of tables will be involved in the actual system function implementation process. According to statistics, for only one kind of education merchant, there are 16 types of information tables involved in the business table, with a total of more than 400 business fields. A component-based technical solution is urgently needed to solve this problem from the perspectives of business data management, auditing, changes, stable production data, and efficient access.

[0003] In the business operation scenario, managing large amounts of complex business data is a challenge. The existing technical drawbacks mainly include the following aspects:

[0004] Hard-coded code: Traditional data management often relies on hard coding, which results in high code coupling, lack of cohesion, and difficulty in maintenance and expansion.

[0005] Insufficient data stratification: Many systems only use two layers of data stratification and lack change logs and final data stratification, which limits the traceability and audit capabilities of the data.

[0006] Numerous data tables and fields: In scenarios such as education merchants, there are many business fields, resulting in a large number of data tables and complex management.

[0007] Lack of automation: During the data audit and change process, the level of automation is not high, and many operations rely on manual labor, which is inefficient.

[0008] High data storage costs: As the amount of data increases, storage costs also increase, and traditional tiered storage methods may not be able to effectively control costs. Summary of the invention

[0009] In order to overcome the defects of the prior art, the present invention provides a data stratification method and system based on AOP aspect programming. The technical solution of the present invention is:

[0010] A data layering method based on AOP aspect programming includes the following steps:

[0011] (1) Use AOP aspect programming to get an overview of data components;

[0012] (2) Based on the overview data components, abstractly establish a business model that layers the data components;

[0013] (3) Monitor business object changes and perform data hierarchical control;

[0014] (4) Based on the configuration data change diff algorithm, it is used to compare the data changes before and after approval and generate a change log.

[0015] The step (1) is specifically as follows:

[0016] 1.1 Start a database transaction to ensure that changes to business objects and business data are layered in the same transaction to ensure atomicity;

[0017] 1.2 Define the pointcut through regular expressions, and perform AOP pointcut interception on the new operation and update operation methods of the persistence layer, indicating that as long as these methods are called, the execution of the subordinate aspect methods will be triggered. The regular expression is: "execution(*.dao.*.insert|update(..))"; where * represents the code path, dao is the general path of the persistence layer code; insert|update is the name of the new and updated method; 1.3 When the pointcut occurs, the execution of the aspect doAround method is triggered;

[0018] 1.4 Commit the database transaction.

[0019] The step 1.3 is specifically as follows:

[0020] 1.3.1 Bring the pointcut object where the pointcut occurs into the aspect method. The key information of the pointcut object is the newly added business object or the changed business object;

[0021] 1.3.2 A data stratification master switch is set before the slice method. When the switch is on, the slice core algorithm is executed.

[0022] The specific steps of step (3) are:

[0023] 3.1 Pointcut: Through AOP aspect programming, set pointcuts at the methods that cause business object data changes and enter the business logic; when the pointcut is triggered, capture and pass the changed business object entity;

[0024] 3.2 Reflection to obtain business entity objects:

[0025] Get the business entity object through JDK reflection method ProceedingJoinPoint.getArgs();

[0026] Use the JDK native OBject.getClass().getAnnotation method to determine whether the business object has the AuditedHaierCash annotation; if the AuditedHaierCash annotation exists, continue to execute the data layering component algorithm; if not, end the execution of the aspect core algorithm;

[0027] 3.3 Audit table existence check and automatic creation: Determine whether the audit table of the business object exists. If not, use the automatic generation algorithm of the audit table to automatically create it;

[0028] 3.4 Audit table data snapshot: Through the MySQL insert...select... syntax, it is abstracted into the dynamic syntax "insert into${tableNameA}A(REV,REV_SQL,INSERT_DT,${value})SELECT SEQ_F_MP_AUDITED.nextval,${sqlType}, to_char(sysdate,'yyyy-MM-dd HH24:mi:ss'),${value}from${tableName}N where N.${key}=#{ent}", to take a snapshot of the entity of the business object and add it to the audit table of the business object;

[0029] 3.5 Approval form hierarchical judgment:

[0030] Use the JDK native OBject.getClass().getAnnotation method again to determine whether the business object has the NotFinalHaierCash annotation. If it does, enter the approval form hierarchical processing flow;

[0031] 3.6 Approval form layered processing:

[0032] Use MySQL query statements to obtain all business field column definitions corresponding to business objects; use MySQL syntax update by primary key to update business objects in the approval table. If the update is successful, it means that the business approval object already exists and the algorithm is executed; if the update fails, proceed to the next step;

[0033] 3.7 Production audit log storage:

[0034] For business objects with approval layers, the diff algorithm is executed to compare the data differences before and after approval; a production audit log is generated and stored in the change record table.

[0035] In the step (4), for business objects with approval layers, a comparison and change of business data before and after approval is performed based on a flexibly configured data change algorithm. The specific steps are as follows:

[0036] (a) Obtain the entity table name through the business object entity pointcut;

[0037] (b) Obtain the corresponding business primary key data through table structure definition;

[0038] (c) Obtain the approval status of the business object entity through the table name and business primary key;

[0039] (d) Whether the approval status of the business object entity is approved; if not, skip; if approved, proceed to the next step;

[0040] (e) Get the name of the approval table and obtain the field definition of the table;

[0041] (f) querying the attribute field content of the table from the business object model and the business object approval model according to the business primary key to form a MAP return;

[0042] (g) For the contents of the Map, assemble them according to the Change object;

[0043] (h) Complete the conversion of Change object to json protocol, form a change log, and store it in the change record table; the json protocol is designed as follows: [{"merch":[{"list":[{"changeAfter":"Content after modification","changeBefore":"Content before modification","changeColumn":"Field business name"}],"name":"Business object name","operate":"Operation mode: add or modify"}};

[0044] (i) The front end parses the JSON protocol according to the approval process ID, and completes the Chinese conversion in combination with the MERCH_CHANGE_CONFIG configuration information.

[0045] A system for implementing a data layering method based on AOP aspect programming, comprising:

[0046] The data component overview module is used to use AOP aspect programming to provide an overview of data components. The business model building module is used to abstractly build a business model that layers data components based on the overview data components.

[0047] The data layering control module is used to monitor business object changes and perform data layering control. The log generation module is used to compare data changes before and after approval and generate change logs based on the configured data change diff algorithm.

[0048] The advantages of the present invention are:

[0049] In the process of realizing business functions, this method and its system can be introduced in a low-coupling and efficient manner to achieve the effects of business management, auditing, and production data stratification, satisfying the rapid change of business data and completing the isolation of management process data and production data; at the same time, by adjusting the data change configuration protocol, the change audit can be satisfied. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 It is a flowchart that provides an overview of the data components of the present invention.

[0051] Figure 2 It is a flow chart of executing data hierarchical control of the present invention.

[0052] Figure 3 It is a schematic diagram of the establishment process of the business model of the present invention.

[0053] Figure 4 It is a system structure block diagram of the present invention. DETAILED DESCRIPTION

[0054] The present invention will be further described below in conjunction with specific embodiments, and the advantages and features of the present invention will become clearer as the description proceeds. However, these embodiments are exemplary only and do not constitute any limitation to the scope of the present invention. It should be understood by those skilled in the art that the details and forms of the technical solution of the present invention may be modified or replaced without departing from the spirit and scope of the present invention, but these modifications and replacements all fall within the scope of protection of the present invention.

[0055] See also Figures 1 to 4 The present invention relates to a data layering method based on AOP aspect programming, comprising the following steps:

[0056] (1) Use AOP aspect programming to get an overview of data components;

[0057] (2) Based on the overview data components, abstractly establish a business model that layers the data components;

[0058] For the operation of business objects, the focus is on business object operation, business object change audit, and business object impact on production. Based on these focuses, how to use a business object to present and manage is a key issue. Based on this, a data layered business model is abstracted as follows:

[0059]

[0060]

[0061]

[0062] Taking the merchant basic information business model as an example, based on the data layering model design, the data layering structure of the merchant basic information is as follows:

[0063]

[0064] MERCH_INFO is the merchant basic information business object; MERCH_INFO_A is the merchant basic information audit business object; MERCH_INFO_A0 is the merchant basic information approval business object.

[0065] During the design of business functions, we focus on the definition of business objects. We do not need to define the corresponding audit tables and approval tables. We mainly rely on the data layering automatic production algorithm to solve the problem. The specific steps of the algorithm are as follows:

[0066] ① For business objects that need to be processed, the corresponding table name will be declared through the @Table annotation; through the reflection method of the business object, the entity table name corresponding to the business can be dynamically obtained through this annotation;

[0067] ② Use the global configuration variable creatTableEnable to control the switch. When the switch is on, the corresponding audit table and approval table will be automatically generated through the algorithm. In general, the switch is on in the test environment and off in the production environment. Consider the reliability of production database permissions.

[0068] ③Use MySQL syntax "SELECT COUNT(*)FROM User_Tables WHERE table_name=#{tableNameA}" to determine whether the data hierarchical table exists. If it does not exist, proceed to the next step;

[0069] ④Use MySQL syntax to obtain the primary key of the business object: "select cu.COLUMN_NAME from user_cons_columns cu,user_constraints au where cu.constraint_name=au.constraint_name and au.constraint_type='P'and au.table_name=#{tableName}ORDER BY COLUMN_NAME DESC";

[0070] ⑤Create a table using MySQL syntax: "CREATE TABLE${tableNameA}as SELECT*FROM${tableName},F_MP_AUDITED";

[0071] ⑥ Complete the table's primary key setting using MySQL syntax: "ALTER TABLE${tableNameA}ADD PRIMARYKEY("${colAudited}","${col}")";

[0072] ⑦At this point, the algorithm completes the automatic creation of the tables required for data stratification.

[0073] (3) Monitor business object changes and perform data hierarchical control;

[0074] (4) Based on the configuration data change diff algorithm, it is used to compare the data changes before and after approval and generate a change log.

[0075] The step (1) is specifically as follows:

[0076] 1.1 Start a database transaction to ensure that changes to business objects and business data are layered in the same transaction to ensure atomicity;

[0077] 1.2 Define the pointcut through regular expressions, and perform AOP pointcut interception on the new operation and update operation methods of the persistence layer, indicating that as long as these methods are called, the execution of the subordinate aspect methods will be triggered. The regular expression is: "execution(*.dao.*.insert|update(..))"; where * represents the code path, dao is the general path of the persistence layer code; insert|update is the name of the new and updated method; 1.3 When the pointcut occurs, the execution of the aspect doAround method is triggered;

[0078] 1.4 Commit the database transaction.

[0079] The step 1.3 is specifically as follows:

[0080] 1.3.1 Bring the pointcut object where the pointcut occurs into the aspect method. The key information of the pointcut object is the newly added business object or the changed business object;

[0081] 1.3.2 A data stratification master switch is set before the slice method. When the switch is on, the slice core algorithm is executed.

[0082] The specific steps of step (3) are:

[0083] 3.1 Pointcut: Through AOP aspect programming, set pointcuts at the methods that cause business object data changes and enter the business logic; when the pointcut is triggered, capture and pass the changed business object entity;

[0084] 3.2 Reflection to obtain business entity objects:

[0085] Get the business entity object through JDK reflection method ProceedingJoinPoint.getArgs();

[0086] Use the JDK native OBject.getClass().getAnnotation method to determine whether the business object has the AuditedHaierCash annotation; if the AuditedHaierCash annotation exists, continue to execute the data layering component algorithm; if not, end the execution of the aspect core algorithm;

[0087] 3.3 Audit table existence check and automatic creation: Determine whether the audit table of the business object exists. If not, use the automatic generation algorithm of the audit table to automatically create it;

[0088] 3.4 Audit table data snapshot: Through the MySQL insert...select... syntax, it is abstracted into the dynamic syntax "insert into${tableNameA}A(REV,REV_SQL,INSERT_DT,${value})SELECT SEQ_F_MP_AUDITED.nextval,${sqlType},to_char(sysdate,'yyyy-MM-dd HH24:mi:ss'),${value}from${tableName}N where N.${key}=#{ent}", to take a snapshot of the entity of the business object and add it to the audit table of the business object;

[0089] 3.5 Approval form hierarchical judgment:

[0090] Use the JDK native OBject.getClass().getAnnotation method again to determine whether the business object has the NotFinalHaierCash annotation. If it does, enter the approval form hierarchical processing flow;

[0091] 3.6 Approval form layered processing:

[0092] Use MySQL query statements to obtain all business field column definitions corresponding to business objects;

[0093] Use MySQL syntax update by primary key to update the business object in the approval table. If the update is successful, it means that the business approval object already exists and the algorithm is executed; if the update fails, proceed to the next step;

[0094] 3.7 Production audit log storage:

[0095] For business objects with approval layers, the diff algorithm is executed to compare the data differences before and after approval; a production audit log is generated and stored in the change record table.

[0096] In the step (4), for business objects with approval layers, a comparison and change of business data before and after approval is performed based on a flexibly configured data change algorithm. The specific steps are as follows:

[0097] (a) Obtain the entity table name through the business object entity pointcut;

[0098] (b) Obtain the corresponding business primary key data through table structure definition;

[0099] (c) Obtain the approval status of the business object entity through the table name and business primary key;

[0100] (d) Whether the approval status of the business object entity is approved; if not, skip; if approved, proceed to the next step;

[0101] (e) Get the name of the approval table and obtain the field definition of the table;

[0102] (f) querying the attribute field content of the table from the business object model and the business object approval model according to the business primary key to form a MAP return;

[0103] (g) For the contents of the Map, assemble them according to the Change object;

[0104] (h) Complete the conversion of Change object to json protocol, form a change log, and store it in the change record table; the json protocol is designed as follows: [{"merch":[{"list":[{"changeAfter":"Content after modification","changeBefore":"Content before modification","changeColumn":"Field business name"}],"name":"Business object name","operate":"Operation mode: add or modify"}};

[0105] (i) The front end parses the JSON protocol according to the approval process ID, and completes the Chinese conversion in combination with the MERCH_CHANGE_CONFIG configuration information.

[0106] The present invention also relates to a system for implementing a data layering method based on AOP aspect programming, comprising:

[0107] Data component overview module 1 is used to use AOP aspect programming to provide an overview of data components; business model establishment module 2 is used to abstractly establish a business model for layering data components based on the overview data components;

[0108] The data layering control module 3 is used to monitor business object changes and perform data layering control; the log generation module 4 is used to compare data changes before and after approval based on the configured data change diff algorithm and generate a change log.

[0109] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A data stratification method based on AOP aspect programming, characterized in that: The following steps are involved: (1) Use AOP aspect programming to get an overview of data components; (2) Based on the overview data components, abstractly establish a business model that layers the data components; (3) Monitor business object changes and perform data hierarchical control; (4) Based on the configuration data change diff algorithm, it is used to compare the data changes before and after approval and generate a change log.

2. The data stratification method based on AOP aspect programming according to claim 1 is characterized in that: The step (1) is specifically as follows: 1.1 Start a database transaction to ensure that changes to business objects and business data are layered in the same transaction to ensure atomicity; 1.2 Define the pointcut through regular expressions, and perform AOP pointcut interception on the new operation and update operation methods of the persistence layer, indicating that as long as these methods are called, the execution of the subordinate aspect methods will be triggered. The regular expression is: "execution(*.dao.*.insert|update(..))"; where * represents the code path, dao is the general path of the persistence layer code; insert|update is the name of the new and updated method; 1.3 When a cut point occurs, the execution of the doAround method of the cut surface is triggered; 1.4 Commit the database transaction.

3. The data stratification method based on AOP aspect programming according to claim 2 is characterized in that: The step 1.3 is specifically as follows: 1.3.1 Bring the pointcut object where the pointcut occurs into the aspect method. The key information of the pointcut object is the newly added business object or the changed business object; 1.3.2 A data stratification master switch is set before the slice method. When the switch is on, the slice core algorithm is executed.

4. According to the data stratification method based on AOP aspect programming according to claim 1, it is characterized in that the specific steps of step (3) are: 3.1 Pointcut: Through AOP aspect programming, set pointcuts at the methods that cause business object data changes and enter the business logic; when the pointcut is triggered, capture and pass the changed business object entity; 3.2 Reflection to obtain business entity objects: Get the business entity object through JDK reflection method ProceedingJoinPoint.getArgs(); Use the JDK native OBject.getClass().getAnnotation method to determine whether the business object has the AuditedHaierCash annotation; if the AuditedHaierCash annotation exists, continue to execute the data layering component algorithm; if not, end the execution of the aspect core algorithm; 3.3 Audit table existence check and automatic creation: Determine whether the audit table of the business object exists. If not, use the automatic generation algorithm of the audit table to automatically create it; 3.4 Audit table data snapshot: Through the MySQL insert...select... syntax, it is abstracted into the dynamic syntax "insertinto${tableNameA}A(REV,REV_SQL,INSERT_DT,${value})SELECT SEQ_F_MP_AUDITED.nextval,${sqlType},to_char(sysdate,'yyyy-MM-dd HH24:mi:ss'),${value}from${tableName}N where N.${key}=#{ent}", to take a snapshot of the entity of the business object and add it to the audit table of the business object; 3.5 Approval form hierarchical judgment: Use the JDK native OBject.getClass().getAnnotation method again to determine whether the business object has the NotFinalHaierCash annotation. If it does, enter the approval form hierarchical processing flow; 3.6 Approval form layered processing: Use MySQL query statements to obtain all business field column definitions corresponding to business objects; use MySQL syntax update by primary key to update business objects in the approval table. If the update is successful, it means that the business approval object already exists and the algorithm is executed; if the update fails, proceed to the next step; 3.7 Production audit log storage: For business objects with approval layers, the diff algorithm is executed to compare the data differences before and after approval; a production audit log is generated and stored in the change record table.

5. The data stratification method based on AOP aspect programming according to claim 1 or 2, characterized in that: In the step (4), for business objects with approval layers, a comparison and change of business data before and after approval is performed based on a flexibly configured data change algorithm. The specific steps are as follows: (a) Obtain the entity table name through the business object entity pointcut; (b) Obtain the corresponding business primary key data through table structure definition; (c) Obtain the approval status of the business object entity through the table name and business primary key; (d) Whether the approval status of the business object entity is approved; if not, skip; If approved, proceed to the next step; (e) Get the name of the approval table and obtain the field definition of the table; (f) querying the attribute field content of the table from the business object model and the business object approval model according to the business primary key to form a MAP return; (g) For the contents of the Map, assemble them according to the Change object; (h) Complete the conversion of Change object to json protocol, form a change log, and store it in the change record table; the json protocol is designed as follows: [{"merch":[{"list":[{"changeAfter":"Content after modification","changeBefore":"Content before modification","changeColumn":"Field business name"}],"name":"Business object name","operate":"Operation mode: add or modify"}}; (i) The front end parses the JSON protocol according to the approval process ID, and completes the Chinese conversion in combination with the MERCH_CHANGE_CONFIG configuration information.

6. A system for implementing the data stratification method based on AOP aspect programming according to any one of claims 1 to 5, characterized in that: include: The data component overview module is used to use AOP aspect programming to provide an overview of data components; A business model building module is used to abstractly build a business model that layers data components based on the overview data components; Data hierarchical control module, used to monitor business object changes and perform data hierarchical control; The log generation module is used to compare the data changes before and after approval and generate change logs based on the configured data change diff algorithm.