package com.tmerclub.cloud.search.canal.model;

import com.tmerclub.cloud.search.canal.common.BinLogEventType;
import com.tmerclub.cloud.search.canal.common.OperationType;

import java.io.Serial;
import java.io.Serializable;

/**
 * @author throwable
 * @version v1
 * @description
 * @since 2020/9/20 17:17
 */
public class CanalBinLogResult<T> implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    /**
     * 提取的长整型主键
     */
    private Long primaryKey;


    /**
     * binlog事件类型
     */
    private BinLogEventType binLogEventType;

    /**
     * 更变前的数据
     */
    private T beforeData;

    /**
     * 更变后的数据
     */
    private T afterData;

    /**
     * 数据库名称
     */
    private String databaseName;

    /**
     * 表名称
     */
    private String tableName;

    /**
     * sql语句 - 一般是DDL的时候有用
     */
    private String sql;

    /**
     * mysql操作类型
     */
    private OperationType operationType;

    public Long getPrimaryKey() {
        return primaryKey;
    }

    public void setPrimaryKey(Long primaryKey) {
        this.primaryKey = primaryKey;
    }

    public BinLogEventType getBinLogEventType() {
        return binLogEventType;
    }

    public void setBinLogEventType(BinLogEventType binLogEventType) {
        this.binLogEventType = binLogEventType;
    }

    public T getBeforeData() {
        return beforeData;
    }

    public void setBeforeData(T beforeData) {
        this.beforeData = beforeData;
    }

    public T getAfterData() {
        return afterData;
    }

    public void setAfterData(T afterData) {
        this.afterData = afterData;
    }

    public String getDatabaseName() {
        return databaseName;
    }

    public void setDatabaseName(String databaseName) {
        this.databaseName = databaseName;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public OperationType getOperationType() {
        return operationType;
    }

    public void setOperationType(OperationType operationType) {
        this.operationType = operationType;
    }

    @Override
    public String toString() {
        return "CanalBinLogResult{" +
                "primaryKey=" + primaryKey +
                ", binLogEventType=" + binLogEventType +
                ", beforeData=" + beforeData +
                ", afterData=" + afterData +
                ", databaseName='" + databaseName + '\'' +
                ", tableName='" + tableName + '\'' +
                ", sql='" + sql + '\'' +
                ", operationType=" + operationType +
                '}';
    }
}
