CN115705319A - Operation log management method and device and electronic equipment - Google Patents

Operation log management method and device and electronic equipment Download PDF

Info

Publication number
CN115705319A
CN115705319A CN202110885716.4A CN202110885716A CN115705319A CN 115705319 A CN115705319 A CN 115705319A CN 202110885716 A CN202110885716 A CN 202110885716A CN 115705319 A CN115705319 A CN 115705319A
Authority
CN
China
Prior art keywords
log
data
input
asynchronous thread
sub
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110885716.4A
Other languages
Chinese (zh)
Inventor
朱志勇
刘梅华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
China Mobile Shanghai ICT Co Ltd
CM Intelligent Mobility Network Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Shanghai ICT Co Ltd
CM Intelligent Mobility Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Communications Group Co Ltd, China Mobile Shanghai ICT Co Ltd, CM Intelligent Mobility Network Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202110885716.4A priority Critical patent/CN115705319A/en
Publication of CN115705319A publication Critical patent/CN115705319A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention discloses an operation log management method and device and electronic equipment, and belongs to the technical field of computers. The method comprises the following steps: receiving a first input of a user to a first data table; responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread; generating a first operation log according to a comparison result between the first data before the target processing and the first data after the target processing by adopting the first log asynchronous thread; and storing the first operation log into a preset operation log table according to a preset format. The invention can simplify the recording process of the operation log.

Description

Operation log management method and device and electronic equipment
Technical Field
The invention belongs to the technical field of computers, and particularly relates to an operation log management method and device and electronic equipment.
Background
The operation log can be used for determining whether a certain operation is executed on a specified date and determining whether the operation is executed by the user, and can also assist the user in performing security analysis and compliance audit so as to timely and effectively find abnormal security events, audit violations and the like. In the Information Technology (IT) field, as the number of services expands rapidly with the development of microservices, the Application Programming Interface (API) also increases rapidly, and each time the Interface is added, deleted or modified, the oplog logic and the oplog page need to be added, deleted or modified accordingly. Therefore, the logging and querying process of the operation log in the related art is complicated.
Disclosure of Invention
The invention aims to provide an operation log management method, an operation log management device and electronic equipment, which can solve the problem that the operation log in the related art is complex in recording and inquiring processes.
In order to solve the technical problem, the invention is realized as follows:
in a first aspect, the present invention provides an operation log management method, including:
receiving a first input of a user to a first data table;
responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread;
generating a first operation log according to a comparison result between the first data before the target processing and the first data after the target processing by adopting the first log asynchronous thread;
and storing the first operation log into a preset operation log table according to a preset format.
In a second aspect, the present invention further provides an operation log management apparatus, including:
the first input module is used for receiving first input of a user to the first data table;
the processing module is used for responding to the first input, performing target processing on first data in the first data table and starting a first log asynchronous thread;
a generating module, configured to generate a first operation log according to a comparison result between the first data before the target processing and the first data after the target processing by using the first log asynchronous thread;
and the storage module is used for storing the first operation log into a preset operation log table according to a preset format.
In a third aspect, the present invention also provides an electronic device comprising a processor, a memory, and a program or instructions stored on the memory and executable on the processor, which when executed by the processor implements the steps of the method according to the first aspect.
In a fourth aspect, the invention also provides a computer readable storage medium on which a program or instructions are stored, which program or instructions, when executed by a processor, implement the steps of the method according to the first aspect.
In the embodiment of the invention, a first input of a user to a first data table is received; responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread; generating a first operation log according to a comparison result between the first data before the target processing and the first data after the target processing by adopting the first log asynchronous thread; and storing the first operation log into a preset operation log table according to a preset format. In this way, since the content recorded by the first operation log includes the difference of the first data before and after the target processing, and the storage format is the preset format, various operations on the first data can be recorded without modifying the logic of the operation log, and the recording process of the operation log can be simplified.
Drawings
FIG. 1 is a flow chart of a method for managing oplogs provided by the present invention;
FIG. 2 is a schematic diagram of a saving timing sequence of an operation log in an operation log management method according to the present invention;
FIG. 3 is a schematic diagram of the correspondence between data tables;
FIG. 4 is a schematic diagram of an oplog page;
FIG. 5 is a schematic diagram of query timing sequences of an operation log in an operation log management method according to the present invention;
FIG. 6 is a block diagram of an operation log management apparatus according to the present invention;
fig. 7 is a structural diagram of an electronic device provided by the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms first, second and the like in the description and in the claims of the present invention are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that embodiments of the invention may be practiced other than those illustrated or described herein, and that the objects identified as "first," "second," etc. are generally a class of objects and do not limit the number of objects, e.g., a first object may be one or more.
Referring to fig. 1, which is a flowchart of an operation log management method according to an embodiment of the present invention, as shown in fig. 1, the method may include the following steps:
step 101, receiving a first input of a user to a first data table.
In a specific implementation, the first input may be an input operation performed by a user through an input device such as a mouse, a keyboard, a touch screen, or the like, and the first input to the first data table may be an operation on data in the first data table, for example: new addition operation, modification operation, deletion operation, etc., and are not specifically limited herein.
And 102, responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread.
In a specific implementation, the first data may include a plurality of data contents, for example: one piece of account information may include: user identification (userId), account (or account number), name (name), and enterprise ID (eid).
Corresponding to the first input, the target processing may include: one or more of data processing procedures such as addition processing, modification processing, deletion processing, etc., are not specifically limited herein.
The above target processing of the first data in the first data table and starting the first log asynchronous thread may be understood as: the thread may be parallel to the thread that performs the target processing on the first data in the first data table, so that the subsequent steps 103 and 104 may be performed based on the first log asynchronous thread while the target processing on the first data in the first data table by the system is not affected.
Step 103, generating a first operation log according to a comparison result between the first data before the target processing and the first data after the target processing by using the first log asynchronous thread.
In this step, the first log asynchronous process may determine which data content of the first data has changed by comparing the first data before the target processing with the first data after the target processing, and may record the changed data content in a first operation log, for example: the change scenes of data contents such as account information, account passwords, mailboxes, new accounts and account information are modified.
In addition, the first operation log may record other information besides the data content change, for example: the operation information such as the user information of the operator performing the first input, the time for performing the first input, and the IP information for performing the first input is not described herein again.
In a first optional implementation manner, when the first input is used to add first data, the first data does not exist before the adding process, and therefore, a comparison result between the first data before the adding process and the first data after the adding process is the added first data, that is, the generating of the first operation log according to the comparison result between the first data before the target process and the first data after the target process may be understood as: and generating the first operation log according to at least one item of the first input operation information, the primary key information of the first data and the first data.
For example: for the new operation, after the new service is processed, the user ID, IP information and the like can be transmitted into the first log asynchronous thread to record a new operation log; in the subsequent log query stage, query can be performed according to the user ID, the user table configuration information, and the like recorded in the operation log table, so as to obtain the newly added first data.
For another example: recording the table attribute and the primary key information into a first operation log, and storing the table attribute and the primary key information into a preset operation log table; in the subsequent log query stage, screening may be performed according to the attribute information, the primary key information, and the like, so as to obtain the newly added first data.
In a second alternative embodiment, when the first input is used to modify the first data, it is necessary to obtain the first data before modification before modifying the first data in the database, and transfer the user ID, the IP information, and the like to the first log asynchronous thread, so as to compare the first data before modification processing with the first data after modification processing through the first log asynchronous thread to obtain the modified content of the first data by the first input, and then record the modified content in the first operation log. In other words, for the modification operation, the first data before modification needs to be queried first, then the first data in the database needs to be updated, and finally the first log asynchronous thread is started to generate and maintain the first operation log.
The manner for acquiring the first data before modification before modifying the first data in the database may include: and acquiring a primary key ID corresponding to the first input in the first data table, and acquiring the first data according to the primary key ID. For example: the method comprises the steps of intercepting a Structured Query Language (SQL) instruction generated based on a first input to obtain a primary key ID and other operation information according to information in the SQL instruction, and obtaining first data from a first data table according to the primary key ID.
For example: assuming that the first input is a modification operation and the first data is account information in an account table, intercepting the database layer to acquire account information before modification before modifying the account information in the account table, and generating and recording a first operation log based on a difference between the account information before modification and the account information after modification, where the first operation log may be implemented by the following program codes: and modifying account information in the account table:
update
tbl_account
SET
account=#{status,jdbcType=VARCHAR},
name=#{name,jdbcType=VARCHAR},
eid={eid,jdbcType=VARCHAR}
where userId=#{userId}
of course, before executing the above program code, it is necessary to perform the following operations according to the query conditions and the attribute values before modification described in the above code, for example: "where userId =203539328" to query the database accordingly for the complete data of the record before change, for example: { "userId": 203539328"," account ": dearMno", "name": mno electric coffee "," eid ": "403041280"}.
And then, executing the program codes for modifying the account information in the account table to update the first data in the database, starting a first log asynchronous thread, obtaining the specific attribute of the change according to the obtained first data before the change and the first data after the change determined by the program codes, and generating an operation log according to the specific attribute.
For example: the first data before change is: { "userId": "203539328", "account": "dearMno", "name": "mno electric coffee", "eid": "403041280" } and the first data after change are: { "userId": "203539328", account ":" dearcdev "," name ":" dev electric coffee "," eid ": comparing the results with 406305153, and obtaining the operation log of the modification operation:
[
{"tableName":"tbl_account","recordId":"203539328","batchId":"001","fieldN ame":"account","oldValue":"dearMno","newValue":"dearccDev"},
{ "tableName": tbl _ account "," recordld ": 203539328", "batchId": 001"," fieldN name ": name", "oldValue": mno electric coffee "," newValue ": dev electric coffee" },
{"tableName":"tbl_account","recordId":"203539328","batchId":"001","fieldN ame":"eid","oldValue":"403041280","newValue":"406305153"}
]
and finally, storing the operation log in a preset operation log table according to a preset format.
For example: assuming that the first input is used to modify a role relationship between an account and a deleted account, the operation log data stored in the preset operation log table may be as shown in table 1 below:
TABLE 1
Figure BDA0003194074520000071
As shown in table 1 above, 3 oplogs for modifying one account correspond to the oplog data in rows 1 to 3 in the preset oplog table, and the batch numbers of the oplog data in rows 3 are the same, that is, all are 1; the 2 operation logs for deleting the account role relationship respectively correspond to operation log data of rows 4 to 5 in a preset operation log table, and the batch number of the 2 operation log data is the same and is different from the batch number of the 3 operation logs for modifying one account.
In a third alternative embodiment, for the delete operation, similar to the process of the modify operation, the first data before deletion may be queried first, then the first data in the database is deleted, and finally the first log asynchronous thread is started to generate and maintain the first operation log.
For convenience of explanation, in the following embodiments, the first input including the modification operation is exemplified, and is not specifically limited herein.
And step 104, storing the first operation log into a preset operation log table according to a preset format.
In this step, the first operation log is stored in a preset operation log table according to a preset format, which can be understood as follows: the target position in the preset operation log table corresponds to the content of the fixed attribute, for example: different operation logs are stored in different rows of the preset operation log table, and it is assumed that the first operation log includes 5 log contents, which are: operator information, the type of the target processing, the type of the first data, the value of the first data before the target processing, and the value of the first data after the target processing; the 5 log contents can be stored in columns 1 to 5 in the preset operation log table according to the arrangement order of the 5 log contents. In other words, each column in the preset operation log table may correspond to an attribute one to one, and the attribute may also include: data content, operator information, type of operation, etc.
For example: the structure of the preset operation log table is as shown in table 2 below:
TABLE 2
Figure BDA0003194074520000081
Figure BDA0003194074520000091
As shown in table 2 above, the preset operation log table is recorded based on the table attribute, so that even if an operation log of a newly added table needs to be recorded, the table structure does not need to be changed, and in an operation log in the related art, a corresponding table structure needs to be added or modified every time a new type of operation log is added, so that the embodiment of the present application can record operation logs of different types by using a general table structure, and the recording process of the operation log is simplified.
Based on this, for different types of first inputs and for different data, the generated operation logs can be stored in the preset operation log table according to the same preset format, so that the situation that when the API interface is changed due to the target processing of the first data, the logic of the operation logs needs to be modified according to the change of the API interface to record the operation logs is avoided.
In addition, the specific attribute changed by the target processing may be specified based on a comparison between the first data before the target processing and the first data after the target processing, and an attribute value corresponding to the attribute may be recorded in the first operation log. In other words, in the embodiment of the present invention, by dynamically acquiring the first data before modification, dynamically acquiring the modified first data, and dynamically recording the operation log, it is not necessary to change the interface and data of the database.
For example: taking the program code for generating 3 operation logs as an example, for account information of "userld": the "203539328", the 3 attributes of "account", "name", and "eid" are modified through the first input, then the 3 first operation logs can be respectively generated so as to respectively modify the attribute values corresponding to the 3 attributes, and the values of the batch numbers (batch ids) of the 3 first operation logs are the same; finally, the 3 first oplogs are recorded in a common oplog change table.
In the embodiment of the invention, a first input of a user to a first data table is received; responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread; generating a first operation log according to a comparison result between the first data before the target processing and the first data after the target processing by adopting the first log asynchronous thread; and storing the first operation log into a preset operation log table according to a preset format. In this way, because the content recorded by the first operation log includes the difference of the first data before and after the target processing, and the storage format is the preset format, various operations on the first data can be recorded without modifying the logic of the operation log, and the recording process of the operation log can be simplified.
As an optional implementation, before the target processing the first data in the first data table and starting the first log asynchronous thread, the method further includes:
acquiring first input first operation information;
calling service logic associated with the first data, and verifying the first operation information based on the service logic;
and under the condition that the verification is passed, executing the steps of carrying out target processing on the first data in the first data table and starting a first log asynchronous thread.
In a specific implementation, the first operation information may include at least one of: user information of a user performing the first input, device information of a device performing the first input, and an association relationship between the user information and/or the device information and the first data for which the first input is directed, and the like.
For example: as shown in fig. 2, a system to which the oplog management method is applied includes: user layer, control layer, service layer and data layer.
A user layer for users to perform functional operations, such as: and operations such as modifying the basic information of the account, modifying the password, changing the mailbox and the like.
The control layer is used for acquiring operation information such as operation user information and Internet Protocol (IP) information, calling the service logic to verify the operation information through the service logic, and transmitting the operation information to the service layer when the verification is passed. For example: and under the application scene of changing the mobile phone number, verifying the old mobile phone number and the corresponding mobile phone verification code verification information by using the called service logic, verifying the new mobile phone number and the corresponding mobile phone verification code verification information, and executing subsequent steps only if the new mobile phone number and the corresponding mobile phone verification code verification information are verified, so as to operate the data in the database.
And (3) a service layer: processing the service logic, calling a database layer to perform operations such as adding, modifying and deleting data, and transmitting the operation information of the operations to the data layer;
and (3) a data layer: and for the operations of adding, modifying and deleting the data table, recording an operation log by starting an asynchronous thread.
Specifically, the adding, modifying, and deleting operations on the data table have the same meaning as that of step 103 by starting the process of recording the operation log by the asynchronous thread, and are not described herein again.
In this embodiment, before executing steps 102 and 103, the first input first operation information is further verified, so that when the first input first operation information conforms to the service logic corresponding to the first data, the steps 102 and 103 are executed, which can prevent the data in the database from being modified by an unauthorized user or an unauthorized device, thereby improving the security of the data in the database.
As an optional implementation, the target processing includes an update processing or a delete processing, and the target processing the first data in the first data table and starting a first log asynchronous process in response to the first input includes:
acquiring a corresponding primary key ID from the first data table according to the first input, and acquiring the first data before updating from the first data table;
updating the first data and starting a first sub-log asynchronous thread, wherein the first sub-log asynchronous thread comprises the first sub-log asynchronous thread;
inputting the first data before updating, the first data after updating and the first operation information into the first sub-log asynchronous thread;
generating, by using the first log asynchronous thread, a first operation log according to a comparison result between the first data before the target processing and the first data after the target processing, including:
comparing the first data before updating with the first data after updating by adopting the first sub-log asynchronous thread so as to determine change information according to a comparison result;
generating a first sub operation log based on the change information and the first operation information, wherein the first operation log comprises the first sub operation log.
In a specific implementation, the obtaining of the corresponding primary key ID from the first data table according to the first input and obtaining the first data before updating from the first data table may be understood as: for modification or deletion operation, before processing service, according to the corresponding primary key ID of the first input in the operated first data table, acquiring information before record modification, and then processing service.
In addition, the first data before updating and the first data after updating are compared by adopting the first sub-log asynchronous thread, so that change information is determined according to a comparison result; the process of generating the first sub-operation log based on the change information and the first operation information may be understood as follows: the first sub-oplog records only the changed attribute values, for example: assume that the first input is for first data before processing the target: { "userId": "203539328", "userName": "Zhang three", "phone": "13911111111" }, modified as follows: { "userId": 203539328"," userName ": zhang three", "phone": 13822222222"}, the change information recorded in the first operation log is the account record with the account number 203539328, and the mobile phone number is updated from 1391111111 to 13822222222222.
In this embodiment, the first sub-log asynchronous thread is adopted to compare the first data before updating with the first data after updating, so as to determine change information according to a comparison result; and generating a first sub-operation log based on the change information and the first operation information. The first sub operation log only needs to record the change information, and the first sub operation log can be simplified without completely recording the first data before the change and the first data after the change in the first operation log.
As an optional implementation, the target processing includes adding processing, and the target processing is performed on first data in the first data table and starts a first log asynchronous process in response to the first input, including:
in response to the first input, determining second operation information, newly adding first data in the first data table based on the second operation information, and starting a second sub-log asynchronous thread, wherein the first sub-log asynchronous thread comprises the second sub-log asynchronous thread;
generating second sub-operation logs corresponding to the first data and the second operation information respectively by adopting the second sub-log asynchronous thread, wherein the first operation log comprises the second sub-operation logs;
and storing the second sub-operation log into the preset operation log table according to the preset format.
In a specific implementation, the generating, by using the second sub-log asynchronous thread, second sub-operation logs corresponding to the first data and the second operation information respectively may be understood as: and recording one or more items of information such as the second operation information, the first data, the primary key ID of the first data and the like in the second sub-log asynchronous thread. For example: for the new operation, after the service is processed, the user ID for executing the first input, the equipment IP information for executing the first input and the like are transmitted into a second sub-log asynchronous thread, so that the second sub-log asynchronous thread inquires and obtains new first data according to the user ID, the configuration of a user table and the like, and the information such as the main key ID, the table attribute, the user ID, the equipment IP and the like based on the first data is recorded in a second sub-operation log.
In this embodiment, when a user adds a new first data, the operation information of the user and the information of the first data may be obtained by using an asynchronous thread to be recorded in the second sub-operation log, so that when the second sub-operation log is stored in the preset operation log table according to the preset format, the user may conveniently view the new data, the new operation information, and the like subsequently.
It should be noted that when a large amount of operation logs are stored in the preset operation log table, the operation logs may be uniformly output from the preset operation log table, or a screening policy may be set to screen out the operation logs required by the user and display the operation logs on the log page.
As an optional implementation, the method further comprises:
receiving a second input of the user;
determining log query information in response to the second input;
screening out a log query result from the preset operation log table according to the log query information;
and outputting the log query result.
In a specific implementation, the declaration of the log query information may be a specific attribute value, such as: as shown in fig. 4, the above second input can be entered in the service type selection window: and if one or more log query information in the information of the start time, the end time, the operation type, the name, the operator and the like is/are obtained, the log query result can be screened out from the preset operation log table.
In an alternative embodiment, the log query result may be understood as: the operation log according with the log query information can be understood as the operation log according with the log query information, which is output according with the preset format of the operation log.
In another alternative embodiment, the log query result may be understood as: the main information of the operation log conforming to the log query information, for example: and merging the operation logs of the same batch into a log query result, wherein the log query result can comprise the primary key ID, the account number, the operation type, the service type, the operation time and the like merged by the operation logs of the same batch. In this case, outputting the log query result may be understood as outputting a combined log query result. For example: taking the example that the operation logs meeting the target log query information include 5 operation logs as shown in table 1 above, the output log query result is shown in the table page on the left side in fig. 4, and in addition, a detail view button corresponding to the screened operation logs in a one-to-one manner may also be displayed in the page, for example: the "View" button is shown in FIG. 4, so that when the user clicks on the button, other attribute information of the oplog can be expanded, such as: a field name where the change occurs, an attribute value before the change, an attribute value after the change, and the like.
In the example shown in fig. 4, it is assumed that the operation logs that meet the target log query information include 5 operation logs shown in table 1 above, and the number of the log query results may be 2, which correspond to 3 operation log data with a batch number of "1" and 2 operation log data with a batch number of "2" in table 1 above respectively; when the user clicks the query button of the first log query result, the changed 3 field names in the 3 pieces of operation log data with the batch number "1" in table 1 above and the attribute values before and after the change of the 3 field names are displayed; correspondingly, when the user clicks the query button of the second log query result, 2 field names that have been changed in the 2 pieces of operation log data with batch number "2" in table 1 above, and the attribute values before and after the change of the 2 field names, respectively, are displayed.
It should be noted that, in practical applications, there may be an association relationship between data tables in the database, such as: one-to-one correspondence between one data table and another data table, or, as shown in fig. 3, one-to-many correspondence between one data table and a plurality of data tables.
For example: when the account in the account data table is modified through the operation log shown in the above table 1, and the enterprise identifier (eid) is also modified, in the log query process shown in fig. 4, when the user clicks the detail view button of the first log query result, the enterprise information in the enterprise data table is queried according to the eid, and the enterprise information such as the enterprise name is displayed in the detail page.
For another example: when the account role relationship is deleted through the operation log shown in the above table 1, the user _ id and the role _ id are simultaneously changed, and in the log query process shown in fig. 4, when the user clicks the detail view button of the second log query result, the user data and the role data table are respectively queried according to the user _ id and the role _ id before deletion, so as to display information such as the user name and the role name in the detail page according to the queried information.
In summary, in the embodiment, a log query result screened according to the log query information may include operation logs corresponding to one or more data tables, and when a fourth input of the user is received to view the detailed content of the log query result, the changed data information may be queried from the one or more data tables corresponding to the log query result, so as to be displayed in the detailed page respectively.
For example: as shown in fig. 5, the process of querying the log may include the following steps:
1. a query condition is selected.
In this step, the front-end page layer determines the log query information according to the query condition selected by the user on the front-end page.
2. Log query information is passed.
In this step, the front-end page layer transmits the log query information to the log query service layer.
3. And filtering the operation log.
In this step, the log query service layer screens the operation logs in the preset operation log table according to the log query information, and merges the screened operation logs according to the batch number to obtain a log query result.
4. And transmitting log query results.
In this step, the log query service layer transmits the log query result to the front-end page layer.
5. And outputting a log query result.
In this step, the front-end page layer presents the log query result to the user.
6. Details are obtained.
In this step, the front-end page layer performs detail checking operation on the log query result according to the operation performed by the user on the front-end page.
7. And transmitting the detail viewing information.
In this step, the front-end page layer transmits the detail checking information corresponding to the log query result to the log query service layer.
8. And obtaining the detailed result of the log query result.
In this step, the log query service layer obtains the detailed result of the log query result by querying the data table. For example: and when the operation log is detected to store the primary key ID, searching the name recorded in the corresponding data table according to the configuration so that the detail result comprises the name.
9. The detailed results are communicated.
In this step, the log query service layer transmits the detailed result to the front-end page layer.
10. And outputting a detailed result.
In this step, the front-end page layer presents the detailed results to the user.
In this embodiment, the log query result may be obtained by querying from the preset operation log table according to the log query information input by the user, so as to be used for querying the required operation log information.
It should be noted that, when the first input is used to add a data table of a new service and first data in the data table, and a user needs to query an operation log corresponding to the added data table, query configuration information of the added data table may be configured in a log query page in a manner of configuring a log query page in advance.
As an optional implementation manner, in a case that the first input is used for adding new first data and a first data table in which the first data is located, before the receiving the second input of the user, the method further includes:
receiving a fifth input of the user;
responding to the fifth input, and determining a target service type, wherein the target service type comprises a service type corresponding to the first data table;
and adding the configuration of the target service type in a log query interface.
In a specific implementation, after the configuration of the target service type is added in the log query interface, the user may input target log query information in the log query interface to query the data in the first data table according to the target log query information. For example: as shown in fig. 4, a "service type (select)" button in the log query interface may be clicked to trigger the display of a drop-down list, and a target service type is selected from the drop-down list, so that the query of the operation log of the target service type may be implemented.
In the embodiment, a general operation log table structure design scheme is adopted, so that the table structure of a preset operation log table is not required to be changed under the condition of changing the service; in addition, by adopting a universal and flexible database structure configuration, a universal operation log list display, a dynamic display mode of the details of the universal operation log and a query scheme of an association table, under the condition of changing the service, the query and the display of the operation log of the newly added service type can be realized by simple configuration without changing the log query page code.
As an optional implementation, before the responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread, the method further includes:
receiving a third input of the user;
determining log configuration information associated with the first data table in response to the third input;
intercepting an operation instruction of the first data table according to the log configuration information;
the responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread comprises:
and responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread according to the intercepted operation instruction.
In a specific implementation, the third input may be any operation for setting the log configuration information related to the first data table, and is not limited in particular herein.
In addition, the log configuration information related to the first data table may be understood as: intercepting the operation instruction of the first data table is configured, so that data before change in the first data table is inquired according to the intercepted operation information, and the data is compared with the changed data to obtain a first operation log.
Of course, when the user wants to check the operation logs of other data tables, the log configuration information related to other data tables may also be configured in advance, which is not described herein again.
In specific implementation, operation instructions of a part of data tables in a database are intercepted, so that data before change is inquired according to the intercepted operation information, and the data is compared with the changed data to obtain an operation log.
Moreover, through the log configuration information, one part of data tables in the database can be configured to intercept the operation instruction of the data tables, and the other part of data tables are not configured with the interception operation, so that only the operation log corresponding to the data table needing to be intercepted can be stored in the preset operation log table; in addition, in the subsequent process of outputting or inquiring the operation logs, the operation logs which are not needed to be inquired by the user can be prevented from being mixed, so that the pertinence of the operation logs which are output or inquired can be improved.
In this embodiment, a scheme that an interceptor intercepts an operation instruction of a database layer and dynamically generates an operation log may be adopted, so that the recorded operation log is not affected by a service, and even under the condition that an interface or other data table is newly added, code logic of the operation log does not need to be modified.
Referring to fig. 6, which is a structural diagram of an operation log management apparatus according to an embodiment of the present invention, as shown in fig. 6, the operation log management apparatus 600 includes:
a first input module 601, configured to receive a first input to the first data table from a user;
a processing module 602, configured to perform target processing on first data in the first data table in response to the first input, and start a first log asynchronous thread;
a generating module 603, configured to generate, by using the first log asynchronous thread, a first operation log according to a comparison result between the first data before the target processing and the first data after the target processing;
the storage module 604 is configured to store the first operation log into a preset operation log table according to a preset format.
Optionally, the operation log management apparatus 600 further includes:
the acquisition module is used for acquiring the first input first operation information;
the verification module is used for calling service logic associated with the first data and verifying the first operation information based on the service logic;
the processing module 602 is specifically configured to, in a case that the verification passes, execute the step of performing the target processing on the first data in the first data table, and starting a first log asynchronous thread.
Optionally, the target process includes an update process or a deletion process, and the processing module 602 includes:
the acquisition unit is used for acquiring a corresponding primary key ID from the first data table according to the first input and acquiring the first data before updating from the first data table;
the updating unit is used for updating the first data and starting a first sub-log asynchronous thread, wherein the first sub-log asynchronous thread comprises the first sub-log asynchronous thread;
an input unit, configured to input the first data before updating, the first data after updating, and the first operation information to the first sub-log asynchronous thread;
the generation module comprises:
the comparison unit is used for comparing the first data before updating with the first data after updating by adopting the first sub-log asynchronous thread so as to determine change information according to a comparison result;
a first generating unit, configured to generate a first sub operation log based on the change information and the first operation information, where the first operation log includes the first sub operation log.
Optionally, the target process includes a new addition process, and the processing module 602 includes:
a determining unit, configured to determine second operation information in response to the first input, add first data in the first data table based on the second operation information, and start a second sub-log asynchronous thread, where the first sub-log asynchronous thread includes the second sub-log asynchronous thread;
a second generating unit, configured to generate, by using the second sub-log asynchronous thread, second sub-operation logs corresponding to the first data and the second operation information, respectively, where the first operation log includes the second sub-operation log;
and the storage unit is used for storing the second sub-operation log into the preset operation log table according to the preset format.
Optionally, the operation log management apparatus 600 further includes:
the second input module is used for receiving a second input of the user;
a determination module to determine log query information in response to the second input;
the screening module is used for screening out a log query result from the preset operation log table according to the log query information;
and the output module is used for outputting the log query result.
Optionally, the operation log management apparatus 600 further includes:
the third input module is used for receiving a third input of the user;
determining log configuration information associated with the first data table in response to the third input;
the intercepting module is used for intercepting an operation instruction of the first data table according to the log configuration information;
the processing module 602 is specifically configured to:
and responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread according to the intercepted operation instruction.
The operation log management apparatus 600 provided in the embodiment of the present invention can implement each process implemented in the method embodiment shown in fig. 1, and can obtain the same beneficial effects, and for avoiding repetition, details are not repeated here.
Optionally, as shown in fig. 7, an electronic device 700 according to an embodiment of the present invention is further provided, and includes a processor 701, a memory 702, and a program or an instruction stored in the memory 702 and executable on the processor 701, where the program or the instruction is executed by the processor 701 to implement each process of the method embodiment shown in fig. 1, and can achieve the same technical effect, and details are not repeated here to avoid repetition.
It should be noted that the electronic device in the embodiment of the present invention includes the mobile electronic device and the non-mobile electronic device described above.
An embodiment of the present invention further provides a computer-readable storage medium, where a program or an instruction is stored on the computer-readable storage medium, and when the program or the instruction is executed by a processor, the program or the instruction implements each process of the method embodiment shown in fig. 1, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.
The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and so on.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a component of' 8230; \8230;" does not exclude the presence of another like element in a process, method, article, or apparatus that comprises the element. Further, it should be noted that the scope of the methods and apparatus of embodiments of the present invention is not limited to performing functions in the order illustrated or discussed, but may include performing functions in a substantially simultaneous manner or in a reverse order based on the functions involved, e.g., the methods described may be performed in an order different than that described, and various steps may be added, omitted, or combined. In addition, features described with reference to certain examples may be combined in other examples.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
While the present invention has been described with reference to the particular illustrative embodiments, it is to be understood that the invention is not limited to the disclosed embodiments, but is intended to cover various modifications, equivalent arrangements, and equivalents thereof, which may be made by those skilled in the art without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (10)

1. An operation log management method, comprising:
receiving a first input of a user to a first data table;
responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread;
generating a first operation log according to a comparison result between the first data before the target processing and the first data after the target processing by adopting the first log asynchronous thread;
and storing the first operation log into a preset operation log table according to a preset format.
2. The method of claim 1, wherein prior to said target processing first data in said first data table and initiating a first log asynchronous thread, the method further comprises:
acquiring first input first operation information;
calling service logic associated with the first data, and verifying the first operation information based on the service logic;
and under the condition that the verification is passed, executing the steps of carrying out target processing on the first data in the first data table and starting a first log asynchronous thread.
3. The method of claim 1, wherein the target processing comprises an update processing or a delete processing, and wherein the target processing first data in the first data table and initiating a first log asynchronous thread in response to the first input comprises:
acquiring a corresponding primary key ID from the first data table according to the first input, and acquiring the first data before updating from the first data table;
updating the first data and starting a first sub-log asynchronous thread, wherein the first sub-log asynchronous thread comprises the first sub-log asynchronous thread;
inputting the first data before updating, the first data after updating and the first operation information into the first sub-log asynchronous thread;
generating, by using the first log asynchronous thread, a first operation log according to a comparison result between the first data before the target processing and the first data after the target processing, including:
comparing the first data before updating with the first data after updating by adopting the first sub-log asynchronous thread so as to determine change information according to a comparison result;
generating a first sub operation log based on the change information and the first operation information, wherein the first operation log comprises the first sub operation log.
4. The method of claim 1, wherein the target processing comprises an add-new processing, wherein the target processing first data in the first data table and initiating a first log-asynchronous thread in response to the first input comprises:
in response to the first input, determining second operation information, newly adding first data in the first data table based on the second operation information, and starting a second sub-log asynchronous thread, wherein the first sub-log asynchronous thread comprises the second sub-log asynchronous thread;
generating second sub-operation logs corresponding to the first data and the second operation information respectively by adopting the second sub-log asynchronous thread, wherein the first operation log comprises the second sub-operation logs;
and storing the second sub-operation log into the preset operation log table according to the preset format.
5. The method of claim 1, further comprising:
receiving a second input of the user;
determining log query information in response to the second input;
screening out a log query result from the preset operation log table according to the log query information;
and outputting the log query result.
6. The method of claim 1, wherein prior to said target processing first data within said first data table in response to said first input and initiating a first log asynchronous thread, the method further comprises:
receiving a third input of the user;
determining log configuration information associated with the first data table in response to the third input;
intercepting an operation instruction of the first data table according to the log configuration information;
the responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread comprises:
and responding to the first input, performing target processing on first data in the first data table, and starting a first log asynchronous thread according to the intercepted operation instruction.
7. An operation log management apparatus, comprising:
the first input module is used for receiving first input of a user to the first data table;
the processing module is used for responding to the first input, performing target processing on first data in the first data table and starting a first log asynchronous thread;
a generating module, configured to generate a first operation log according to a comparison result between the first data before the target processing and the first data after the target processing by using the first log asynchronous thread;
and the storage module is used for storing the first operation log into a preset operation log table according to a preset format.
8. The apparatus of claim 7, wherein the target process comprises an update process or a delete process, and wherein the processing module comprises:
an obtaining unit, configured to obtain a corresponding primary key ID from the first data table according to the first input, and obtain the first data before updating from the first data table;
the updating unit is used for updating the first data and starting a first sub-log asynchronous thread, wherein the first sub-log asynchronous thread comprises the first sub-log asynchronous thread;
an input unit, configured to input the first data before updating, the first data after updating, and the first operation information to the first sub-log asynchronous thread;
the generation module comprises:
the comparison unit is used for comparing the first data before updating with the first data after updating by adopting the first sub-log asynchronous thread so as to determine change information according to a comparison result;
a first generating unit, configured to generate a first sub-operation log based on the change information and the first operation information, where the first operation log includes the first sub-operation log.
9. An electronic device comprising a processor, a memory, and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps in the oplog management method of any of claims 1-6.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the oplog management method according to any one of claims 1 to 6.
CN202110885716.4A 2021-08-03 2021-08-03 Operation log management method and device and electronic equipment Pending CN115705319A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110885716.4A CN115705319A (en) 2021-08-03 2021-08-03 Operation log management method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110885716.4A CN115705319A (en) 2021-08-03 2021-08-03 Operation log management method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN115705319A true CN115705319A (en) 2023-02-17

Family

ID=85178695

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110885716.4A Pending CN115705319A (en) 2021-08-03 2021-08-03 Operation log management method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN115705319A (en)

Similar Documents

Publication Publication Date Title
EP3792798B1 (en) Method, apparatus, and system for managing user accounts in the event of conflicting login names
US7509672B1 (en) Cross-platform single sign-on data sharing
CN111695156A (en) Service platform access method, device, equipment and storage medium
US10999721B2 (en) Communication identifier binding processing method and terminal
CN109829286B (en) User authority management system and method for WEB application
US20030022657A1 (en) Application provisioning over a wireless network
US7711785B2 (en) System for using email message to transmit a command to remotely control a computer resource
US10560416B2 (en) Hero cards that display contextual information and actions for backend systems
CN111291043A (en) Identification value query method, identification resolution server and storage medium
CN109783543B (en) Data query method, device, equipment and storage medium
CN111541546B (en) Multi-platform login method, device, equipment and readable medium
US8522323B1 (en) System and method for obtaining identities
CN114185632B (en) Page configuration method, page configuration device, computer equipment, medium and program product
CN113221156A (en) Front-end authority control method and device, electronic equipment and storage medium
CN111047434B (en) Operation record generation method and device, computer equipment and storage medium
CN114124490A (en) Method and device for releasing new media content, storage medium and electronic equipment
CN108073630B (en) Service search access management method and system based on dynamic configuration
CN111078424A (en) Information interaction method and device, computer equipment and storage medium
CN113127906A (en) Unified authority management platform, method and storage medium based on C/S architecture
CN115222375B (en) Government affair data monitoring, analyzing and processing method and system based on big data
CN115705319A (en) Operation log management method and device and electronic equipment
CN109104499B (en) Session establishing method, device, equipment and storage medium
CN114153438A (en) API automatic generation system
JP4186452B2 (en) Document management device
CN113032471A (en) Database processing method and device, electronic equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination