diff --git a/src/main/java/com/study/design/auditlog/AbstractAuditLogProcessor.java b/src/main/java/com/study/design/auditlog/AbstractAuditLogProcessor.java index c8f2f23d36ae4b01c13edf7cd33b8e5109d5f9e3..596c506ae543cd878c64b9f0fe0947a3c642c01d 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 a58ea202a02c0af35954b2a51fb8e5d2da109b0e..aff2a435b34aafbfbfd980287625c61f9c049dd6 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 8088bc34dc4ee1f475bc52809222e58f809c3b1b..c344c8cc9cb14726f33319b207c84177e21cb9c5 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 e56b77481bca841ff4df5546fbd2931639226218..77da272add2867563750ec6053d5b2097c63879c 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 a39fb8cc205c26eb5b6b0373d15976612085e796..146b22e41185a1631ac33b89e7e5760a05437c4a 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;