fix:日志模块

上级 f6fa2d8d
...@@ -4,9 +4,24 @@ import com.study.design.auditlog.pojo.AuditLog; ...@@ -4,9 +4,24 @@ import com.study.design.auditlog.pojo.AuditLog;
import java.util.Date; import java.util.Date;
/**
* 抽象审计日志处理器
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/7/30 13:10
*/
public abstract class AbstractAuditLogProcessor { 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 auditLog = new AuditLog();
auditLog.setAccount(account); auditLog.setAccount(account);
auditLog.setAction(action); auditLog.setAction(action);
...@@ -15,6 +30,12 @@ public abstract class AbstractAuditLogProcessor { ...@@ -15,6 +30,12 @@ public abstract class AbstractAuditLogProcessor {
return auditLog; return auditLog;
} }
/**
* 不同的子类复写
*
* @param auditLog
* @return
*/
protected abstract AuditLog buildDetails(AuditLog auditLog); protected abstract AuditLog buildDetails(AuditLog auditLog);
public final void sendToQueue(AuditLog auditLog) { public final void sendToQueue(AuditLog auditLog) {
......
...@@ -3,8 +3,16 @@ package com.study.design.auditlog; ...@@ -3,8 +3,16 @@ package com.study.design.auditlog;
import com.study.design.auditlog.pojo.AuditLog; import com.study.design.auditlog.pojo.AuditLog;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/**
* 登录日志处理器
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/7/30 13:11
*/
@Component @Component
public class LoginLogProcessor extends AbstractAuditLogProcessor{ public class LoginLogProcessor extends AbstractAuditLogProcessor {
@Override @Override
protected AuditLog buildDetails(AuditLog auditLog) { protected AuditLog buildDetails(AuditLog auditLog) {
return auditLog; return auditLog;
......
...@@ -3,8 +3,16 @@ package com.study.design.auditlog; ...@@ -3,8 +3,16 @@ package com.study.design.auditlog;
import com.study.design.auditlog.pojo.AuditLog; import com.study.design.auditlog.pojo.AuditLog;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/**
* 订单日志处理器
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/7/30 13:11
*/
@Component @Component
public class OrderLogProcessor extends AbstractAuditLogProcessor{ public class OrderLogProcessor extends AbstractAuditLogProcessor {
@Override @Override
protected AuditLog buildDetails(AuditLog auditLog) { protected AuditLog buildDetails(AuditLog auditLog) {
String orderId = auditLog.getOrderId(); String orderId = auditLog.getOrderId();
......
...@@ -3,8 +3,16 @@ package com.study.design.auditlog; ...@@ -3,8 +3,16 @@ package com.study.design.auditlog;
import com.study.design.auditlog.pojo.AuditLog; import com.study.design.auditlog.pojo.AuditLog;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/**
* 支付日志处理器
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/7/30 13:12
*/
@Component @Component
public class PayLogProcessor extends AbstractAuditLogProcessor{ public class PayLogProcessor extends AbstractAuditLogProcessor {
@Override @Override
protected AuditLog buildDetails(AuditLog auditLog) { protected AuditLog buildDetails(AuditLog auditLog) {
String orderId = auditLog.getOrderId(); String orderId = auditLog.getOrderId();
......
...@@ -2,13 +2,37 @@ package com.study.design.auditlog.pojo; ...@@ -2,13 +2,37 @@ package com.study.design.auditlog.pojo;
import java.util.Date; import java.util.Date;
/**
* 日志通用类
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/7/30 13:10
*/
public class AuditLog { public class AuditLog {
/**
* 账户
*/
private String account; private String account;
/**
* 动作
*/
private String action; private String action;
/**
* 日期
*/
private Date date; private Date date;
/**
* 订单id
*/
private String orderId; private String orderId;
private Object details; //订单创建需要有相关产品信息; /**
// 订单支付需要有相关产品信息以及支付方式和支付金额。 * 订单创建需要有相关产品信息;
* 订单支付需要有相关产品信息以及支付方式和支付金额。
*/
private Object details;
public String getAccount() { public String getAccount() {
return account; return account;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册