package cn.estsh.i3plus.pojo.platform.platbean;

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.mongodb.core.mapping.Document;

import javax.persistence.Column;
import javax.persistence.Table;

/**
 * @Description :
 * @Reference :
 * @Author : wei.peng
 * @CreateDate : 20-4-9 下午8:41
 * @Modify:
 **/
@Data
@Document
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="SYS_LOG_CONSOLE")
@Api(value="系统异常表",description = "记录系统出现的异常")
public class SysLogConsole extends BaseBean {


    private static final long serialVersionUID = -6073378683575266830L;
    /******** 服务器信息 ********/
    @Column(name="SOFT_TYPE")
    @ApiParam(value ="产品名称")
    private Integer softType;
    public String getSoftTypeTxt() {
        return softType == null ? null : CommonEnumUtil.SOFT_TYPE.valueOfDescription(softType);
    }

    @Column(name="LOG_HOST")
    @ApiParam(value ="服务器IP")
    private String logHost;

    @Column(name="LOG_PID")
    @ApiParam(value ="应用PID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long logPid;

    @Column(name="LOG_PORT")
    @ApiParam(value ="应用端口")
    private Integer logPort;

    @Column(name="LOG_GROUP")
    @ApiParam(value ="日志分组(日志记录器名称，getLogger方法的参数值)")
    private String logGroup;

    @Column(name="LOG_LEVEL")
    @ApiParam(value ="日志等级(OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL)")
    private String logLevel;

    @Column(name="LOG_TYPE")
    @ApiParam(value ="操作类型(post,put,get)")
    private String logType;

    /******** 用户信息 ********/

    @Column(name="USER_HOST")
    @ApiParam(value ="用户登录IP")
    private String userHost;

    @Column(name="USER_BROWSER")
    @ApiParam(value ="用户登录浏览器")
    private String userBrowser;

    @Column(name="USER_OS")
    @ApiParam(value ="用户登录操作系统")
    private String userOs;

    @Column(name="USER_ID")
    @ApiParam(value ="账号ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;

    @Column(name="USER_LOGIN_NAME")
    @ApiParam(value ="用户登录名称")
    private String userLoginName;

    /******** 日志信息 ********/
    @Column(name="REQUEST_ID")
    @ApiParam(value ="请求ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long requestId;

    @Column(name="EXECUTE_THREAD_ID")
    @ApiParam(value ="执行线程")
    private String executeThreadId;

    @Column(name="EXECUTE_CLASS_NAME")
    @ApiParam(value ="执行Class")
    private String executeClassName;

    @Column(name="EXECUTE_METHOD")
    @ApiParam(value ="执行方法")
    private String executeMethod;

    @Column(name="EXECUTE_LINE_NUMBER")
    @ApiParam(value ="报错行数")
    private Integer executeLineNumber;

    @Column(name="EXECUTE_TITLE")
    @ApiParam(value ="方法标题")
    private String executeTitle;

    @Column(name="EXECUTE_ARGS")
    @ApiParam(value ="执行参数")
    private String executeArgs;

    @Column(name="EXECUTE_TIME")
    @ApiParam(value ="执行耗时")
    private Integer executeTime;

    @Column(name="EXECUTE_STATUS")
    @ApiParam(value ="执行状态")
    private String executeStatus;

    @Column(name="EXECUTE_MESSAGE")
    @ApiParam(value ="执行日志信息")
    private String executeMessage;

    @Column(name="ERROR_STACK_TRACE",length = 5000)
    @ApiParam(value ="执行异常堆栈信息")
    private String errorStackTrace;

}
