From 815d0a006ee4f828665484f99b5368b69490acae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Sun, 30 Jul 2023 13:12:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=97=A5=E5=BF=97=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auditlog/AbstractAuditLogProcessor.java | 25 +++++++++++++++-- .../design/auditlog/LoginLogProcessor.java | 10 ++++++- .../design/auditlog/OrderLogProcessor.java | 10 ++++++- .../design/auditlog/PayLogProcessor.java | 10 ++++++- .../study/design/auditlog/pojo/AuditLog.java | 28 +++++++++++++++++-- 5 files changed, 76 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/study/design/auditlog/AbstractAuditLogProcessor.java b/src/main/java/com/study/design/auditlog/AbstractAuditLogProcessor.java index c8f2f23..596c506 100644 --- a/src/main/java/com/study/design/auditlog/AbstractAuditLogProcessor.java +++ b/src/main/java/com/study/design/auditlog/AbstractAuditLogProcessor.java @@ -4,9 +4,24 @@ import com.study.design.auditlog.pojo.AuditLog; import java.util.Date; + +/** + * 抽象审计日志处理器 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/30 13:10 + */ public abstract class AbstractAuditLogProcessor { - // 创建我们的 AuditLog (基础部分) - public final AuditLog buildAuditLog(String account, String action, String orderId){ + /** + * 创建我们的 AuditLog (基础部分) + * + * @param account + * @param action + * @param orderId + * @return + */ + public final AuditLog buildAuditLog(String account, String action, String orderId) { AuditLog auditLog = new AuditLog(); auditLog.setAccount(account); auditLog.setAction(action); @@ -15,6 +30,12 @@ public abstract class AbstractAuditLogProcessor { return auditLog; } + /** + * 不同的子类复写 + * + * @param auditLog + * @return + */ protected abstract AuditLog buildDetails(AuditLog auditLog); public final void sendToQueue(AuditLog auditLog) { diff --git a/src/main/java/com/study/design/auditlog/LoginLogProcessor.java b/src/main/java/com/study/design/auditlog/LoginLogProcessor.java index a58ea20..aff2a43 100644 --- a/src/main/java/com/study/design/auditlog/LoginLogProcessor.java +++ b/src/main/java/com/study/design/auditlog/LoginLogProcessor.java @@ -3,8 +3,16 @@ package com.study.design.auditlog; import com.study.design.auditlog.pojo.AuditLog; import org.springframework.stereotype.Component; + +/** + * 登录日志处理器 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/30 13:11 + */ @Component -public class LoginLogProcessor extends AbstractAuditLogProcessor{ +public class LoginLogProcessor extends AbstractAuditLogProcessor { @Override protected AuditLog buildDetails(AuditLog auditLog) { return auditLog; diff --git a/src/main/java/com/study/design/auditlog/OrderLogProcessor.java b/src/main/java/com/study/design/auditlog/OrderLogProcessor.java index 8088bc3..c344c8c 100644 --- a/src/main/java/com/study/design/auditlog/OrderLogProcessor.java +++ b/src/main/java/com/study/design/auditlog/OrderLogProcessor.java @@ -3,8 +3,16 @@ package com.study.design.auditlog; import com.study.design.auditlog.pojo.AuditLog; import org.springframework.stereotype.Component; + +/** + * 订单日志处理器 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/30 13:11 + */ @Component -public class OrderLogProcessor extends AbstractAuditLogProcessor{ +public class OrderLogProcessor extends AbstractAuditLogProcessor { @Override protected AuditLog buildDetails(AuditLog auditLog) { String orderId = auditLog.getOrderId(); diff --git a/src/main/java/com/study/design/auditlog/PayLogProcessor.java b/src/main/java/com/study/design/auditlog/PayLogProcessor.java index e56b774..77da272 100644 --- a/src/main/java/com/study/design/auditlog/PayLogProcessor.java +++ b/src/main/java/com/study/design/auditlog/PayLogProcessor.java @@ -3,8 +3,16 @@ package com.study.design.auditlog; import com.study.design.auditlog.pojo.AuditLog; import org.springframework.stereotype.Component; + +/** + * 支付日志处理器 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/30 13:12 + */ @Component -public class PayLogProcessor extends AbstractAuditLogProcessor{ +public class PayLogProcessor extends AbstractAuditLogProcessor { @Override protected AuditLog buildDetails(AuditLog auditLog) { String orderId = auditLog.getOrderId(); diff --git a/src/main/java/com/study/design/auditlog/pojo/AuditLog.java b/src/main/java/com/study/design/auditlog/pojo/AuditLog.java index a39fb8c..146b22e 100644 --- a/src/main/java/com/study/design/auditlog/pojo/AuditLog.java +++ b/src/main/java/com/study/design/auditlog/pojo/AuditLog.java @@ -2,13 +2,37 @@ package com.study.design.auditlog.pojo; import java.util.Date; + +/** + * 日志通用类 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/30 13:10 + */ public class AuditLog { + /** + * 账户 + */ private String account; + /** + * 动作 + */ private String action; + /** + * 日期 + */ private Date date; + /** + * 订单id + */ private String orderId; - private Object details; //订单创建需要有相关产品信息; - // 订单支付需要有相关产品信息以及支付方式和支付金额。 + /** + * 订单创建需要有相关产品信息; + * 订单支付需要有相关产品信息以及支付方式和支付金额。 + */ + private Object details; + public String getAccount() { return account; -- GitLab