package tech.easyflow.ai.entity;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import tech.easyflow.common.entity.DateEntity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 知识库文档导入任务。
 *
 * @author Codex
 * @since 2026-04-14
 */
@Table(value = "tb_document_import_task", comment = "知识库文档导入任务")
public class DocumentImportTask extends DateEntity implements Serializable {

    @Id(keyType = KeyType.Generator, value = "snowFlakeId")
    private BigInteger id;

    @Column(comment = "文档ID")
    private BigInteger documentId;

    @Column(comment = "知识库ID")
    private BigInteger knowledgeId;

    @Column(comment = "任务阶段")
    private String phase;

    @Column(comment = "任务状态")
    private String status;

    @Column(comment = "底层任务ID")
    private String providerTaskId;

    @Column(typeHandler = FastjsonTypeHandler.class, comment = "任务载荷")
    private Map<String, Object> payloadJson;

    @Column(comment = "错误摘要")
    private String errorSummary;

    @Column(comment = "开始时间")
    private Date startedAt;

    @Column(comment = "结束时间")
    private Date finishedAt;

    @Column(comment = "创建时间")
    private Date created;

    @Column(comment = "创建人")
    private BigInteger createdBy;

    @Column(comment = "修改时间")
    private Date modified;

    @Column(comment = "修改人")
    private BigInteger modifiedBy;

    public BigInteger getId() {
        return id;
    }

    public void setId(BigInteger id) {
        this.id = id;
    }

    public BigInteger getDocumentId() {
        return documentId;
    }

    public void setDocumentId(BigInteger documentId) {
        this.documentId = documentId;
    }

    public BigInteger getKnowledgeId() {
        return knowledgeId;
    }

    public void setKnowledgeId(BigInteger knowledgeId) {
        this.knowledgeId = knowledgeId;
    }

    public String getPhase() {
        return phase;
    }

    public void setPhase(String phase) {
        this.phase = phase;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getProviderTaskId() {
        return providerTaskId;
    }

    public void setProviderTaskId(String providerTaskId) {
        this.providerTaskId = providerTaskId;
    }

    public Map<String, Object> getPayloadJson() {
        return payloadJson == null ? new LinkedHashMap<String, Object>() : payloadJson;
    }

    public void setPayloadJson(Map<String, Object> payloadJson) {
        this.payloadJson = payloadJson == null ? new LinkedHashMap<String, Object>() : payloadJson;
    }

    public String getErrorSummary() {
        return errorSummary;
    }

    public void setErrorSummary(String errorSummary) {
        this.errorSummary = errorSummary;
    }

    public Date getStartedAt() {
        return startedAt;
    }

    public void setStartedAt(Date startedAt) {
        this.startedAt = startedAt;
    }

    public Date getFinishedAt() {
        return finishedAt;
    }

    public void setFinishedAt(Date finishedAt) {
        this.finishedAt = finishedAt;
    }

    @Override
    public Date getCreated() {
        return created;
    }

    @Override
    public void setCreated(Date created) {
        this.created = created;
    }

    public BigInteger getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(BigInteger createdBy) {
        this.createdBy = createdBy;
    }

    @Override
    public Date getModified() {
        return modified;
    }

    @Override
    public void setModified(Date modified) {
        this.modified = modified;
    }

    public BigInteger getModifiedBy() {
        return modifiedBy;
    }

    public void setModifiedBy(BigInteger modifiedBy) {
        this.modifiedBy = modifiedBy;
    }
}
