Operation log processing method and device, electronic equipment and storage medium

By obtaining operation log annotations from the persistent layer interface, data before and after the operation is retrieved and saved, thus solving the problem of operation logs being intrusive to the service layer and presentation layer, achieving decoupling of operation logs and improving the reliability of data snapshots.

CN113360138BActive Publication Date: 2026-05-29WEBANK (CHINA)

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
WEBANK (CHINA)
Filing Date
2021-06-18
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In existing technologies, the operation log function is highly intrusive to the business code of the service layer and presentation layer, resulting in high coupling between different functional modules in the software system, increasing development and maintenance costs, and posing a security risk of data being captured and tampered with.

Method used

By obtaining the operation log annotations of the target persistence layer interface, the system can acquire and save the data before and after the operation of the target data, reducing the intrusion on the business code of the service layer and presentation layer. The operation log recording function is implemented by a plugin and coheded into the backend system, decoupling it from the business code of the service layer.

Benefits of technology

It reduces the coupling between different functional modules in the software system, improves the reliability of data snapshots recorded in operation logs, and reduces the security risks of data tampering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113360138B_ABST
    Figure CN113360138B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a kind of operation log processing method, device, electronic equipment and computer storage medium, the method comprises: determining target persistence layer interface, target persistence layer interface is called when editing target data Operation of persistence layer interface;Operation log annotation corresponding to target persistence layer interface is obtained;Operation log annotation is used to characterize the persistence layer query interface of target data;Before editing target data, the operation before data of target data is obtained according to operation log annotation;And / or, after editing target data, the operation after data of target data is obtained according to operation log annotation;The operation before data of target data and / or the operation after data of target data is saved to operation log.Based on the operation log processing method of the present application, the coupling of different functional modules in software system can be reduced, and the reliability of operation log record data snapshot can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of financial technology (Fintech), and more particularly to an operation log processing method, apparatus, electronic device, and computer storage medium. Background Technology

[0002] With the development of computer technology, more and more technologies are being applied in the financial field. The traditional financial industry is gradually transforming into financial technology. However, due to the security and real-time requirements of the financial industry, higher demands are also being placed on technology.

[0003] Service-Oriented Architecture (SOA) breaks down a software system into a presentation layer, a service layer, and a persistence layer, each corresponding to different functional modules. The service layer is primarily responsible for handling business logic, managing page interactions, and providing services to the user. Business logic can be set up in the service layer, and this logic can call services within the service layer. The persistence layer is responsible for calling the framework's underlying interfaces and performing database access operations, including adding, deleting, modifying, and querying data.

[0004] The Operation Log tracks the time and network address information of user operations on the database, recording data snapshots before and after the operations. Before performing any operations, users query the database to retrieve data. When an operation is performed, the presentation layer sends an edit request to the service layer, including the previous query record and the updated data. The service layer adds a new record to the Operation Log, updating the existing data record; it also stores the values ​​of the previous query and the updated data in the Operation Log.

[0005] In related technologies, implementing operation log functionality requires writing corresponding pre-record and post-record business logic in the service layer for each editing service, resulting in strong intrusion into the service layer's business code. The presentation layer's program functionality also needs to additionally store the query results of the target data and carry these results with it when initiating an edit operation request, thus exhibiting strong intrusion into the presentation layer's business code. This high intrusion of business code leads to high coupling between different functional modules in the software system, increasing development and maintenance costs. Therefore, reducing the coupling between different functional modules in a software system has become a crucial problem that urgently needs to be addressed. Summary of the Invention

[0006] This application provides an operation log processing method, apparatus, electronic device, and computer storage medium, which can reduce the coupling between different functional modules in a software system.

[0007] This application provides an embodiment of an operation log processing method, including:

[0008] Determine the target persistence layer interface, which is the persistence layer interface called when editing target data; obtain the operation log annotation corresponding to the target persistence layer interface; the operation log annotation is used to characterize the persistence layer query interface corresponding to the target data;

[0009] Before editing the target data, obtain the pre-operation data of the target data according to the operation log annotation; and / or, after editing the target data, obtain the post-operation data of the target data according to the operation log annotation;

[0010] Save the data before and / or after the operation of the target data to the operation log.

[0011] In one implementation, obtaining pre-operation data of the target data based on the operation log annotations before editing the target data includes:

[0012] Obtain the semantic information of the target persistence layer interface;

[0013] When the semantic information of the target persistence layer interface pertains to deleting or modifying the target data, the pre-operation data of the target data is obtained based on the operation log annotation before the editing operation is performed on the target data.

[0014] In one implementation, the step of obtaining the post-operation data of the target data according to the operation log annotation after editing the target data includes:

[0015] Obtain the semantic information of the target persistence layer interface;

[0016] When the semantic information of the target persistence layer interface pertains to inserting or modifying the target data, after the target data is edited, the post-operation data of the target data is obtained according to the operation log annotation.

[0017] In one implementation, the method further includes:

[0018] Generate operation log annotations corresponding to the target persistence layer interface. The operation log annotations include the identification information of the target data and the mapping relationship between the persistence layer query interface corresponding to the target data.

[0019] In one implementation, obtaining the pre-operation data and / or post-operation data of the target data based on the operation log annotations includes:

[0020] Parse the operation log annotations to obtain the identification information of the target data and the mapping relationship between the persistent layer query interface corresponding to the target data;

[0021] Based on the identification information of the target data and the mapping relationship, determine the persistent layer query interface corresponding to the target data;

[0022] Based on the persistent layer query interface corresponding to the target data, obtain the pre-operation data and / or post-operation data of the target data.

[0023] In one implementation, obtaining the operation log annotation corresponding to the target persistence layer interface includes:

[0024] Determine the database statement to be executed when editing the target data; obtain the mapping statement corresponding to the database statement, the mapping statement being used to set the operation log annotation corresponding to the target persistence layer interface;

[0025] Parse the mapping statement corresponding to the database statement according to the syntax rules of the mapping statement, and obtain the operation log annotation corresponding to the target persistence layer interface;

[0026] When the operation log annotation corresponding to the target persistence layer interface is obtained, it is determined that the pre-operation data and / or post-operation data of the target data need to be saved to the operation log.

[0027] In one implementation, the step of obtaining the pre-operation data and / or post-operation data of the target data based on the operation log annotation is implemented based on a plugin.

[0028] An operation log processing device provided in this application includes:

[0029] The determination module is used to determine the target persistence layer interface, which is the persistence layer interface called when editing target data; and to obtain the operation log annotation corresponding to the target persistence layer interface; the operation log annotation is used to characterize the persistence layer query interface corresponding to the target data.

[0030] The processing module is configured to obtain pre-operation data of the target data based on the operation log annotations before performing an editing operation on the target data; and / or, obtain post-operation data of the target data based on the operation log annotations after performing an editing operation on the target data.

[0031] The storage module is used to save the pre-operation data and / or post-operation data of the target data to the operation log.

[0032] In one implementation, the processing module is configured to obtain pre-operation data of the target data based on the operation log annotations before performing editing operations on the target data, including:

[0033] Obtain the semantic information of the target persistence layer interface;

[0034] When the semantic information of the target persistence layer interface pertains to deleting or modifying the target data, the pre-operation data of the target data is obtained based on the operation log annotation before the editing operation is performed on the target data.

[0035] In one implementation, the processing module is configured to, after performing an editing operation on the target data, obtain post-operation data of the target data based on the operation log annotations, including:

[0036] Obtain the semantic information of the target persistence layer interface;

[0037] When the semantic information of the target persistence layer interface pertains to inserting or modifying the target data, after the target data is edited, the post-operation data of the target data is obtained according to the operation log annotation.

[0038] In one implementation, the processing module is further configured to: generate an operation log annotation corresponding to the target persistence layer interface, wherein the operation log annotation includes the identification information of the target data and the mapping relationship between the persistence layer query interface corresponding to the target data.

[0039] In one implementation, the processing module is configured to obtain pre-operation data and / or post-operation data of the target data based on the operation log annotations, including:

[0040] Parse the operation log annotations to obtain the identification information of the target data and the mapping relationship between the persistent layer query interface corresponding to the target data;

[0041] Based on the identification information of the target data and the mapping relationship, determine the persistent layer query interface corresponding to the target data;

[0042] Based on the persistent layer query interface corresponding to the target data, obtain the pre-operation data and / or post-operation data of the target data.

[0043] In one implementation, obtaining the operation log annotation corresponding to the target persistence layer interface includes:

[0044] Determine the database statement to be executed when editing the target data; obtain the mapping statement corresponding to the database statement, the mapping statement being used to set the operation log annotation corresponding to the target persistence layer interface;

[0045] Parse the mapping statement corresponding to the database statement according to the syntax rules of the mapping statement, and obtain the operation log annotation corresponding to the target persistence layer interface;

[0046] When the operation log annotation corresponding to the target persistence layer interface is obtained, it is determined that the pre-operation data and / or post-operation data of the target data need to be saved to the operation log.

[0047] In one implementation, the processing module's step of obtaining the pre-operation data and / or post-operation data of the target data based on the operation log annotations is implemented using a plugin.

[0048] This application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory that can run on the processor. When the processor executes the program, it implements the operation log processing method provided by one or more of the aforementioned technical solutions.

[0049] This application provides a computer storage medium storing a computer program; when the computer program is executed, it can implement the operation log processing method provided by one or more of the aforementioned technical solutions.

[0050] Based on the operation log processing method of this application, the operation log annotation corresponding to the target persistence layer interface is obtained; the operation log annotation is used to characterize the persistence layer query interface corresponding to the target data; the pre-operation data and / or post-operation data of the target data are obtained according to the operation log annotation; and the pre-operation data and / or post-operation data of the target data are saved to the operation log. This eliminates the need to write program code in the service layer to implement the pre-recording and post-recording functions in the operation log, and instead requires writing program code in the presentation layer to implement the function of saving query records. This reduces the intrusion of the operation log function on the business code of the service layer, thereby reducing the coupling between different functional modules in the software system. Furthermore, by not relying on edit operation requests sent by the presentation layer for value passing, the security risk of data being intercepted and tampered with is reduced, thus improving the reliability of data snapshots recorded in the operation log.

[0051] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Attached Figure Description

[0052] Figure 1 This is an application scenario diagram of an operation log processing method provided in related technologies;

[0053] Figure 2 A flowchart illustrating an operation log processing method provided in an embodiment of this application;

[0054] Figure 3 A flowchart illustrating the process of obtaining pre-operation data and / or post-operation data of target data provided in an embodiment of this application;

[0055] Figure 4 This is a schematic diagram of the process for obtaining the operation log annotation corresponding to the target persistence layer interface provided in an embodiment of this application;

[0056] Figure 5 This is an application scenario diagram of the operation log processing method provided in the embodiments of this application;

[0057] Figure 6 Another application scenario diagram of the operation log processing method provided in the embodiments of this application;

[0058] Figure 7 This is another application scenario diagram of the operation log processing method provided in the embodiments of this application;

[0059] Figure 8 A schematic diagram of an operation log processing device provided in an embodiment of this application;

[0060] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0061] The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments provided herein are merely illustrative of the present application and are not intended to limit the present application. Furthermore, the embodiments provided below are some embodiments for implementing the present application, and not all embodiments for implementing the present application. Unless otherwise specified, the technical solutions described in the embodiments of the present application can be implemented in any combination.

[0062] In a service-oriented architecture, a software system is divided into a presentation layer, a service layer, and a persistence layer. The presentation layer is the front-end of the software system, while the service and persistence layers are the back-end. The service layer can be implemented using Spring MVC. Spring MVC is a lightweight, request-driven web framework based on Java that conforms to the Model-View-Controller architectural pattern, decoupling front-end page display, control logic, and data storage.

[0063] Figure 1The diagram illustrates an application scenario of an operation log processing method provided in related technologies. See also... Figure 1 In related technologies, the data processing flow when a user initiates an edit operation request may include: Step 101: The user initiates a data query request; Step 102: The service layer queries the target data in the database; Step 103: The database returns the target data to the user; Step 104: The service layer assembles the target data and returns the target data to the presentation layer; Step 105: The target data is stored in the memory of the presentation layer.

[0064] Step 106: The presentation layer retrieves the target data from memory; Step 107: The user initiates an edit operation request for the target data; Step 108: The data obtained from querying the target data is used as the pre-operation data of the target data, and the pre-operation data of the target data is recorded in the operation log of the database; Step 109: The database table record is modified; Step 110: The data obtained after the edit operation on the target data is used as the post-operation data of the target data, and the post-operation data of the target data is recorded in the operation log of the database; Step 111: The modification result of the edit operation on the target data is returned to the user.

[0065] In related technologies, implementing the operation log function requires writing corresponding pre-record and post-record business logic in the service layer for each editing service. Therefore, it is highly intrusive to the business code of the service layer. The presentation layer's program functionality needs to additionally store the query results of the target data and carry these results with it when initiating an edit operation request. Therefore, it is also highly intrusive to the business code of the presentation layer.

[0066] Figure 2 A schematic flowchart of the operation log processing method provided in an embodiment of this application is shown. See also... Figure 2 The operation log processing method provided in this application embodiment may include the following steps:

[0067] Step A201: Determine the target persistence layer interface, which is the persistence layer interface called when editing the target data.

[0068] Here, the target data can be at least one piece of data displayed in the front-end interface. The types of editing operations on the target data can include any of the following: add, delete, modify, or query.

[0069] It should be understood that the persistence layer is a layered concept in enterprise system programming, and the persistence layer is the database operation interface.

[0070] In the example, when editing the target data, the database operations in the persistence layer can be handled by the MyBatis framework. MyBatis is a Java-based persistence layer framework.

[0071] In the example, when editing target data, one target persistence layer interface can correspond to one table operation.

[0072] Step A202: Obtain the operation log annotation corresponding to the target persistence layer interface; the operation log annotation is used to characterize the persistence layer query interface corresponding to the target data.

[0073] Here, operation log annotations are code-level descriptions used to add operation log annotations to a certain program entry point.

[0074] In the example, the operation log annotation corresponding to the target persistence layer interface is obtained based on the definition of the expression for the parameter mapping relationship corresponding to the target persistence layer interface.

[0075] In the example, if the operation log annotation corresponding to the target persistence layer interface is obtained, it indicates that this database operation needs to record operation logs related to the target data, and step A203 is executed. Otherwise, step A203 is not executed, and the process can end.

[0076] Step A203: Before performing editing operations on the target data, obtain the pre-operation data of the target data based on the operation log annotations; and / or, after performing editing operations on the target data, obtain the post-operation data of the target data based on the operation log annotations.

[0077] Here, the data before the operation corresponds to the database record before the operation, which can be a field value or a record in the entire database table. The data after the operation corresponds to the database record after the operation, which can be a field value or a record in the entire database table.

[0078] In the example, the operation log for the target data may include pre-operation data and / or post-operation data. The decision on whether to record pre-operation data and / or post-operation data is made based on the operation log annotations corresponding to the target persistence layer interface.

[0079] In the example, when it is determined that the pre-operation data and / or post-operation data of the target data need to be recorded, the persistent layer query interface corresponding to the target data is analyzed based on the operation log annotation, and the persistent layer query interface corresponding to the target data is called to obtain the pre-operation data and / or post-operation data of the target data.

[0080] In the example, the persistent layer query interface defined by the execution operation log annotation is used to obtain the pre-operation data and / or post-operation data of the target data.

[0081] Step A204: Save the data before and / or after the operation of the target data to the operation log.

[0082] Here, the operation log focuses on the time information and network address information when users perform data operations on the database, and records data snapshots before and after the user performs data operations.

[0083] In the example, a table structure for the operation log is created. The table structure for the operation log can include any of the following information: the identifier information of the target data, the user information corresponding to the target data, the operation time of the target data, the data before the operation of the target data, and the data after the operation of the target data.

[0084] In the example, the database automatically generates the identification information of the target data; based on the context of the edit operation request sent by the user, the user information corresponding to the target data is obtained; and the machine time when the edit operation is performed on the target data is taken as the operation time of the target data.

[0085] In the example, based on the context of the edit operation request sent by the user, the identification information of the target data is obtained, and the identification information of the target data that depends on the target data is used to obtain the operation log records about the target data.

[0086] Based on the operation log processing method of this application, the operation log annotation corresponding to the target persistence layer interface is obtained; the operation log annotation is used to characterize the persistence layer query interface corresponding to the target data; the pre-operation data and / or post-operation data of the target data are obtained according to the operation log annotation; and the pre-operation data and / or post-operation data of the target data are saved to the operation log. It eliminates the need to write program code in the service layer to implement the pre-recording and post-recording functions of the operation log, and to write program code in the presentation layer to implement the function of saving query records. Therefore, the intrusion of the operation log function on the business code of the service layer can be reduced, thereby reducing the coupling between different functional modules in the software system. By not relying on the edit operation request sent by the presentation layer for value passing, the security risk of data being intercepted and tampered with can be reduced, thereby improving the reliability of the data snapshot recorded in the operation log.

[0087] In practical applications, steps A201 to A204 can be implemented using a processor, which can be at least one of the following: Application Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), Central Processing Unit (CPU), controller, microcontroller, and microprocessor.

[0088] In one implementation, in step A203 above, before performing editing operations on the target data, obtaining the pre-operation data of the target data based on the operation log annotations may include the following steps:

[0089] Obtain semantic information of the target persistence layer interface; if the semantic information of the target persistence layer interface pertains to deleting or modifying the target data, obtain the pre-operation data of the target data based on the operation log annotation before performing the editing operation on the target data.

[0090] In the example, within the Mybatis framework, the interceptor can intercept the target persistence layer interface and determine whether the SQL statement of the target persistence layer interface is an "update" or "insert" semantic by parsing the Structured Query Language (SQL) template corresponding to the target interface.

[0091] Here, the Mybatis framework is a persistence layer framework that supports dynamically modifying structured query statements. It uses Extensible Markup Language (XML) or annotations to implement mapping functionality, mapping the persistence layer interface to records in the database.

[0092] In the example, when the SQL statement in the target persistence layer interface is of "update" or "insert" semantics, the operation log records the data after the operation corresponding to the target data.

[0093] Here, the SQL statement of the target persistence layer interface corresponds to the persistence layer interface called when editing the target data.

[0094] In the example, when the SQL statement of the target persistence layer interface has "update" semantics, the data before the operation on the target data is recorded. The operation log record for the data to be inserted is retrieved based on the identifier information of the target data, and the data after the operation on the target data is updated in the operation log. When the SQL statement of the target persistence layer interface has "insert" semantics, a new operation log record is added to the operation log table, recording the data after the operation on the target data.

[0095] In one implementation, in step A203 above, after editing the target data, obtaining the post-operation data of the target data based on the operation log annotations may include the following steps:

[0096] Obtain the semantic information of the target persistence layer interface; when the semantic information of the target persistence layer interface belongs to inserting or modifying the target data, after the editing operation on the target data, obtain the post-operation data of the target data according to the operation log annotation.

[0097] In the example, within the Mybatis framework, the interceptor can intercept the target persistence layer interface. By parsing the SQL template corresponding to the target interface, it determines whether the SQL statement of the target persistence layer interface has "update" or "delete" semantics. If the SQL statement of the target persistence layer interface has "update" or "delete" semantics, the data before the operation is recorded in the operation log.

[0098] In one implementation, the method further includes: generating operation log annotations corresponding to the target persistence layer interface, wherein the operation log annotations include the identification information of the target data and the mapping relationship between the persistence layer query interface corresponding to the target data.

[0099] In the example, the semantic information of the target persistence layer interface may include any of the following: "update" semantics, "insert" semantics, or "delete" semantics.

[0100] In practical applications, users can add operation log annotations corresponding to the persistence layer interfaces according to business needs. Within these operation log annotations, users can define custom expressions representing the parameter mapping relationships for the target persistence layer interface.

[0101] Here, when defining the expression for the parameter mapping relationship corresponding to the target persistence layer interface, you can set the mapping statement (MappingStatement) corresponding to the target persistence layer interface in the Mybatis framework.

[0102] In the example, EL (Expression Language) expressions can be used to form operation log annotations, as shown below:

[0103] @LogMapping(

[0104] selectSql="name of the persistence layer query interface"

[0105] paramMapping = "an expression for parameter mapping relationships" )

[0107] Here, the parameter paramMapping is used to define the expression for the parameter mapping relationship.

[0108] In the example, the expression for the parameter mapping relationship can use EL expressions to define the mapping relationship between the identification information of the target data and the persistent layer query interface corresponding to the target data.

[0109] It should be understood that EL expressions are Spring's expression language, which supports defining parameter mapping relationships in operation log annotations.

[0110] In one implementation, in step A203 above, the pre-operation data and / or post-operation data of the target data are obtained based on the operation log annotations, see [link to relevant documentation]. Figure 3 This may include the following steps:

[0111] Step A301: Parse the operation log annotations to obtain the identification information of the target data and the mapping relationship between the persistent layer query interface corresponding to the target data.

[0112] In the example, based on the identification information of the target persistence layer interface, the database statements executed when editing the target data are read, and the operation log annotations of the target persistence layer interface are determined.

[0113] In the example, based on the EL expression syntax rules used in the mapping statements in the operation log annotations, the operation log annotations of the target persistence layer interface are parsed to obtain the identification information of the target data and the mapping relationship between the target data and the corresponding persistence layer query interface.

[0114] Step A302: Determine the persistent layer query interface corresponding to the target data based on the identification information and mapping relationship of the target data.

[0115] In the example, the persistent layer query interface corresponding to the target data is determined based on the identification information of the target data and the mapping relationship between the identification information of the target data and the persistent layer query interface corresponding to the target data.

[0116] Step A303: Obtain the pre-operation data and / or post-operation data of the target data according to the persistent layer query interface corresponding to the target data.

[0117] In the example, based on the persistent layer query interface corresponding to the target data, the database is queried for the pre-operation data and / or post-operation data of the target data according to the identification information of the target data, and the pre-operation data and / or post-operation data of the target data are obtained.

[0118] In related technologies, when the user's edit operation request does not include post-operation data for the target data, the service layer cannot record the post-operation data for the target data in the operation log. For example, for the service layer's batch processing instruction "increase the age of each customer by one year," if the edit operation request does not include the post-operation data corresponding to "modify the customer's age to a specific value," and the edit operation request does not specify the identification information of the target data corresponding to the customer's age, the service layer cannot obtain the pre-operation data and post-operation data for "customer's age," and therefore cannot obtain a data snapshot of the operation log record for "customer's age" when executing the batch processing and data editing operation corresponding to "increase the age of each customer by one year."

[0119] In this embodiment, the post-operation data of the target data is obtained according to the persistent layer query interface of the target data. For the batch processing instruction "increase the age of each customer by one year" in the service layer, when executing the batch processing or data editing operation corresponding to "increase the age of each customer by one year", the operation log annotation of the target persistent layer interface called during the editing operation of the target data to which "customer age" belongs can be used to obtain the pre-operation data and / or post-operation data of the target data, thereby improving the reliability of the data snapshot recorded in the operation log.

[0120] In one implementation, in step A202 above, the operation log annotation corresponding to the target persistence layer interface is obtained, see [link to relevant documentation]. Figure 4 This may include the following steps:

[0121] Step A401: Determine the database statement executed when editing the target data; obtain the mapping statement corresponding to the database statement, which is used to set the operation log annotation corresponding to the target persistence layer interface.

[0122] In the example, the system detects the user's editing operation on the target data, determines the persistence layer interface called when the user performs the editing operation on the target data, and determines the database statement executed when the user performs the editing operation on the target data based on the operation type of the data operation performed by the called persistence layer interface.

[0123] In the example, the database statements executed when editing the target data are encapsulated to obtain the corresponding mapping statements.

[0124] In the example, the mapping statement can use EL expressions to define the mapping relationship between the identifier information of the target data and the corresponding persistence layer query interface. Therefore, the mapping statement can be used to set the operation log annotations corresponding to the target persistence layer interface.

[0125] In the example, the software system can use the Interceptor interface of the Mybatis framework to intercept the Executor and detect the expression of the parameter mapping relationship of all target persistence layer interfaces to be executed. Therefore, it can obtain the mapping statement corresponding to the database statement executed when editing the target data.

[0126] Here, Interceptor is the name of the interceptor in the Mybatis framework, and Executor is the executor in the Mybatis framework that executes the MappingStatement mapping statement.

[0127] Step A402: Parse the mapping statement corresponding to the database statement according to the syntax rules of the mapping statement, and obtain the operation log annotation corresponding to the target persistence layer interface.

[0128] In the example, the mapping statement corresponding to the database statement is parsed according to the syntax rules of the mapping statement, and an attempt is made to obtain the operation log annotation corresponding to the target persistence layer interface.

[0129] Step A403: When the operation log annotation corresponding to the target persistence layer interface is obtained, determine whether the data before the operation and / or the data after the operation of the target data need to be saved to the operation log.

[0130] In the example, when the operation log annotation corresponding to the target persistence layer interface is obtained, it indicates that the data before and / or after the operation of the target data needs to be saved to the operation log. That is, the database operation on the target data needs to be recorded in the operation log.

[0131] In the example, if the operation log annotation corresponding to the target persistence layer interface cannot be obtained, it means that it is not necessary to save the pre-operation data and / or post-operation data of the target data to the operation log. That is, the database operation on the target data does not need to be recorded in the operation log.

[0132] In one implementation, the steps of obtaining the pre-operation data and / or post-operation data of the target data based on operation log annotations are implemented using a plugin.

[0133] In the example, a general program plugin is used to obtain the pre-operation data and / or post-operation data of the target data based on the operation log annotations corresponding to the target persistence layer interface, and then saves the pre-operation data and / or post-operation data of the target data to the operation log. This achieves the operation log recording function.

[0134] It should be understood that, based on the idea of ​​"moving operation log code down from the service layer to the persistence layer," the operation log recording function is defined as a general program plugin. This cohedes the operation log recording function within the backend system, decoupling it from the business code in the service layer.

[0135] To improve the robustness of the program design, exception handling can be implemented in the internal logic of the plugin to ensure that the plugin does not affect the original business function, thereby guaranteeing that the target persistence layer interface will be called when editing the target data.

[0136] In related technologies, the business scenarios expressed by the service layer are inexhaustible, with different business scenarios corresponding to different business codes, and a lack of commonality between different business scenarios. When implementing the operation log function, it is necessary to analyze the business code in the service layer and write program code to implement the pre-recording and post-recording functions in the operation log. Therefore, it is highly intrusive to the business code in the presentation layer.

[0137] In this embodiment, a general program plugin is used to implement the operation log recording function, which is integrated into the backend system. This decouples the operation log recording function from the service layer's business code, thereby reducing the intrusiveness of the operation log function on the service layer's business code.

[0138] Figure 5 This diagram illustrates an application scenario of the operation log processing method provided in an embodiment of this application. See also... Figure 5 Based on the network architecture of persistence layer-plugin-database, the operation log processing method provided in this application embodiment may include the following steps: Step 501: The persistence layer calls the database; Step 502: When the persistence layer calls the database, a pre-logger analyzes and obtains which persistence layer query interface needs to be called to retrieve the data before the operation, and calls the persistence layer query interface to query the target data; Step 503: The database returns the query result of the target data to the user; Step 504: The query result of the target data is saved to the operation log; Step 505: The SQL statement of the target persistence layer interface is executed; Step 506: The post-logger analyzes and obtains which persistence layer query interface needs to be called to retrieve the data after the operation corresponding to the target data, and calls the persistence layer query interface corresponding to the target data; Step 507: The database returns the query result of the target data to the user; Step 508: The query result of the target data is saved to the database operation log.

[0139] In the example, the persistence layer interface provides the functions insertByX, deleteByX, updateByX, and selectByX, where X represents the user's identification information. The user's role can include any of the following: database administrator or database operator.

[0140] Based on the same technical concept as the foregoing embodiments, see Figure 6 The operation log processing apparatus provided in this application embodiment may include the following steps:

[0141] Step A601: Determine the target persistence layer interface.

[0142] Step A602: Determine whether the target persistence layer interface has operation log annotations.

[0143] In the example, when it is determined that the target persistence layer interface has an operation log annotation, the following steps A603 are performed.

[0144] In the example, when it is determined that the target persistence layer interface does not have an operation log annotation, the following steps A607 are performed.

[0145] Step A603: Determine whether the SQL statement of the target persistence layer interface is a delete / update statement.

[0146] In the example, when the SQL statement in the target persistence layer interface is a delete / update statement, the following steps A604 are performed.

[0147] In the example, if the SQL statement in the target persistence layer interface is not a delete / update statement, the following steps A607 are performed.

[0148] Step A604: Parse the operation log annotations corresponding to the target persistence layer interface.

[0149] Step A605: Call the persistence layer interface described by the operation log annotation selectSql to obtain the data before the operation corresponding to the target data.

[0150] Step A606: Save the pre-operation data corresponding to the target data in the operation log.

[0151] Step A607: Call the target persistence layer interface when editing the target data.

[0152] Step A608: Determine whether the target persistence layer interface has operation log annotations.

[0153] In the example, when it is determined that the target persistence layer interface has an operation log annotation, the following steps A609 are performed.

[0154] In the example, when it is determined that the target persistence layer interface does not have an operation log annotation, the following steps A613 are performed.

[0155] Step A609: Determine whether the SQL statement of the target persistence layer interface is an insert / update statement.

[0156] In the example, when the SQL statement in the target persistence layer interface is an insert / update statement, the following steps A610 are performed.

[0157] In the example, if the SQL statement in the target persistence layer interface is not an insert / update statement, the following steps A613 are performed.

[0158] Step A610: Parse the operation log annotations corresponding to the target persistence layer interface.

[0159] Step A611: Call the persistence layer interface described by the operation log annotation selectSql to obtain the post-operation data corresponding to the target data.

[0160] Step A612: Save the post-operation data corresponding to the target data in the operation log.

[0161] Step A613: End.

[0162] Figure 7 This diagram illustrates an application scenario of the operation log processing method provided in an embodiment of this application. See also... Figure 7 Based on the network architecture of persistence layer-plugin-database, the operation log processing method provided in this application embodiment may include the following steps:

[0163] Step 701: Receive user query requests for data samples.

[0164] For example, a user sends a query request for a data sample to the backend system from the presentation layer of the frontend system. The presentation layer receives the user's query request for the data sample.

[0165] Step 702: The backend system queries the database for data samples.

[0166] For example, the service layer of the backend system receives a user's query request for a data sample and queries the database for the data sample based on the data sample's identification information.

[0167] Step 703: The database returns a data sample to the backend system.

[0168] For example, the database returns query results about data samples to the service layer of the backend system.

[0169] Step 704: The backend system assembles the data sample and returns the assembled data sample to the frontend.

[0170] For example, the service layer of the backend system assembles data samples and returns the assembled data samples to the presentation layer of the frontend system.

[0171] It should be understood that a data sample may include data from at least one sample. When reading a data sample, a user can select target data from at least one sample as the object of data editing operations. The target data can be data from any sample, or part or all of the data sample.

[0172] In the example, the data editing operation types include any of the following: insert, delete, update, and modify.

[0173] Step 705: The backend system receives the user's request to edit the target data.

[0174] For example, the front-end system's presentation layer displays the target data. While reading the target data, users can edit it, generating edit requests. The back-end system then receives these edit requests.

[0175] Here, the edit operation request may include the identification information of the target data and the information of the target persistence layer interface called when editing the target data.

[0176] Step 706: The backend system modifies the target data in the database, and the operation log plugin records data snapshots before and after the editing operation on the target data.

[0177] For example, the persistence layer of the backend system modifies the target data in the database based on the target persistence layer interface called when editing the target data. The backend system's persistence layer then retrieves the pre-edit data and post-edit data based on the operation log annotations corresponding to the target persistence layer interface, and records the pre-edit and / or post-edit data in the operation log.

[0178] Step 707: The backend system returns the modification results of the target data to the frontend system.

[0179] For example, the persistence layer of the backend system retrieves the post-edit data after the target data has been edited, and returns the post-edit data of the target data to the presentation layer of the frontend system.

[0180] In related technologies, when implementing operation log functionality, the service layer relies on edit operation requests sent by the presentation layer for value passing. However, the parameters in the edit operation request are susceptible to packet capture and tampering during the value passing process. Furthermore, if the data in the database has already changed, the data recorded in the operation log before the operation is not a true snapshot of the data before the operation. Therefore, the reliability of the data snapshot recorded in the operation log cannot be guaranteed.

[0181] In this embodiment of the application, when implementing the operation log function, the pre-operation data and / or post-operation data of the target data are obtained according to the operation log annotations. Value passing is not dependent on the edit operation request sent by the presentation layer, which can reduce the security risk of data being captured and tampered with, thereby improving the reliability of the data snapshot recorded in the operation log.

[0182] The following section provides a comparative analysis of the operation log processing method and related technologies provided in this application, taking into account a request to modify customer information.

[0183] In related technologies, the presentation layer provides customer information query services, storing customer information in memory and including the previously queried customer information in user-initiated edit requests. The backend system provides customer information editing services, locating the business code that modifies the customer information table when editing customer information. This involves assembling the pre-operation data and adding the target data's pre-operation data to the operation log; and assembling the post-operation data and updating the target data's post-operation data in the operation log. Since the business code in the service layer has been modified, it is necessary to retest the functionality of the service layer.

[0184] In related technologies, when the presentation layer sends an edit operation request to the backend system, the edit operation request can be divided into parameterless requests and parameterized requests. When the edit operation request does not carry post-operation data, the post-operation data cannot be recorded in the operation log. For parameterized requests, the parameters in the edit operation request are vulnerable to packet capture and tampering. Therefore, relying on the edit operation request sent by the presentation layer for value passing cannot guarantee the reliability of the data snapshot recorded in the operation log.

[0185] In the example, an operation log annotation is added to the persistence layer interface for updating the customer information table. The operation log annotation takes the following form:

[0186] @LogMapping(selectSql="selectById",paramMapping="{id=id}")

[0187] int updateCustomer(CustomerEntity entity);

[0188] int selectById(String id);

[0189] Here, LogMapping indicates that an operation log needs to be recorded when this interface is called. updateCustomer() is the function of the persistence layer interface for updating the customer information table, and CustomerEntity entity represents the Java entity class (entity) corresponding to the customer information table.

[0190] In the example, when parsing the parameter mapping relationship of the operation log annotation, the identifier information of the target data in the customer information table can be obtained from the Java entity class, and the identifier information of the target data can be used as the primary key of selectById for parameter calling.

[0191] In the example, the operation log functionality is easier to implement in a scenario where "a single user request results in multiple data table changes." Developers can add operation log annotations to the persistence layer interface without needing to worry about whether the database operation in the service layer is a single operation type.

[0192] In this embodiment, the service code of the backend system does not need to consider the business logic of multiple previous and subsequent records corresponding to the target data when implementing the operation log function; the operation log code is highly cohesive within the operation log plugin. In the service code of the presentation layer, the business logic of implementing the operation log function does not need to be considered, and no modification to the presentation layer function is required to implement the operation log function. The data before and after the operation does not depend on the values ​​passed from the presentation layer; therefore, the reliability of the data snapshots recorded in the operation log can be improved.

[0193] Based on the same technical concept as the foregoing embodiments, see Figure 8 The operation log processing apparatus provided in this application embodiment may include:

[0194] The determination module 801 is used to determine the target persistence layer interface, which is the persistence layer interface called when editing target data;

[0195] The acquisition module 802 is used to acquire the operation log annotation corresponding to the target persistence layer interface; the operation log annotation is used to characterize the persistence layer query interface corresponding to the target data;

[0196] The processing module 803 is used to obtain the pre-operation data of the target data according to the operation log annotation before performing an editing operation on the target data; and / or, to obtain the post-operation data of the target data according to the operation log annotation after performing an editing operation on the target data.

[0197] Storage module 804 is used to save the pre-operation data and / or post-operation data of the target data to the operation log.

[0198] In one implementation, the processing module 803 is configured to obtain pre-operation data of the target data based on the operation log annotations before performing editing operations on the target data, including:

[0199] Obtain the semantic information of the target persistence layer interface;

[0200] When the semantic information of the target persistence layer interface pertains to deleting or modifying the target data, the pre-operation data of the target data is obtained based on the operation log annotation before the editing operation is performed on the target data.

[0201] In one implementation, the processing module 803 is configured to, after performing an editing operation on the target data, obtain post-operation data of the target data based on the operation log annotations, including:

[0202] Obtain the semantic information of the target persistence layer interface;

[0203] When the semantic information of the target persistence layer interface pertains to inserting or modifying the target data, after the target data is edited, the post-operation data of the target data is obtained according to the operation log annotation.

[0204] In one implementation, the processing module 803 is further configured to: generate an operation log annotation corresponding to the target persistence layer interface, wherein the operation log annotation includes the identification information of the target data and the mapping relationship between the persistence layer query interface corresponding to the target data.

[0205] In one implementation, the processing module 803 is configured to obtain pre-operation data and / or post-operation data of the target data based on the operation log annotations, including:

[0206] Parse the operation log annotations to obtain the identification information of the target data and the mapping relationship between the persistent layer query interface corresponding to the target data;

[0207] Based on the identification information of the target data and the mapping relationship, determine the persistent layer query interface corresponding to the target data;

[0208] Based on the persistent layer query interface corresponding to the target data, obtain the pre-operation data and / or post-operation data of the target data.

[0209] In one implementation, the acquisition module 802 is used to acquire the operation log annotation corresponding to the target persistence layer interface, including:

[0210] Determine the database statement to be executed when editing the target data; obtain the mapping statement corresponding to the database statement, the mapping statement being used to set the operation log annotation corresponding to the target persistence layer interface;

[0211] Parse the mapping statement corresponding to the database statement according to the syntax rules of the mapping statement, and obtain the operation log annotation corresponding to the target persistence layer interface;

[0212] When the operation log annotation corresponding to the target persistence layer interface is obtained, it is determined that the pre-operation data and / or post-operation data of the target data need to be saved to the operation log.

[0213] In one implementation, the processing module 803 is configured to obtain the pre-operation data and / or post-operation data of the target data based on the operation log annotations, and this step is implemented using a plugin.

[0214] In practical applications, the determining module 801, the acquiring module 802, the processing module 803, and the storage module 804 can all be implemented using a processor of an electronic device. The processor can be at least one of ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, microcontroller, and microprocessor. This application embodiment does not limit this.

[0215] In some embodiments, the functions or modules of the apparatus provided in this application can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0216] Based on the same technical concept as the foregoing embodiments, see Figure 9 The electronic device 900 provided in this application embodiment may include: a memory 910 and a processor 920; wherein,

[0217] Memory 910 is used to store computer programs and data;

[0218] The processor 920 is used to execute a computer program stored in the memory to implement any of the operation log processing methods in the foregoing embodiments.

[0219] In practical applications, the aforementioned memory 910 may be volatile memory, exemplarily RAM; or non-volatile memory, exemplarily ROM, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or a combination of the above types of memory. The aforementioned memory 910 may provide instructions and data to the processor 920.

[0220] The description of the various embodiments above tends to emphasize the differences between them. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.

[0221] The methods disclosed in the various method embodiments provided in this application can be arbitrarily combined to obtain new method embodiments without conflict.

[0222] The features disclosed in the various product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0223] The features disclosed in the various method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.

[0224] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative and exemplary. The division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components may be combined, or integrated into another system, or some features may be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0225] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple grid units. Depending on the actual situation, some or all of the units may be selected to achieve the purpose of this embodiment.

[0226] In addition, each functional unit in the various embodiments of this application can be integrated into one processing module, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0227] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments.

[0228] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for processing operation logs, characterized in that, include: Determine the target persistence layer interface, which is the persistence layer interface called when editing target data; Determine the database statement to be executed when editing the target data; obtain the mapping statement corresponding to the database statement, the mapping statement being used to set the operation log annotation corresponding to the target persistence layer interface; Parse the mapping statement corresponding to the database statement according to the syntax rules of the mapping statement, and obtain the operation log annotation corresponding to the target persistence layer interface; When the operation log annotation corresponding to the target persistence layer interface is obtained, it is determined that the pre-operation data and / or post-operation data of the target data need to be saved to the operation log; The operation log annotation is used to characterize the persistent layer query interface corresponding to the target data; Obtain the semantic information of the target persistence layer interface; When the semantic information of the target persistence layer interface pertains to deleting or modifying the target data, the pre-operation data of the target data is obtained according to the operation log annotation before the editing operation of the target data is performed. And / or, Obtain the semantic information of the target persistence layer interface; When the semantic information of the target persistence layer interface pertains to inserting or modifying the target data, after the target data is edited, the post-operation data of the target data is obtained according to the operation log annotation. Save the target data before the operation and / or the target data after the operation to the operation log; The step of obtaining the pre-operation data of the target data based on the operation log annotations, and / or obtaining the post-operation data of the target data based on the operation log annotations, includes: Parse the operation log annotations to obtain the identification information of the target data and the mapping relationship between the persistent layer query interface corresponding to the target data; Based on the identification information of the target data and the mapping relationship, determine the persistent layer query interface corresponding to the target data; Based on the persistent layer query interface corresponding to the target data, obtain the pre-operation data and / or post-operation data of the target data; The method further includes: Generate operation log annotations corresponding to the target persistence layer interface. The operation log annotations include the identification information of the target data and the mapping relationship between the persistence layer query interface corresponding to the target data.

2. The method according to claim 1, characterized in that, The step of obtaining the pre-operation data and / or post-operation data of the target data based on the operation log annotations is implemented using a plugin.

3. An operation log processing device, characterized in that, include: The determination module is used to determine the target persistence layer interface, which is the persistence layer interface called when editing target data; Determine the database statement to be executed when editing the target data; obtain the mapping statement corresponding to the database statement, the mapping statement being used to set the operation log annotation corresponding to the target persistence layer interface; Parse the mapping statement corresponding to the database statement according to the syntax rules of the mapping statement, and obtain the operation log annotation corresponding to the target persistence layer interface; When the operation log annotation corresponding to the target persistence layer interface is obtained, it is determined that the pre-operation data and / or post-operation data of the target data need to be saved to the operation log; The operation log annotation is used to characterize the persistent layer query interface corresponding to the target data; The processing module is configured to: acquire semantic information of the target persistence layer interface; when the semantic information of the target persistence layer interface pertains to deleting or modifying the target data, acquire the pre-operation data of the target data based on the operation log annotation before performing an editing operation on the target data; and / or acquire the semantic information of the target persistence layer interface; and in the target persistence layer interface... The semantic information pertains to inserting or modifying the target data. After editing the target data, the post-operation data of the target data is obtained based on the operation log annotation. The storage module is used to save the pre-operation data and / or post-operation data of the target data to the operation log; The processing module is used for: The step of obtaining the pre-operation data of the target data based on the operation log annotations, and / or obtaining the post-operation data of the target data based on the operation log annotations, includes: Parse the operation log annotations to obtain the identification information of the target data and the mapping relationship between the persistent layer query interface corresponding to the target data; Based on the identification information of the target data and the mapping relationship, determine the persistent layer query interface corresponding to the target data; Based on the persistent layer query interface corresponding to the target data, obtain the pre-operation data and / or post-operation data of the target data; The processing module is also used for: Generate operation log annotations corresponding to the target persistence layer interface. The operation log annotations include the identification information of the target data and the mapping relationship between the persistence layer query interface corresponding to the target data.

4. An electronic device, characterized in that, The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the operation log processing method according to any one of claims 1 to 2.

5. A computer storage medium storing a computer program; characterized in that, Once executed, the computer program can implement the operation log processing method as described in any one of claims 1 to 2.