package com.common.entity;


import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

@Data
//@Document(indexName = "applog-#{T(java.time.LocalDate).now().format(T(java.time.format.DateTimeFormatter).ofPattern('yyyyMMdd'))}")
public class AppLog {

    // ES元数据字段
    @Id
    private String id;

    @Field(type = FieldType.Keyword)
    private String index;

    @Field(type = FieldType.Keyword)
    private String type = "_doc";

    @Field(type = FieldType.Float)
    private Float score = 1.0f;

    // 日志内容字段（对应_source）
    @Field(name = "dtTime", type = FieldType.Long)
    private Long dtTime;

    @Field(name = "collecttime", type = FieldType.Long)
    private Long collectTime;

    @Field(name = "logType", type = FieldType.Keyword)
    private String logType;

    @Field(name = "traceId", type = FieldType.Keyword)
    private String traceId;

    @Field(name = "method", type = FieldType.Text)
    private String method;

    @Field(name = "appName", type = FieldType.Keyword)
    private String appName;

    @Field(name = "ip", type = FieldType.Keyword)
    private String ip;

    @Field(name = "className", type = FieldType.Text)
    private String className;

    @Field(name = "env", type = FieldType.Keyword)
    private String env;

    @Field(name = "content", type = FieldType.Text)
    private String content;

    @Field(name = "threadName", type = FieldType.Text)
    private String threadName;

    @Field(name = "logLevel", type = FieldType.Keyword)
    private String logLevel;

    @Field(name = "seq", type = FieldType.Keyword)
    private String seq;

    @Field(name = "_indexed_at", type = FieldType.Long)
    private Long indexedAt;

    // 系统字段
    private Date createTime = new Date();
}