Data log full-link tracking method and device
By defining operation log annotations and policies, combined with SPEL parameter extraction and reflection comparison engines, the problems of core business code dilution and high maintenance costs in traditional operation log recording methods are solved, the accuracy of operation semantic recognition and change tracking capabilities are improved, and the audit compliance requirements in the financial and medical fields are met.
Patent Information
- Application Number
- CN202510717982.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-09-19
AI Technical Summary
Traditional operation log recording methods lead to the dilution of core business codes, high maintenance costs, poor accuracy in operational semantic recognition, and the inability to restore complete operation details, making it difficult to meet audit compliance requirements, especially in the financial and medical fields.
By defining operation log annotations, adopting batch insert, single insert, delete and update strategies, and combining SPEL parameter extraction and reflection comparison engines, accurate identification of operation semantics and deep comparison of nested objects are achieved, supporting field-level change tracking.
It improves the accuracy of operational semantic recognition and change tracking capabilities, reduces maintenance costs, and meets the audit compliance requirements in the financial and medical fields.
Smart Images

Figure CN120670435A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for full-link tracing of data logs. Background Art
[0002] In information-based scenarios such as enterprise management software and distributed systems, the integrity and traceability of operation logs directly affect the audit compliance of the system. Traditional operation logging methods use hard-coded log modes, basic aspect-oriented programming log aspects, or annotation-driven enhancement solutions. However, hard-coded solutions require explicit insertion of logging logic into business methods, resulting in a serious dilution of core business code by non-functional code and low readability. When logging rules are changed, the business layer code must be fully modified, and regression verification must be performed on all functions, resulting in high maintenance costs. Aspect solutions have difficulty distinguishing the business semantics of subclasses of the same operation category and lack dynamic context analysis capabilities. Non-target methods are easily misidentified as log collection objects, resulting in poor accuracy in identifying operational semantics. Traditional methods only record operation results, but field-level changes occur during the operation process, resulting in the audit log being unable to restore complete operation details and poor change tracking capabilities.
[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the Invention
[0004] The embodiments of the present invention provide a data log full-link tracing method and device, which effectively improves the accuracy of operational semantic recognition and change tracking capabilities, and reduces maintenance costs.
[0005] In one aspect, an embodiment of the present invention provides a data log full-link tracing method, comprising the following steps:
[0006] Define operation log annotations based on target strategies, including batch insert strategy, single insert strategy, delete strategy, or update strategy;
[0007] According to the operation log annotation, the data operation function is fully traced to obtain the tracing results.
[0008] In some embodiments, when the target policy is the batch insert policy, the implementation process of the operation log annotation includes:
[0009] Get the front-end request parameters, table entity class array and operation object ID;
[0010] Create an instance of the batch insert operation log generation tool;
[0011] The batch insert operation log generation tool instance is used to generate batch insert strategy log content according to the front-end request parameters, the table entity class array and the operation object ID.
[0012] In some embodiments, generating the batch insert strategy log content using the batch insert operation log generation tool instance according to the front-end request parameters, the table entity class array, and the operation object ID includes:
[0013] Obtain a list of sub-object names according to the front-end request parameters and the table entity class array;
[0014] According to the table entity class array, obtain the sub-object type name and the main object type name;
[0015] Obtain the main object name according to the table entity class array and the operation object ID;
[0016] According to the sub-object name list, the sub-object type name, the main object name, the main object type name and the preset new character string, batch insert standard format text assembly is performed to obtain the batch insert strategy log content.
[0017] In some embodiments, when the target policy is the single-insert policy, the implementation process of the operation log annotation includes:
[0018] Get the front-end request parameters and table entity class array;
[0019] Initialize the single insert strategy log content;
[0020] Obtaining operation data metadata according to the front-end request parameters;
[0021] Generate a new field based on the operation data metadata;
[0022] sorting the newly added fields;
[0023] According to the operation data metadata, the table entity class array, the sorted newly added fields and the preset newly added character strings, single-insert standard format text assembly is performed, and the single-insert strategy log content is updated.
[0024] In some embodiments, generating a new field based on the operation data metadata includes:
[0025] Initialize the return result list;
[0026] Obtaining a field change mapping table and a field priority mapping table according to the operation data metadata;
[0027] Select a field from the field change mapping table as the target change field;
[0028] Generate standard change content for a single field based on the field name and change value of the target change field;
[0029] Generate a log record object according to the field priority mapping table and the standard change content of the single field;
[0030] Add the log record object to the returned result list;
[0031] The updated returned result list is used as the newly added field.
[0032] In some embodiments, when the target policy is the deletion policy, the implementation process of the operation log annotation includes:
[0033] Get the table entity class array and operation object id;
[0034] Perform data query based on the table entity class array and the operation object ID to obtain a query object name list;
[0035] Get the table name from the query object name list;
[0036] Use the table name as the name of the object to be deleted;
[0037] Generate deletion policy log content according to the table entity class array and the name of the object to be deleted.
[0038] In some embodiments, when the target policy is the update policy, the implementation process of the operation log annotation includes:
[0039] Get the front-end request parameters, table entity class array and operation object ID;
[0040] Query the original object data before modification according to the front-end request parameters, the table entity class array and the operation object ID;
[0041] Generate modified new object data according to the front-end request parameters;
[0042] Extracting original object field mapping, original object sub-object mapping, field priority mapping and target object name from the original object data;
[0043] Extracting a new object field mapping and a new object sub-object mapping from the new object data;
[0044] Generate a change log according to the original object field mapping, the original object sub-object mapping, the field priority mapping, the target object name, the new object field mapping, the new object sub-object mapping, and the target type name;
[0045] If there is a field change in the change log, the change log is used as the update policy log content.
[0046] In some embodiments, generating a change log according to the original object field mapping, the original object sub-object mapping, the field priority mapping, the target object name, the new object field mapping, the new object sub-object mapping, and the target type name includes:
[0047] Initialize the change record list;
[0048] If both the original object field mapping and the new object field mapping are not empty, extracting the target original object field from the original object field mapping;
[0049] Extracting target new object fields from the new object field mapping;
[0050] If the target original object field and the target new object field are different, generating a field change record according to the field priority mapping, and adding the field change record to the change record list;
[0051] If both the original object sub-object mapping and the new object sub-object mapping are not empty, extracting the target original object sub-object from the original object sub-object mapping;
[0052] Extracting a target new object sub-object from the new object sub-object mapping;
[0053] If the target original object sub-object and the target new object sub-object are different, generating a sub-object change record according to the field priority mapping, and adding the sub-object change record to the change record list;
[0054] If the change record list is not empty, sorting the change record list;
[0055] Generate a log header according to the target object name and the target type name;
[0056] The change log is generated according to the log header and the sorted change record list.
[0057] In some embodiments, performing full-link tracing of the data operation function according to the operation log annotation to obtain the tracing result includes:
[0058] Annotate the data operation function according to the operation log annotation;
[0059] Initialize the operation log instance;
[0060] Setting the server start processing time, policy type and object type of the operation log instance;
[0061] Get the parameter content, operation object ID and strategy class in the aspect function;
[0062] Set the operation log content according to the parameter content in the section function;
[0063] Setting the data content of the operation log instance according to the operation object id, the operation log content and the object type;
[0064] Set the current user id of the operation log instance;
[0065] Execute the function annotated in the operation log to obtain a tracking log;
[0066] According to the tracking log, set the operation object id of the operation log instance;
[0067] Setting the server processing completion time of the operation log instance according to the server processing start time;
[0068] The tracing result is generated according to the tracing log and using the operation log instance.
[0069] On the other hand, an embodiment of the present invention provides a data log full-link tracking device, including:
[0070] The first module is used to define an operation log annotation according to a target strategy, wherein the target strategy includes a batch insert strategy, a single insert strategy, a delete strategy, or an update strategy;
[0071] The second module is used to perform full-link tracking of the data operation function according to the operation log annotation to obtain the tracking results.
[0072] In another aspect, an embodiment of the present invention provides a computer device, comprising:
[0073] at least one processor;
[0074] at least one memory for storing at least one program;
[0075] When the at least one program is executed by the at least one processor, the at least one processor implements the method.
[0076] On the other hand, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0077] The beneficial effects of the present invention are as follows:
[0078] An embodiment of the present invention first defines an operation log annotation based on a target strategy, where the target strategy includes a batch insert strategy, a single insert strategy, a deletion strategy, or an update strategy. Then, based on the operation log annotation, the data operation function is fully tracked to obtain a tracking result, thereby enabling full-link tracking of data logs through multiple strategies, thereby improving the accuracy of operation semantic recognition and change tracking capabilities, and reducing maintenance costs.
[0079] Other features and advantages of the present invention will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the structures particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0081] Figure 1 This is a flow chart of a data log full-link tracing method according to an embodiment of the present invention;
[0082] Figure 2 A visualization diagram of tracking results according to an embodiment of the present invention;
[0083] Figure 3 This is a schematic diagram of the structure of a data log full-link tracking device according to an embodiment of the present invention;
[0084] Figure 4 The figure is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0085] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are merely examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the appended claims.
[0086] It will be understood that the terms "first", "second", etc. used in this application may be used herein to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0087] The terms "at least one", "plurality", "each", "any", etc. used in this application include "at least one", "two" or more, "plurality" or "each", "any" or "any one", "each" or "any one" as used herein.
[0088] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0089] Before explaining the embodiments of the present application in detail, some of the nouns and terms involved in the embodiments of the present application are first explained. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0090] A data log is a data structure that records database operations. It is primarily used to ensure data integrity, provide a foundation for fault recovery, support concurrency control, assist in transaction management, and provide a basis for database audits. The data log records all database transaction operations, including inserts, updates, and deletes. These records are stored in chronological order to ensure traceability.
[0091] In information-based scenarios such as enterprise management software and distributed systems, the integrity and traceability of operation logs directly impact the audit compliance of the system. Traditional operation logging methods suffer from core pain points such as loss of operational semantics (e.g., inability to distinguish between "resetting a password" and "changing a username"), opaque change content (e.g., merely recording "user information modified" without specifying the specific field changes), and difficulty adapting across business scenarios. In particular, in the security-critical financial and healthcare sectors, regulators require logs to include: 1) a complete operation chain (operator → operation object → operation content → timestamp); 2) field-level change comparison (old value → new value); and 3) the ability to attribute abnormal operations (failure cause → operation rollback). Traditional operation logging methods employ hard-coded logging patterns, basic aspect-oriented programming logging aspects, or annotation-driven enhancements. However, hard-coded approaches require explicit insertion of logging logic into business methods, significantly diluting the core business code with non-functional code and significantly reducing readability. Changing logging rules requires a complete overhaul of the business-layer code and regression verification of all functionality, resulting in extremely high maintenance costs. Aspect solutions based on method signature parsing cannot distinguish the business semantics of subclasses of the same operation category. At the same time, due to the lack of dynamic context analysis capabilities, non-target methods are easily misidentified as log collection objects, and the ability to identify operational semantics is insufficient. Most solutions only record operation results and lack field-level change comparison, resulting in the audit log being unable to restore complete operation details. For collection-type data structures (such as List and Map), existing solutions cannot identify element-level addition, deletion, and modification operations, and ignore the need for difference comparison of nested objects, resulting in weak change tracking capabilities. When business entities are added, supporting log code needs to be developed for each new entity class, which has low scalability. Aspect definitions based on method names or class paths (such as intercepting all *Service.update* methods) have a high misselection rate, cannot distinguish business semantics, and have poor coarse-grained aspect interception.
[0092] In light of this, the present invention implements precise identification of operational semantics (add, update, delete) and dynamic parameter binding through operation type annotation and SPEL parameter extraction, addressing the decoupling of operational semantics from business scenarios. A reflection comparison engine and a difference snapshot algorithm are designed to support deep comparison of nested objects, enabling rapid comparison and recording of data differences before and after, addressing the challenge of tracking full-field changes.
[0093] The embodiment of the present application provides a data log full-link tracking method, which relates to the field of computer technology. The embodiment of the present application provides a data log full-link tracking method that can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or can be configured as a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network; the software can be an application that implements a data log full-link tracking method, etc., but is not limited to the above forms.
[0094] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
[0095] The following is a detailed explanation of the embodiments of the present application with reference to the accompanying drawings:
[0096] Figure 1 This is an optional flowchart of a data log full-link tracing method provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S102.
[0097] Step S101: define an operation log annotation according to a target strategy, where the target strategy includes a batch insert strategy, a single insert strategy, a delete strategy, or an update strategy;
[0098] Step S102: Based on the operation log annotations, perform full-link tracing of the data operation function to obtain tracing results.
[0099] Steps S101 to S102 shown in the embodiment of the present application implement full-link tracking of data logs, improve the accuracy of operational semantic recognition and change tracking capabilities, and reduce maintenance costs.
[0100] In some embodiments, in step S101, the @OperatorLogAnnotation annotation can be used for non-intrusive log collection. The @OperatorLogAnnotation annotation can be defined to declare operational semantics, dynamically binding parameters such as operator / IP / tenant through SPEL. In the code structure, the @OperatorLogAnnotation annotation is generally only required in methods in the Controller layer (i.e., the control layer) for addition, deletion, and modification. For example, in the create() method, the program code can be expressed as:
[0101]
[0102]
[0103] As you can understand, the @OperatorLogAnnotation annotation contains four parameters: requestObjSpel, iOperatorLogStrategy, tableEntity, and logType. requestObjSpel uses Spring Expression Language (SpEL) to specify the object to be extracted from the request. For example, #student in the code indicates obtaining an object named "student" from a method parameter or request context. iOperatorLogStrategy specifies the logging strategy implementation class, which includes four mode strategies: AddBatchSubObjOperatorLogStrategy (batch insert strategy), AddOperatorLogStrategy (insert strategy), DeleteOperatorLogStrategy (delete strategy), and UpdateOperatorLogStrategy (update strategy). tableEntity declares the entity class associated with the operation log. For example, the code indicates that the log will record operations related to the Student entity. logType defines the log type enumeration value, which includes two types: LogTypeEnum.USER_MANAGE (0, "User management log") and LogTypeEnum.USER_OPERATOR (1, "User operation log"). In the abstract interface that defines the operation log annotation, four different strategies can be implemented, including batch insertion strategy, single insertion strategy, deletion strategy and update strategy.
[0104] In some embodiments, in step S101, when the target policy is a batch insert policy, the implementation process of the operation log annotation may include but is not limited to the following steps:
[0105] Get the front-end request parameters, table entity class array and operation object ID;
[0106] Create an instance of the batch insert operation log generation tool;
[0107] Based on the front-end request parameters, table entity class array and operation object ID, use the batch insert operation log generation tool instance to generate the batch insert strategy log content.
[0108] In some embodiments, an abstract interface (such as AddBatchSubObjOperatorLogStrategy) for operation log annotation can be implemented based on the batch insert strategy. The front-end request parameters (such as requestObj), table entity class array (such as tableEntity) and operation object id (such as operatorObjId) can be obtained first, and then a batch insert operation log generation tool instance (such as subObjectAddBatchUtil) can be created. Then, based on the front-end request parameters, table entity class array and operation object id, the batch insert operation log generation tool instance can be used to generate the batch insert strategy log content. The program code can be expressed as:
[0109]
[0110]
[0111] In some embodiments, based on the front-end request parameters, the table entity class array, and the operation object ID, a batch insert operation log generation tool instance is used to generate the batch insert strategy log content, including:
[0112] Get the sub-object name list based on the front-end request parameters and table entity class array;
[0113] Get the sub-object type name and main object type name according to the table entity class array;
[0114] Get the main object name based on the table entity class array and the operation object id;
[0115] According to the sub-object name list, sub-object type name, main object name, main object type name and preset newly added character string, batch insert standard format text assembly is performed to obtain batch insert strategy log content.
[0116] In some embodiments, the sub-object name list (such as addObjNames) can be obtained based on the front-end request parameters (such as requestObj) and the table entity class array (such as tableEntity). Then, the sub-object type name (such as subObjTypeName) and the main object type name (such as objTypeName) can be obtained based on the table entity class array. Then, the main object name (such as objName) can be obtained based on the table entity class array and the operation object id (such as operatorObjId). Finally, based on the sub-object name list, sub-object type name, main object name, main object type name and preset new string, batch insert standard format text assembly is performed to obtain batch insert policy log content. The program code can be expressed as:
[0117]
[0118]
[0119] Furthermore, the default new string can be set to "%s
%s
%s
[0120]
[0121] In some embodiments, in step S101, when the target policy is a single-insert policy, the implementation process of the operation log annotation may include but is not limited to the following steps:
[0122] Get the front-end request parameters and table entity class array;
[0123] Initialize the single insert strategy log content;
[0124] Obtain operation data metadata based on front-end request parameters;
[0125] Generate new fields based on the metadata of the operation data;
[0126] Sort the newly added fields;
[0127] Based on the operation data metadata, table entity class array, sorted new fields and preset new strings, single insert standard format text is assembled and the single insert strategy log content is updated.
[0128] In some embodiments, an abstract interface (such as AddOperatorLogStrategy) for operation log annotation can be implemented based on a single-insert strategy. The front-end request parameters (such as requestObj) and the table entity class array (such as tableEntity) can be obtained first, and the single-insert strategy log content (such as content) can be initialized. Then, according to the front-end request parameters, the operation data metadata (such as metaData) can be obtained, and then the operation log tool (such as objectAddLogUtil) can be used to generate new fields (such as filedContents) based on the operation data metadata, and sort the new fields (such as sortOperatorLogRecord). Finally, according to the operation data metadata, the table entity class array, the sorted new fields and the preset new strings, the single-insert standard format text is assembled to update the single-insert strategy log content. The program code can be expressed as:
[0129]
[0130]
[0131] And the program code for implementing the operation log tool class can be expressed as:
[0132]
[0133] Furthermore, the default new string can be set to "new %s
%s
[0134]
[0135] In some embodiments, new fields are generated based on the operational data metadata, including:
[0136] Initialize the return result list;
[0137] Obtain the field change mapping table and field priority mapping table based on the operation data metadata;
[0138] Select a field from the field change mapping table as the target change field;
[0139] Generate standard change content for a single field based on the field name and change value of the target change field;
[0140] Generate a log record object based on the field priority mapping table and the standard change content of a single field;
[0141] Add the logging object to the returned result list;
[0142] The updated return result list is used as a new field.
[0143] In some embodiments, the return result list can be initialized first, and then the field change mapping table and field priority mapping table are obtained based on the operation data metadata. Then, each changed field in the field change mapping table can be traversed. During the traversal process, a field can be selected from the field change mapping table as the target changed field. Based on the field name and changed value of the target changed field, the standard change content of the single field is generated. Based on the field priority mapping table and the standard change content of the single field, a log record object is generated, and the log record object is added to the return result list. After traversing all changed fields, the updated return result list is used as the newly added field. The program code can be expressed as:
[0144]
[0145]
[0146] In some embodiments, in step S101, when the target policy is a deletion policy, the implementation process of the operation log annotation may include but is not limited to the following steps:
[0147] Get the table entity class array and operation object id;
[0148] According to the table entity class array and the operation object ID, data query is performed to obtain a list of query object names;
[0149] Get the table name from the query object name list;
[0150] Use the table name as the name of the object to be deleted;
[0151] Generates the deletion policy log content based on the table entity class array and the name of the object to be deleted.
[0152] In some embodiments, an abstract interface (such as DeleteOperatorLogStrategy) for operation log annotation can be implemented according to the deletion strategy. You can first obtain the table entity class array (such as tableEntity) and the operation object id (such as operatorObjId), use the tool class instance (such as OperatorLogUtil) to perform data query based on the table entity class array and the operation object id, obtain the query object name list (such as queryMap), obtain the table name (such as name) from the query object name list, and then use the table name as the name of the object to be deleted (such as objName), and finally generate the deletion strategy log content based on the table entity class array and the name of the object to be deleted. The program code can be expressed as:
[0153]
[0154]
[0155] Furthermore, the program code for generating the standard deletion log format can be expressed as:
[0156]
[0157] More specifically, the program code for the data query process can be expressed as:
[0158]
[0159] In some embodiments, in step S101, when the target policy is an update policy, the implementation process of the operation log annotation may include but is not limited to the following steps:
[0160] Get the front-end request parameters, table entity class array and operation object ID;
[0161] Query the original object data before modification based on the front-end request parameters, table entity class array and operation object ID;
[0162] Generate modified new object data based on front-end request parameters;
[0163] Extracting original object field mapping, original object sub-object mapping, field priority mapping, and target object name from original object data;
[0164] Extract new object field mapping and new object sub-object mapping from new object data;
[0165] Generate a change log based on the original object field mapping, original object sub-object mapping, field priority mapping, target object name, new object field mapping, new object sub-object mapping, and target type name;
[0166] If there are field changes in the change log, the change log will be used as the update policy log content.
[0167] In some embodiments, an abstract interface (such as DeleteOperatorLogStrategy) for operation log annotation can be implemented according to the update strategy. The front-end request parameters (such as requestObj), table entity class array (such as tableEntity) and operation object id (such as operatorObjId) can be obtained first, and the original object data before modification (such as oldObject) can be queried according to the front-end request parameters, table entity class array and operation object id. Then, according to the front-end request parameters, the modified new object data (such as requestObj) can be generated, and the original object field mapping (such as oldOperatorLogMetaData.getFieldMap()), original object sub-object mapping (such as oldOperatorLogMetaData.getSubObjectMap()), field priority mapping (such as oldOperatorLogMetaData.getSubObjectMap()) and so on can be extracted from the original object data. a.getFiledNameAndPriorityMap()) and the target object name (such as oldOperatorLogMetaData.getName()), then extract the new object field mapping (such as newOperatorLogMetaData.getFieldMap()) and the new object sub-object mapping (such as newOperatorLogMetaData.getSubObjectMap()) from the new object data. Finally, based on the original object field mapping, original object sub-object mapping, field priority mapping, target object name, new object field mapping, new object sub-object mapping, and target type name (such as objectType), a change log is generated. If there are field changes in the change log, the change log is used as the update policy log content. The program code can be expressed as:
[0168]
[0169]
[0170]
[0171] In some embodiments, generating a change log based on the original object field mapping, the original object sub-object mapping, the field priority mapping, the target object name, the new object field mapping, the new object sub-object mapping, and the target type name includes:
[0172] Initialize the change record list;
[0173] If both the original object field mapping and the new object field mapping are not empty, the target original object field is extracted from the original object field mapping;
[0174] Extract the target new object fields from the new object field mapping;
[0175] If the target original object fields and the target new object fields are different, a field change record is generated based on the field priority mapping and added to the change record list;
[0176] If both the original object sub-object map and the new object sub-object map are not empty, extract the target original object sub-object from the original object sub-object map;
[0177] Extract the target new object sub-object from the new object sub-object map;
[0178] If the sub-objects of the target original object and the sub-objects of the target new object are different, a sub-object change record is generated based on the field priority mapping and added to the change record list;
[0179] If the change record list is not empty, sort the change record list;
[0180] Generate a log header based on the target object name and target type name;
[0181] Generate a change log based on the log header and the sorted change record list.
[0182] In some embodiments, a change record list (such as result) can be initialized first. If both the original object field mapping and the new object field mapping are not empty (such as Objects.nonNull(oldFieldMap)&&Objects.nonNull(newFieldMap), each original object field in the original object field mapping is traversed, and the target original object field is extracted from the original object field mapping, and the target new object field is extracted from the new object field mapping. If the target original object field and the target new object field are not the same (such as Objects.nonNull(newValue)&&!newValue.equals(entry.getValue())), a field change record is generated according to the field priority mapping, and the field change record is added to the change record list. If both the original object sub-object mapping and the new object sub-object mapping are not empty (such as Objects.nonNull(oldQu oteSubObject)&&Objects.nonNull(newQuoteSubObject)), then traverse each original object sub-object in the original object sub-object mapping, extract the target original object sub-object from the original object sub-object mapping, and extract the target new object sub-object from the new object sub-object mapping. If the target original object sub-object and the target new object sub-object are not the same (such as Objects.nonNull(newValue)&&!newValue.getId().equals(entry.getValue().getId())), then generate a sub-object change record according to the field priority mapping, and add the sub-object change record to the change record list. If the change record list is not empty, sort the change record list, and then generate a log header according to the target object name and target type name. Generate a change log based on the log header and the sorted change record list. The program code can be expressed as:
[0183]
[0184]
[0185]
[0186]
[0187] In some embodiments, in step S102, full-link tracing of the data operation function is performed based on the operation log annotation to obtain tracing results, which may include but is not limited to the following steps:
[0188] Annotate data operation functions according to the operation log annotations;
[0189] Initialize the operation log instance;
[0190] Set the server start processing time, policy type, and object type for the operation log instance;
[0191] Get the parameter content, operation object ID and strategy class in the aspect function;
[0192] Set the operation log content according to the parameter content in the slice function;
[0193] Set the data content of the operation log instance according to the operation object id, operation log content and object type;
[0194] Set the current user id of the operation log instance;
[0195] Execute the function annotated in the operation log to obtain the tracking log;
[0196] According to the tracking log, set the operation object id of the operation log instance;
[0197] Set the server processing completion time of the operation log instance based on the server start processing time;
[0198] Based on the tracking log, the tracking results are generated using the operation log instance.
[0199] In some embodiments, the data operation function can be annotated according to the operation log annotation, and then the operation log instance can be initialized, and the server start processing time (such as operatorLog.setStartTime), strategy type (such as operatorLog.setType) and object type (such as tableEntity) of the operation log instance can be set, and the parameter content (such as context), operation object id (such as operatorObjId) and strategy class (such as iOperateLogStrategy) in the aspect function can be obtained, and then the operation log content (such as requestObj) can be set according to the parameter content in the aspect function. The data content of the operation log instance is set (such as operatorLog.setContent), the current user id of the operation log instance is set (such as operatorLog.setUserId), and finally the function annotated with the operation log is executed (such as joinPoint.proceed()) to obtain the tracking log. According to the tracking log, the operation object id of the operation log instance is set, and according to the server start processing time, the server processing completion time of the operation log instance is set (such as operatorLog.setEndTime). According to the tracking log, the operation log instance is used to generate the tracking result. The visual diagram of the tracking result is as follows: Figure 2 As shown. The program code can be expressed as:
[0200]
[0201]
[0202] It can be understood that the @Around annotation parameter value="operatorLogPointCut(operatorLogAnnotation)" specifies the pointcut expression, where operatorLogPointCut is the pointcut method name and operatorLogAnnotation is the pointcut method parameter, matching methods annotated with the OperatorLogAnnotation. In the argNames parameter, argNames="joinPoint,operatorLogAnnotation" declares the notification method parameter name list, which must strictly correspond to the order of the aspect method parameters. Here, joinPoint is the join point object (a required parameter) and operatorLogAnnotation is the annotation instance extracted from the pointcut. In the method parameter ProceedingJoinPoint, joinPoint provides full control over the target method, including method signature information (getSignature), parameter values (getArgs), and method execution control (proceed). OperatorLogAnnotation operatorLogAnnotation automatically injects annotation instances, which can be used to obtain: parameter values configured by the annotation and the SPEL expression structure parsed at runtime.
[0203] In some embodiments, compared with the traditional method, the code of the traditional method is highly invasive, while the present embodiment can achieve zero intrusion (pure annotation drive). The framework dependency of the traditional method is strongly bound to MyBatis-Plus. The present embodiment supports a custom annotation system. The change tracking accuracy of the traditional method only supports single-layer objects, while the present embodiment supports nested objects (depth controllable). At the same time, the present embodiment uses the @OperatorLogAnnotation annotation declaration mechanism to implement a composite annotation system. The present embodiment implements a template engine that dynamically binds SPEL to object comparison results through mixed expression parsing. Data can be compared through a difference algorithm.
[0204] The beneficial effects of implementing the embodiments of the present invention include: the embodiments of the present invention first define operation log annotations based on the target strategy, where the target strategy includes a batch insertion strategy, a single insertion strategy, a deletion strategy or an update strategy, and then perform full-link tracking of the data operation function based on the operation log annotation to obtain the tracking results, thereby enabling full-link tracking of data logs through multiple strategies, thereby improving the accuracy of operation semantic recognition and change tracking capabilities, and reducing maintenance costs.
[0205] like Figure 3 As shown, an embodiment of the present invention further provides a data log full-link tracking device, including:
[0206] The first module 801 is used to define operation log annotations according to a target strategy, where the target strategy includes a batch insert strategy, a single insert strategy, a delete strategy, or an update strategy;
[0207] The second module 802 is used to perform full-link tracing of the data operation function according to the operation log annotation to obtain the tracing result.
[0208] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0209] like Figure 4 As shown, an embodiment of the present invention further provides a computer device, including:
[0210] at least one processor 901;
[0211] At least one memory 902, configured to store at least one program;
[0212] When at least one program is executed by at least one processor, the at least one processor implements Figure 1 The method shown.
[0213] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0214] The embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program, which is executed by a processor to implement Figure 1 The method shown.
[0215] The contents of the above method embodiments are all applicable to the present storage medium embodiment. The functions specifically implemented by the present storage medium embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0216] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.
Claims
1. A data log full-link tracking method, characterized in that: The following steps are involved: Define operation log annotations based on target strategies, including batch insert strategy, single insert strategy, delete strategy, or update strategy; According to the operation log annotation, the data operation function is fully traced to obtain the tracing results.
2. The method according to claim 1, characterized in that When the target strategy is the batch insert strategy, the implementation process of the operation log annotation includes: Get the front-end request parameters, table entity class array and operation object ID; Create an instance of the batch insert operation log generation tool; The batch insert operation log generation tool instance is used to generate batch insert strategy log content according to the front-end request parameters, the table entity class array and the operation object ID.
3. The method according to claim 2, characterized in that The step of generating the batch insert strategy log content by using the batch insert operation log generation tool instance according to the front-end request parameters, the table entity class array, and the operation object ID includes: Obtain a list of sub-object names according to the front-end request parameters and the table entity class array; According to the table entity class array, obtain the sub-object type name and the main object type name; Obtain the main object name according to the table entity class array and the operation object ID; According to the sub-object name list, the sub-object type name, the main object name, the main object type name and the preset new character string, batch insert standard format text assembly is performed to obtain the batch insert strategy log content.
4. The method according to claim 1, wherein When the target strategy is the single-insert strategy, the implementation process of the operation log annotation includes: Get the front-end request parameters and table entity class array; Initialize the single insert strategy log content; Obtaining operation data metadata according to the front-end request parameters; Generate a new field based on the operation data metadata; sorting the newly added fields; According to the operation data metadata, the table entity class array, the sorted newly added fields and the preset newly added character strings, single-insert standard format text assembly is performed, and the single-insert strategy log content is updated.
5. The method according to claim 4, characterized in that Generating a new field according to the operation data metadata includes: Initialize the return result list; Obtaining a field change mapping table and a field priority mapping table according to the operation data metadata; Select a field from the field change mapping table as the target change field; Generate standard change content for a single field based on the field name and change value of the target change field; Generate a log record object according to the field priority mapping table and the standard change content of the single field; Add the log record object to the returned result list; The updated returned result list is used as the newly added field.
6. The method according to claim 1, characterized in that When the target policy is the deletion policy, the implementation process of the operation log annotation includes: Get the table entity class array and operation object id; Perform data query based on the table entity class array and the operation object ID to obtain a query object name list; Get the table name from the query object name list; Use the table name as the name of the object to be deleted; Generate deletion policy log content according to the table entity class array and the name of the object to be deleted.
7. The method according to claim 1, characterized in that When the target policy is the update policy, the implementation process of the operation log annotation includes: Get the front-end request parameters, table entity class array and operation object ID; Query the original object data before modification according to the front-end request parameters, the table entity class array and the operation object ID; Generate modified new object data according to the front-end request parameters; Extracting original object field mapping, original object sub-object mapping, field priority mapping and target object name from the original object data; Extracting a new object field mapping and a new object sub-object mapping from the new object data; Generate a change log according to the original object field mapping, the original object sub-object mapping, the field priority mapping, the target object name, the new object field mapping, the new object sub-object mapping, and the target type name; If there is a field change in the change log, the change log is used as the update policy log content.
8. The method according to claim 7, characterized in that Generating a change log according to the original object field mapping, the original object sub-object mapping, the field priority mapping, the target object name, the new object field mapping, the new object sub-object mapping, and the target type name includes: Initialize the change record list; If both the original object field mapping and the new object field mapping are not empty, extracting the target original object field from the original object field mapping; Extracting target new object fields from the new object field mapping; If the target original object field and the target new object field are different, generating a field change record according to the field priority mapping, and adding the field change record to the change record list; If both the original object sub-object mapping and the new object sub-object mapping are not empty, extracting the target original object sub-object from the original object sub-object mapping; Extracting a target new object sub-object from the new object sub-object mapping; If the target original object sub-object and the target new object sub-object are different, generating a sub-object change record according to the field priority mapping, and adding the sub-object change record to the change record list; If the change record list is not empty, sorting the change record list; Generate a log header according to the target object name and the target type name; The change log is generated according to the log header and the sorted change record list.
9. The method according to claim 1, characterized in that The data operation function is fully traced according to the operation log annotation to obtain the tracing results, including: Annotate the data operation function according to the operation log annotation; Initialize the operation log instance; Setting the server start processing time, policy type and object type of the operation log instance; Get the parameter content, operation object ID and strategy class in the aspect function; Set the operation log content according to the parameter content in the section function; Setting the data content of the operation log instance according to the operation object id, the operation log content and the object type; Set the current user id of the operation log instance; Execute the function annotated in the operation log to obtain a tracking log; According to the tracking log, set the operation object id of the operation log instance; Setting the server processing completion time of the operation log instance according to the server processing start time; The tracing result is generated according to the tracing log and using the operation log instance.
10. A data log full-link tracking device, characterized in that: include: The first module is used to define an operation log annotation according to a target strategy, wherein the target strategy includes a batch insert strategy, a single insert strategy, a delete strategy, or an update strategy; The second module is used to perform full-link tracking of the data operation function according to the operation log annotation to obtain the tracking results.
Citation Information
Patent Citations
Operation log processing method and device, electronic equipment and storage medium
CN113360138A
Operation log generation method and device, equipment and medium
CN115858466A
Blockchain-based certificate data generation method and apparatus, and computer device
WO2024060390A1