package com.lesingle.modules.leai.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 乐读派 Webhook 事件去重表
 * <p>
 * 注意：此表为追加-only日志表，不需要 BaseEntity 的审计字段（updateBy、modifyTime、deleted 等），
 * 因此独立定义 id 和 createTime，不继承 BaseEntity。
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "t_leai_webhook_event", autoResultMap = true)
@Schema(description = "乐读派 Webhook 事件")
public class LeaiWebhookEvent {

    @Schema(description = "主键ID")
    @TableField("id")
    private Long id;

    @Schema(description = "事件唯一ID（X-Webhook-Id）")
    @TableField("event_id")
    private String eventId;

    @Schema(description = "事件类型")
    @TableField("event_type")
    private String eventType;

    @Schema(description = "乐读派作品ID")
    @TableField("remote_work_id")
    private String remoteWorkId;

    @Schema(description = "事件原始载荷")
    @TableField(value = "payload", typeHandler = JacksonTypeHandler.class)
    private Object payload;

    @Schema(description = "处理状态：0-未处理，1-已处理成功，2-处理失败")
    @TableField("processed")
    private Integer processed;

    @Schema(description = "失败原因")
    @TableField("error_message")
    private String errorMessage;

    @Schema(description = "重试次数")
    @TableField("retry_count")
    private Integer retryCount;

    @Schema(description = "创建时间")
    @TableField("create_time")
    private LocalDateTime createTime;
}
