package cn.reghao.tnb.search.esapp.log.model.po;

import cn.reghao.jutil.jdk.web.log.GatewayLog;
import cn.reghao.jutil.jdk.web.db.BaseObject;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * @author reghao
 * @date 2025-08-14 14:34:36
 */
@NoArgsConstructor
@Getter
public class AccessLog extends BaseObject<String> {
    private String requestId;
    private long requestTime;
    private String targetRoute;
    private String targetService;
    private String requestUrl;
    private String requestMethod;
    private Map<String, String> requestHeaders;
    private String requestBody;
    private String remoteAddr = "";
    private int remotePort = 0;
    private int statusCode;
    private Map<String, String> responseHeaders;
    private String responseBody;
    private long responseTime;
    private long executeTime;
    private String fingerprint;

    public AccessLog(GatewayLog gatewayLog) {
        this.requestId = gatewayLog.getRequestId();
        this.requestTime = gatewayLog.getRequestTime();
        this.targetRoute = gatewayLog.getTargetRoute();
        this.targetService = gatewayLog.getTargetService();
        this.requestUrl = gatewayLog.getRequestUrl();
        this.requestMethod = gatewayLog.getRequestMethod();
        this.requestHeaders = gatewayLog.getRequestHeaders();
        this.requestBody = gatewayLog.getRequestBody();
        this.remoteAddr = gatewayLog.getRemoteAddr();
        this.remotePort = gatewayLog.getRemotePort();
        this.statusCode = gatewayLog.getStatusCode();
        this.responseHeaders = gatewayLog.getResponseHeaders();
        this.responseBody = gatewayLog.getResponseBody();
        this.responseTime = gatewayLog.getResponseTime();
        this.executeTime = gatewayLog.getExecuteTime();
        this.fingerprint = gatewayLog.getFingerprint();
    }
}
