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