From 7d0cd8bd392793961179cd07e63d1ab4c2491ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B2=85?= <907037276@qq.com> Date: Tue, 10 Oct 2023 22:41:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E5=8D=95=E7=82=B9=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=B0=83=E6=95=B4=202=E3=80=81=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/SpringContextEventListener.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/com/sztzjy/forex/trading_trading/config/SpringContextEventListener.java diff --git a/src/main/java/com/sztzjy/forex/trading_trading/config/SpringContextEventListener.java b/src/main/java/com/sztzjy/forex/trading_trading/config/SpringContextEventListener.java new file mode 100644 index 0000000..770f14d --- /dev/null +++ b/src/main/java/com/sztzjy/forex/trading_trading/config/SpringContextEventListener.java @@ -0,0 +1,32 @@ +package com.sztzjy.forex.trading_trading.config; + +import com.sztzjy.forex.trading_trading.entity.Log; +import com.sztzjy.forex.trading_trading.service.LogService; +import lombok.RequiredArgsConstructor; +import org.springframework.context.event.EventListener; +import org.springframework.core.annotation.Order; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + + +/** + * 事件监听器 + */ +@Component +@RequiredArgsConstructor +public class SpringContextEventListener { + private final LogService logService; + + /** + * 异步保存操作日志 + * + * @param event 发布日志事件 详见{@link com.sztzjy.forex.trading_trading.annotation.aspect.OperateLogAspect},{@link LogRecordEvent} + */ + @Order + @Async + @EventListener(LogRecordEvent.class) + public void logListener(LogRecordEvent event) { + Log log = (Log) event.getSource(); + logService.add(log); + } +} From bf386770e88dd0833aa7f220dd6a77078e5ca065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B2=85?= <907037276@qq.com> Date: Tue, 10 Oct 2023 22:41:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E5=8D=95=E7=82=B9=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=B0=83=E6=95=B4=202=E3=80=81=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/mappers/LogMapper.xml | 366 +++++++++++++++++++++++ 1 file changed, 366 insertions(+) create mode 100644 src/main/resources/mappers/LogMapper.xml diff --git a/src/main/resources/mappers/LogMapper.xml b/src/main/resources/mappers/LogMapper.xml new file mode 100644 index 0000000..161d11d --- /dev/null +++ b/src/main/resources/mappers/LogMapper.xml @@ -0,0 +1,366 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + id, create_time, update_time, action, description, ip_address, operator_id, operator_name, + params, user_agent + + + + + + delete from system_log + where id = #{id,jdbcType=VARCHAR} + + + + delete from system_log + + + + + + + insert into system_log (id, create_time, update_time, + action, description, ip_address, + operator_id, operator_name, params, + user_agent) + values (#{id,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, + #{action,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{ipAddress,jdbcType=VARCHAR}, + #{operatorId,jdbcType=VARCHAR}, #{operatorName,jdbcType=VARCHAR}, #{params,jdbcType=VARCHAR}, + #{userAgent,jdbcType=VARCHAR}) + + + + insert into system_log + + + id, + + + create_time, + + + update_time, + + + action, + + + description, + + + ip_address, + + + operator_id, + + + operator_name, + + + params, + + + user_agent, + + + + + #{id,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{action,jdbcType=VARCHAR}, + + + #{description,jdbcType=VARCHAR}, + + + #{ipAddress,jdbcType=VARCHAR}, + + + #{operatorId,jdbcType=VARCHAR}, + + + #{operatorName,jdbcType=VARCHAR}, + + + #{params,jdbcType=VARCHAR}, + + + #{userAgent,jdbcType=VARCHAR}, + + + + + + + update system_log + + + id = #{record.id,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + + + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + + + action = #{record.action,jdbcType=VARCHAR}, + + + description = #{record.description,jdbcType=VARCHAR}, + + + ip_address = #{record.ipAddress,jdbcType=VARCHAR}, + + + operator_id = #{record.operatorId,jdbcType=VARCHAR}, + + + operator_name = #{record.operatorName,jdbcType=VARCHAR}, + + + params = #{record.params,jdbcType=VARCHAR}, + + + user_agent = #{record.userAgent,jdbcType=VARCHAR}, + + + + + + + + + update system_log + set id = #{record.id,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + action = #{record.action,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=VARCHAR}, + ip_address = #{record.ipAddress,jdbcType=VARCHAR}, + operator_id = #{record.operatorId,jdbcType=VARCHAR}, + operator_name = #{record.operatorName,jdbcType=VARCHAR}, + params = #{record.params,jdbcType=VARCHAR}, + user_agent = #{record.userAgent,jdbcType=VARCHAR} + + + + + + + update system_log + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + action = #{action,jdbcType=VARCHAR}, + + + description = #{description,jdbcType=VARCHAR}, + + + ip_address = #{ipAddress,jdbcType=VARCHAR}, + + + operator_id = #{operatorId,jdbcType=VARCHAR}, + + + operator_name = #{operatorName,jdbcType=VARCHAR}, + + + params = #{params,jdbcType=VARCHAR}, + + + user_agent = #{userAgent,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=VARCHAR} + + + + update system_log + set create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + action = #{action,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + ip_address = #{ipAddress,jdbcType=VARCHAR}, + operator_id = #{operatorId,jdbcType=VARCHAR}, + operator_name = #{operatorName,jdbcType=VARCHAR}, + params = #{params,jdbcType=VARCHAR}, + user_agent = #{userAgent,jdbcType=VARCHAR} + where id = #{id,jdbcType=VARCHAR} + + \ No newline at end of file