package com.mini.capi.biz.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.time.LocalDateTime;

import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 数据同步任务执行日志表
 * </p>
 *
 * @author gaoxq
 * @since 2025-08-27
 */
@Getter
@Setter
@TableName("biz_sync_task_log")
public class SyncTaskLog implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 记录创建时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 日志ID
     */
    @TableId(value = "task_log_id", type = IdType.AUTO)
    private String taskLogId;

    /**
     * 关联的同步任务ID
     */
    @TableField("task_id")
    private String taskId;

    /**
     * 同步任务名称
     */
    @TableField("task_name")
    private String taskName;

    /**
     * 源数据库ID
     */
    @TableField("source_db_id")
    private String sourceDbId;

    /**
     * 源数据库名称
     */
    @TableField("source_db_name")
    private String sourceDbName;

    /**
     * 源表名
     */
    @TableField("source_table")
    private String sourceTable;

    /**
     * 目标数据库ID
     */
    @TableField("target_db_id")
    private String targetDbId;

    /**
     * 目标数据库名称
     */
    @TableField("target_db_name")
    private String targetDbName;

    /**
     * 目标表名
     */
    @TableField("target_table")
    private String targetTable;

    /**
     * 同步开始时间
     */
    @TableField("start_time")
    private LocalDateTime startTime;

    /**
     * 同步结束时间
     */
    @TableField("end_time")
    private LocalDateTime endTime;

    /**
     * 总记录数
     */
    @TableField("total_rows")
    private Long totalRows;

    /**
     * 成功同步记录数
     */
    @TableField("success_rows")
    private Long successRows;

    /**
     * 失败记录数
     */
    @TableField("fail_rows")
    private Long failRows;

    /**
     * 同步状态(0:执行中,1:成功,2:失败)
     */
    @TableField("sync_status")
    private String syncStatus;

    /**
     * 错误信息(失败时记录)
     */
    @TableField("error_msg")
    private String errorMsg;

    /**
     * 耗时(秒)
     */
    @TableField("cost_time")
    private Integer costTime;

    /**
     * 租户id
     */
    @TableField("f_tenant_id")
    private String fTenantId;

    /**
     * 流程id
     */
    @TableField("f_flow_id")
    private String fFlowId;

    /**
     * 流程任务主键
     */
    @TableField("f_flow_task_id")
    private String fFlowTaskId;

    /**
     * 流程任务状态
     */
    @TableField("f_flow_state")
    private Integer fFlowState;


    public SyncTaskLog(String taskId, String taskName, String sourceDbId, String sourceDbName, String sourceTable, String targetDbId
            , String targetDbName, String targetTable, LocalDateTime startTime, LocalDateTime endTime, Long totalRows, Long successRows, Long failRows, String syncStatus
            , String errorMsg, Integer costTime, String fTenantId) {
        this.taskId = taskId;
        this.taskName = taskName;
        this.sourceDbId = sourceDbId;
        this.sourceDbName = sourceDbName;
        this.sourceTable = sourceTable;
        this.targetDbId = targetDbId;
        this.targetDbName = targetDbName;
        this.targetTable = targetTable;
        this.startTime = startTime;
        this.endTime = endTime;
        this.totalRows = totalRows;
        this.successRows = successRows;
        this.failRows = failRows;
        this.syncStatus = syncStatus;
        this.errorMsg = errorMsg;
        this.costTime = costTime;
        this.fTenantId = fTenantId;
    }
}
