pigx-common-log
This commit is contained in:
parent
40938c20b6
commit
6b16897c70
|
|
@ -1,6 +1,7 @@
|
||||||
package com.pig4cloud.pigx.common.log;
|
package com.pig4cloud.pigx.common.log;
|
||||||
|
|
||||||
import com.pig4cloud.pigx.common.log.aspect.SysLogAspect;
|
import com.pig4cloud.pigx.common.log.aspect.SysLogAspect;
|
||||||
|
import lombok.Generated;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,11 @@ package com.pig4cloud.pigx.common.log;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import lombok.Generated;
|
||||||
|
|
||||||
@ApiModel("日志")
|
@ApiModel("日志")
|
||||||
public class SysLog implements Serializable {
|
public class SysLog {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
@ApiModelProperty("日志编号")
|
@ApiModelProperty("日志编号")
|
||||||
private Long id;
|
private Long id;
|
||||||
@ApiModelProperty("日志类型")
|
@ApiModelProperty("日志类型")
|
||||||
|
|
@ -44,126 +43,157 @@ public class SysLog implements Serializable {
|
||||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
|
||||||
|
@Generated
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return this.title;
|
return this.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public String getCreateBy() {
|
public String getCreateBy() {
|
||||||
return this.createBy;
|
return this.createBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public LocalDateTime getCreateTime() {
|
public LocalDateTime getCreateTime() {
|
||||||
return this.createTime;
|
return this.createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public LocalDateTime getUpdateTime() {
|
public LocalDateTime getUpdateTime() {
|
||||||
return this.updateTime;
|
return this.updateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public String getRemoteAddr() {
|
public String getRemoteAddr() {
|
||||||
return this.remoteAddr;
|
return this.remoteAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public String getUserAgent() {
|
public String getUserAgent() {
|
||||||
return this.userAgent;
|
return this.userAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public String getRequestUri() {
|
public String getRequestUri() {
|
||||||
return this.requestUri;
|
return this.requestUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public String getMethod() {
|
public String getMethod() {
|
||||||
return this.method;
|
return this.method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public String getParams() {
|
public String getParams() {
|
||||||
return this.params;
|
return this.params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public Long getTime() {
|
public Long getTime() {
|
||||||
return this.time;
|
return this.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public String getException() {
|
public String getException() {
|
||||||
return this.exception;
|
return this.exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public String getServiceId() {
|
public String getServiceId() {
|
||||||
return this.serviceId;
|
return this.serviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public Integer getDelFlag() {
|
public Integer getDelFlag() {
|
||||||
return this.delFlag;
|
return this.delFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setId(final Long id) {
|
public void setId(final Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setType(final String type) {
|
public void setType(final String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setCreateBy(final String createBy) {
|
public void setCreateBy(final String createBy) {
|
||||||
this.createBy = createBy;
|
this.createBy = createBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setCreateTime(final LocalDateTime createTime) {
|
public void setCreateTime(final LocalDateTime createTime) {
|
||||||
this.createTime = createTime;
|
this.createTime = createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setUpdateTime(final LocalDateTime updateTime) {
|
public void setUpdateTime(final LocalDateTime updateTime) {
|
||||||
this.updateTime = updateTime;
|
this.updateTime = updateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setRemoteAddr(final String remoteAddr) {
|
public void setRemoteAddr(final String remoteAddr) {
|
||||||
this.remoteAddr = remoteAddr;
|
this.remoteAddr = remoteAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setUserAgent(final String userAgent) {
|
public void setUserAgent(final String userAgent) {
|
||||||
this.userAgent = userAgent;
|
this.userAgent = userAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setRequestUri(final String requestUri) {
|
public void setRequestUri(final String requestUri) {
|
||||||
this.requestUri = requestUri;
|
this.requestUri = requestUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setMethod(final String method) {
|
public void setMethod(final String method) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setParams(final String params) {
|
public void setParams(final String params) {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setTime(final Long time) {
|
public void setTime(final Long time) {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setException(final String exception) {
|
public void setException(final String exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setServiceId(final String serviceId) {
|
public void setServiceId(final String serviceId) {
|
||||||
this.serviceId = serviceId;
|
this.serviceId = serviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public void setDelFlag(final Integer delFlag) {
|
public void setDelFlag(final Integer delFlag) {
|
||||||
this.delFlag = delFlag;
|
this.delFlag = delFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (o == this) {
|
if (o == this) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -357,10 +387,12 @@ public class SysLog implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
return other instanceof SysLog;
|
return other instanceof SysLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int PRIME = true;
|
int PRIME = true;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
|
@ -397,6 +429,7 @@ public class SysLog implements Serializable {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public String toString() {
|
public String toString() {
|
||||||
Long var10000 = this.getId();
|
Long var10000 = this.getId();
|
||||||
return "SysLog(id=" + var10000 + ", type=" + this.getType() + ", title=" + this.getTitle() + ", createBy=" + this.getCreateBy() + ", createTime=" + String.valueOf(this.getCreateTime()) + ", updateTime=" + String.valueOf(this.getUpdateTime()) + ", remoteAddr=" + this.getRemoteAddr() + ", userAgent=" + this.getUserAgent() + ", requestUri=" + this.getRequestUri() + ", method=" + this.getMethod() + ", params=" + this.getParams() + ", time=" + this.getTime() + ", exception=" + this.getException() + ", serviceId=" + this.getServiceId() + ", delFlag=" + this.getDelFlag() + ")";
|
return "SysLog(id=" + var10000 + ", type=" + this.getType() + ", title=" + this.getTitle() + ", createBy=" + this.getCreateBy() + ", createTime=" + String.valueOf(this.getCreateTime()) + ", updateTime=" + String.valueOf(this.getUpdateTime()) + ", remoteAddr=" + this.getRemoteAddr() + ", userAgent=" + this.getUserAgent() + ", requestUri=" + this.getRequestUri() + ", method=" + this.getMethod() + ", params=" + this.getParams() + ", time=" + this.getTime() + ", exception=" + this.getException() + ", serviceId=" + this.getServiceId() + ", delFlag=" + this.getDelFlag() + ")";
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.pig4cloud.pigx.common.log.aspect;
|
||||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||||
import com.pig4cloud.pigx.common.log.event.SysLogEvent;
|
import com.pig4cloud.pigx.common.log.event.SysLogEvent;
|
||||||
import com.pig4cloud.pigx.common.log.util.SysLogUtils;
|
import com.pig4cloud.pigx.common.log.util.SysLogUtils;
|
||||||
|
import lombok.Generated;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
|
@ -12,6 +13,7 @@ import org.springframework.context.ApplicationEventPublisher;
|
||||||
|
|
||||||
@Aspect
|
@Aspect
|
||||||
public class SysLogAspect {
|
public class SysLogAspect {
|
||||||
|
@Generated
|
||||||
private static final Logger log = LoggerFactory.getLogger(SysLogAspect.class);
|
private static final Logger log = LoggerFactory.getLogger(SysLogAspect.class);
|
||||||
private final ApplicationEventPublisher publisher;
|
private final ApplicationEventPublisher publisher;
|
||||||
|
|
||||||
|
|
@ -34,6 +36,7 @@ public class SysLogAspect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
public SysLogAspect(final ApplicationEventPublisher publisher) {
|
public SysLogAspect(final ApplicationEventPublisher publisher) {
|
||||||
this.publisher = publisher;
|
this.publisher = publisher;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,12 @@ package com.pig4cloud.pigx.common.log.event;
|
||||||
|
|
||||||
import com.pig4cloud.pigx.common.log.SysLog;
|
import com.pig4cloud.pigx.common.log.SysLog;
|
||||||
|
|
||||||
public class SysLogEvent {
|
public record SysLogEvent(SysLog sysLog) {
|
||||||
private final SysLog sysLog;
|
public SysLogEvent(SysLog sysLog) {
|
||||||
|
|
||||||
public SysLog getSysLog() {
|
|
||||||
return this.sysLog;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SysLogEvent(final SysLog sysLog) {
|
|
||||||
this.sysLog = sysLog;
|
this.sysLog = sysLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SysLog sysLog() {
|
||||||
|
return this.sysLog;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.pig4cloud.pigx.common.log.event;
|
package com.pig4cloud.pigx.common.log.event;
|
||||||
|
|
||||||
|
import lombok.Generated;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
|
|
@ -7,6 +8,7 @@ import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
|
||||||
public class SysLogListener {
|
public class SysLogListener {
|
||||||
|
@Generated
|
||||||
private static final Logger log = LoggerFactory.getLogger(SysLogListener.class);
|
private static final Logger log = LoggerFactory.getLogger(SysLogListener.class);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@ import cn.hutool.extra.servlet.JakartaServletUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.pig4cloud.pigx.common.log.SysLog;
|
import com.pig4cloud.pigx.common.log.SysLog;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.xnzn.framework.secure.SecureManager;
|
import java.util.Objects;
|
||||||
|
import lombok.Generated;
|
||||||
|
import net.xnzn.framework.secure.token.TokenManager;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public final class SysLogUtils {
|
public final class SysLogUtils {
|
||||||
public static SysLog getSysLog() {
|
public static SysLog getSysLog() {
|
||||||
HttpServletRequest request = ((ServletRequestAttributes)Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
HttpServletRequest request = ((ServletRequestAttributes)Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||||
|
|
@ -26,9 +26,10 @@ public final class SysLogUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getUsername() {
|
private static String getUsername() {
|
||||||
return (String)SecureManager.getSubjectName().orElse((Object)null);
|
return (String)TokenManager.getSubjectName().orElse((Object)null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Generated
|
||||||
private SysLogUtils() {
|
private SysLogUtils() {
|
||||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue