package com.mortals.xhx.module.access.model;

import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.base.framework.CustomJsonDateDeserializer;
import com.mortals.xhx.module.access.model.vo.AccessLogVo;
/**
 * 访问日志实体对象
 *
 * @author zxfei
 * @date 2022-08-22
 */

public class AccessLogEntity extends AccessLogVo {
    private static final long serialVersionUID = 1L;

    /**
     * TraceId
     */
    private String traceID;
    /**
     * 父服务调用id
     */
    private Integer pspanId;
    /**
     * 当前服务跨度Id
     */
    private Integer spanId;
    /**
     * 应用名称
     */
    private String appName;
    /**
     * 实例IP
     */
    private String hostName;
    /**
     * 目标服务
     */
    private String targetServer;
    /**
     * 日志等级
     */
    private String logLevel;
    /**
     * 请求者IP
     */
    private String requestIp;
    /**
     * 请求方式
     */
    private String method;
    /**
     * 用户浏览器UA
     */
    private String ua;
    /**
     * 请求URI
     */
    private String uri;
    /**
     * 请求参数，json序列化
     */
    private String requestData;
    /**
     * 响应结果,
     */
    private String responseData;
    /**
     * 日志产生时间
     */
    private Date logTime;
    /**
     * 请求时间
     */
    private Date requestTime;
    /**
     * 响应时间
     */
    private Date responseTime;
    /**
     * 持续时间，单位毫秒
     */
    private Long duration;
    /**
     * 协议
     */
    private String schemaData;



    public AccessLogEntity(){}
    /**
     * 获取 TraceId
     * @return String
     */
    public String getTraceID(){
        return traceID;
    }
    /**
     * 设置 TraceId
     * @param traceID
     */
    public void setTraceID(String traceID){
        this.traceID = traceID;
    }
    /**
     * 获取 父服务调用id
     * @return Integer
     */
    public Integer getPspanId(){
        return pspanId;
    }
    /**
     * 设置 父服务调用id
     * @param pspanId
     */
    public void setPspanId(Integer pspanId){
        this.pspanId = pspanId;
    }
    /**
     * 获取 当前服务跨度Id
     * @return Integer
     */
    public Integer getSpanId(){
        return spanId;
    }
    /**
     * 设置 当前服务跨度Id
     * @param spanId
     */
    public void setSpanId(Integer spanId){
        this.spanId = spanId;
    }
    /**
     * 获取 应用名称
     * @return String
     */
    public String getAppName(){
        return appName;
    }
    /**
     * 设置 应用名称
     * @param appName
     */
    public void setAppName(String appName){
        this.appName = appName;
    }
    /**
     * 获取 实例IP
     * @return String
     */
    public String getHostName(){
        return hostName;
    }
    /**
     * 设置 实例IP
     * @param hostName
     */
    public void setHostName(String hostName){
        this.hostName = hostName;
    }
    /**
     * 获取 目标服务
     * @return String
     */
    public String getTargetServer(){
        return targetServer;
    }
    /**
     * 设置 目标服务
     * @param targetServer
     */
    public void setTargetServer(String targetServer){
        this.targetServer = targetServer;
    }
    /**
     * 获取 日志等级
     * @return String
     */
    public String getLogLevel(){
        return logLevel;
    }
    /**
     * 设置 日志等级
     * @param logLevel
     */
    public void setLogLevel(String logLevel){
        this.logLevel = logLevel;
    }
    /**
     * 获取 请求者IP
     * @return String
     */
    public String getRequestIp(){
        return requestIp;
    }
    /**
     * 设置 请求者IP
     * @param requestIp
     */
    public void setRequestIp(String requestIp){
        this.requestIp = requestIp;
    }
    /**
     * 获取 请求方式
     * @return String
     */
    public String getMethod(){
        return method;
    }
    /**
     * 设置 请求方式
     * @param method
     */
    public void setMethod(String method){
        this.method = method;
    }
    /**
     * 获取 用户浏览器UA
     * @return String
     */
    public String getUa(){
        return ua;
    }
    /**
     * 设置 用户浏览器UA
     * @param ua
     */
    public void setUa(String ua){
        this.ua = ua;
    }
    /**
     * 获取 请求URI
     * @return String
     */
    public String getUri(){
        return uri;
    }
    /**
     * 设置 请求URI
     * @param uri
     */
    public void setUri(String uri){
        this.uri = uri;
    }
    /**
     * 获取 请求参数，json序列化
     * @return String
     */
    public String getRequestData(){
        return requestData;
    }
    /**
     * 设置 请求参数，json序列化
     * @param requestData
     */
    public void setRequestData(String requestData){
        this.requestData = requestData;
    }
    /**
     * 获取 响应结果,
     * @return String
     */
    public String getResponseData(){
        return responseData;
    }
    /**
     * 设置 响应结果,
     * @param responseData
     */
    public void setResponseData(String responseData){
        this.responseData = responseData;
    }
    /**
     * 获取 日志产生时间
     * @return Date
     */
    public Date getLogTime(){
        return logTime;
    }
    /**
     * 设置 日志产生时间
     * @param logTime
     */
    public void setLogTime(Date logTime){
        this.logTime = logTime;
    }
    /**
     * 获取 请求时间
     * @return Date
     */
    public Date getRequestTime(){
        return requestTime;
    }
    /**
     * 设置 请求时间
     * @param requestTime
     */
    public void setRequestTime(Date requestTime){
        this.requestTime = requestTime;
    }
    /**
     * 获取 响应时间
     * @return Date
     */
    public Date getResponseTime(){
        return responseTime;
    }
    /**
     * 设置 响应时间
     * @param responseTime
     */
    public void setResponseTime(Date responseTime){
        this.responseTime = responseTime;
    }
    /**
     * 获取 持续时间，单位毫秒
     * @return Long
     */
    public Long getDuration(){
        return duration;
    }
    /**
     * 设置 持续时间，单位毫秒
     * @param duration
     */
    public void setDuration(Long duration){
        this.duration = duration;
    }
    /**
     * 获取 协议
     * @return String
     */
    public String getSchemaData(){
        return schemaData;
    }
    /**
     * 设置 协议
     * @param schemaData
     */
    public void setSchemaData(String schemaData){
        this.schemaData = schemaData;
    }




    @Override
    public int hashCode() {
        return this.getId().hashCode();
    }
    @Override
    public boolean equals(Object obj) {
        if (obj == null) return false;
        if (obj instanceof AccessLogEntity) {
            AccessLogEntity tmp = (AccessLogEntity) obj;
            if (this.getId() == tmp.getId()) {
                return true;
            }
        }
        return false;
    }

    public String toString(){
        StringBuilder sb = new StringBuilder("");
        sb.append(",traceID:").append(getTraceID());
        sb.append(",pspanId:").append(getPspanId());
        sb.append(",spanId:").append(getSpanId());
        sb.append(",appName:").append(getAppName());
        sb.append(",hostName:").append(getHostName());
        sb.append(",targetServer:").append(getTargetServer());
        sb.append(",logLevel:").append(getLogLevel());
        sb.append(",requestIp:").append(getRequestIp());
        sb.append(",method:").append(getMethod());
        sb.append(",ua:").append(getUa());
        sb.append(",uri:").append(getUri());
        sb.append(",requestData:").append(getRequestData());
        sb.append(",responseData:").append(getResponseData());
        sb.append(",logTime:").append(getLogTime());
        sb.append(",requestTime:").append(getRequestTime());
        sb.append(",responseTime:").append(getResponseTime());
        sb.append(",duration:").append(getDuration());
        sb.append(",schemaData:").append(getSchemaData());
        return sb.toString();
    }

    public void initAttrValue(){

        this.traceID = "";

        this.pspanId = 0;

        this.spanId = null;

        this.appName = "";

        this.hostName = "";

        this.targetServer = "";

        this.logLevel = "INFO";

        this.requestIp = "";

        this.method = "";

        this.ua = "";

        this.uri = "";

        this.requestData = "";

        this.responseData = "";

        this.logTime = null;

        this.requestTime = null;

        this.responseTime = null;

        this.duration = null;

        this.schemaData = "http";
    }
}