mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-09 08:57:17 +08:00
chore: 移除 lombok 依赖
再度精简依赖
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package top.charles7c.continew.starter.log.common.model;
|
||||
|
||||
import lombok.Data;
|
||||
import top.charles7c.continew.starter.log.common.enums.Include;
|
||||
|
||||
import java.time.Clock;
|
||||
@@ -33,7 +32,6 @@ import java.util.Set;
|
||||
* @author Charles7c
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Data
|
||||
public class LogRecord {
|
||||
|
||||
/**
|
||||
@@ -134,4 +132,53 @@ public class LogRecord {
|
||||
return new LogRecord(this.timestamp, logRequest, logResponse, duration);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public void setModule(String module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public LogRequest getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public void setRequest(LogRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public LogResponse getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(LogResponse response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public Duration getTimeTaken() {
|
||||
return timeTaken;
|
||||
}
|
||||
|
||||
public void setTimeTaken(Duration timeTaken) {
|
||||
this.timeTaken = timeTaken;
|
||||
}
|
||||
|
||||
public Instant getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogRecord{" + "description='" + description + '\'' + ", module='" + module + '\'' + ", request=" + request + ", response=" + response + ", timeTaken=" + timeTaken + ", timestamp=" + timestamp + '}';
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@
|
||||
package top.charles7c.continew.starter.log.common.model;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Data;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import top.charles7c.continew.starter.core.util.ExceptionUtils;
|
||||
import top.charles7c.continew.starter.core.util.IpUtils;
|
||||
@@ -34,7 +33,6 @@ import java.util.Set;
|
||||
* @author Charles7c
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Data
|
||||
public class LogRequest {
|
||||
|
||||
/**
|
||||
@@ -99,4 +97,81 @@ public class LogRequest {
|
||||
this.os = (includes.contains(Include.OS)) ? ServletUtils.getOs(userAgentString) : null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public URI getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(URI url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public Map<String, String> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
public void setHeaders(Map<String, String> headers) {
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
public void setParam(Map<String, Object> param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getBrowser() {
|
||||
return browser;
|
||||
}
|
||||
|
||||
public void setBrowser(String browser) {
|
||||
this.browser = browser;
|
||||
}
|
||||
|
||||
public String getOs() {
|
||||
return os;
|
||||
}
|
||||
|
||||
public void setOs(String os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogRequest{" + "method='" + method + '\'' + ", url=" + url + ", ip='" + ip + '\'' + ", headers=" + headers + ", body='" + body + '\'' + ", param=" + param + ", address='" + address + '\'' + ", browser='" + browser + '\'' + ", os='" + os + '\'' + '}';
|
||||
}
|
||||
}
|
@@ -16,7 +16,6 @@
|
||||
|
||||
package top.charles7c.continew.starter.log.common.model;
|
||||
|
||||
import lombok.Data;
|
||||
import top.charles7c.continew.starter.log.common.enums.Include;
|
||||
|
||||
import java.util.*;
|
||||
@@ -27,7 +26,6 @@ import java.util.*;
|
||||
* @author Charles7c
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Data
|
||||
public class LogResponse {
|
||||
|
||||
/**
|
||||
@@ -59,4 +57,41 @@ public class LogResponse {
|
||||
this.param = response.getParam();
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Map<String, String> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
public void setHeaders(Map<String, String> headers) {
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
public void setParam(Map<String, Object> param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogResponse{" + "status=" + status + ", headers=" + headers + ", body='" + body + '\'' + ", param=" + param + '}';
|
||||
}
|
||||
}
|
@@ -17,8 +17,8 @@
|
||||
package top.charles7c.continew.starter.log.httptracepro.autoconfigure;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@@ -37,16 +37,19 @@ import top.charles7c.continew.starter.log.httptracepro.handler.LogInterceptor;
|
||||
* @author Charles7c
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@ConditionalOnEnabledLog
|
||||
@RequiredArgsConstructor
|
||||
@EnableConfigurationProperties(LogProperties.class)
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
public class LogAutoConfiguration implements WebMvcConfigurer {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(LogAutoConfiguration.class);
|
||||
private final LogProperties logProperties;
|
||||
|
||||
public LogAutoConfiguration(LogProperties logProperties) {
|
||||
this.logProperties = logProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new LogInterceptor(logDao(), logProperties));
|
||||
|
@@ -16,7 +16,6 @@
|
||||
|
||||
package top.charles7c.continew.starter.log.httptracepro.autoconfigure;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
|
||||
import top.charles7c.continew.starter.log.common.enums.Include;
|
||||
@@ -30,7 +29,6 @@ import java.util.Set;
|
||||
* @author Charles7c
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(PropertiesConstants.LOG)
|
||||
public class LogProperties {
|
||||
|
||||
@@ -48,4 +46,33 @@ public class LogProperties {
|
||||
* 包含信息
|
||||
*/
|
||||
private Set<Include> include = new HashSet<>(Include.defaultIncludes());
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public Boolean getIsPrint() {
|
||||
return isPrint;
|
||||
}
|
||||
|
||||
public void setIsPrint(Boolean print) {
|
||||
isPrint = print;
|
||||
}
|
||||
|
||||
public Set<Include> getInclude() {
|
||||
return include;
|
||||
}
|
||||
|
||||
public void setInclude(Set<Include> include) {
|
||||
this.include = include;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogProperties{" + "enabled=" + enabled + ", isPrint=" + isPrint + ", include=" + include + '}';
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@ import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
@@ -47,11 +46,14 @@ import java.util.Set;
|
||||
* @author Charles7c
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class LogFilter extends OncePerRequestFilter implements Ordered {
|
||||
|
||||
private final LogProperties logProperties;
|
||||
|
||||
public LogFilter(LogProperties logProperties) {
|
||||
this.logProperties = logProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.LOWEST_PRECEDENCE - 10;
|
||||
|
@@ -24,8 +24,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
@@ -46,14 +46,18 @@ import java.util.Set;
|
||||
* @author Charles7c
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class LogInterceptor implements HandlerInterceptor {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(LogInterceptor.class);
|
||||
private final LogDao logDao;
|
||||
private final LogProperties logProperties;
|
||||
private final TransmittableThreadLocal<LogRecord.Started> timestampTtl = new TransmittableThreadLocal<>();
|
||||
|
||||
public LogInterceptor(LogDao logDao, LogProperties logProperties) {
|
||||
this.logDao = logDao;
|
||||
this.logProperties = logProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(@NonNull HttpServletRequest request,
|
||||
@NonNull HttpServletResponse response,
|
||||
|
Reference in New Issue
Block a user