package com.gzzm.lobster.artifact;

import com.gzzm.lobster.common.ArtifactStatus;
import com.gzzm.lobster.common.ArtifactType;
import net.cyan.thunwind.annotation.ColumnDescription;
import net.cyan.thunwind.annotation.Entity;
import net.cyan.thunwind.annotation.Index;

import java.util.Date;

/**
 * Artifact —— thread 连续性的关键对象 / Central object of thread continuity.
 *
 * <p>内容本体通过 {@code contentRef} 指向服务器端文件存储，
 * 不直接存在 MySQL TEXT/BLOB 列里。路径规范：
 * {@code artifact/{yyyy}/{MM}/{dd}/{userId}/{uuid}.{ext}}
 *
 * <p>Body is addressed by {@code contentRef} to a server-side file store.
 * Path format: {@code artifact/{yyyy}/{MM}/{dd}/{userId}/{uuid}.{ext}}.
 */
@Entity(table = "AI_ARTIFACT", keys = "artifactId")
public class Artifact {

    @ColumnDescription(type = "varchar(40)")
    private String artifactId;

    @Index
    @ColumnDescription(type = "varchar(40)", nullable = false)
    private String threadId;

    @ColumnDescription(type = "varchar(40)", nullable = false)
    private String workspaceId;

    @Index
    @ColumnDescription(type = "varchar(40)", nullable = false)
    private String userId;

    private ArtifactType artifactType;

    @ColumnDescription(type = "varchar(300)")
    private String title;

    /** 服务器端文件存储路径引用 / Server-side file store path ref */
    @ColumnDescription(type = "varchar(400)")
    private String contentRef;

    @ColumnDescription(type = "number(18)")
    private Long contentSize;

    /** txt / docx / html / json 等 / extension */
    @ColumnDescription(type = "varchar(20)")
    private String format;

    /** 源消息 id（可空）/ Source assistant message id. */
    @ColumnDescription(type = "varchar(40)")
    private String sourceMessageId;

    /** 源 run id（可空）/ Source run id. */
    @ColumnDescription(type = "varchar(40)")
    private String sourceRunId;

    /** 工作副本所基于的 OA 源文件 id / Source OA file id for working copy. */
    @ColumnDescription(type = "varchar(80)")
    private String sourceOaFileId;

    @ColumnDescription(type = "number(6)", defaultValue = "1")
    private Integer version;

    private ArtifactStatus status;

    private Date createTime;
    private Date updateTime;

    public Artifact() {}

    public String getArtifactId() { return artifactId; }
    public void setArtifactId(String artifactId) { this.artifactId = artifactId; }
    public String getThreadId() { return threadId; }
    public void setThreadId(String threadId) { this.threadId = threadId; }
    public String getWorkspaceId() { return workspaceId; }
    public void setWorkspaceId(String workspaceId) { this.workspaceId = workspaceId; }
    public String getUserId() { return userId; }
    public void setUserId(String userId) { this.userId = userId; }
    public ArtifactType getArtifactType() { return artifactType; }
    public void setArtifactType(ArtifactType artifactType) { this.artifactType = artifactType; }
    public String getTitle() { return title; }
    public void setTitle(String title) { this.title = title; }
    public String getContentRef() { return contentRef; }
    public void setContentRef(String contentRef) { this.contentRef = contentRef; }
    public Long getContentSize() { return contentSize; }
    public void setContentSize(Long contentSize) { this.contentSize = contentSize; }
    public String getFormat() { return format; }
    public void setFormat(String format) { this.format = format; }
    public String getSourceMessageId() { return sourceMessageId; }
    public void setSourceMessageId(String sourceMessageId) { this.sourceMessageId = sourceMessageId; }
    public String getSourceRunId() { return sourceRunId; }
    public void setSourceRunId(String sourceRunId) { this.sourceRunId = sourceRunId; }
    public String getSourceOaFileId() { return sourceOaFileId; }
    public void setSourceOaFileId(String sourceOaFileId) { this.sourceOaFileId = sourceOaFileId; }
    public Integer getVersion() { return version; }
    public void setVersion(Integer version) { this.version = version; }
    public ArtifactStatus getStatus() { return status; }
    public void setStatus(ArtifactStatus status) { this.status = status; }
    public Date getCreateTime() { return createTime; }
    public void setCreateTime(Date createTime) { this.createTime = createTime; }
    public Date getUpdateTime() { return updateTime; }
    public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; }
}
