package tech.easyflow.agent.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;

/**
 * AgentScope 会话状态实体。
 */
@Table("tb_agent_session")
public class AgentSession extends DateEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id(keyType = KeyType.Generator, value = "snowFlakeId")
    private BigInteger id;
    @Column(tenantId = true)
    private BigInteger tenantId;
    private BigInteger agentId;
    private BigInteger chatSessionId;
    private String runtimeSessionId;
    private String sessionKey;
    @Column(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> stateJson = new LinkedHashMap<>();
    private Long version;
    private Long cacheVersion;
    private Date lastAccessAt;
    private Date expiresAt;
    private Date created;
    private BigInteger createdBy;
    private Date modified;
    private BigInteger modifiedBy;
    private Integer isDeleted;

    public BigInteger getId() { return id; }
    public void setId(BigInteger id) { this.id = id; }
    public BigInteger getTenantId() { return tenantId; }
    public void setTenantId(BigInteger tenantId) { this.tenantId = tenantId; }
    public BigInteger getAgentId() { return agentId; }
    public void setAgentId(BigInteger agentId) { this.agentId = agentId; }
    public BigInteger getChatSessionId() { return chatSessionId; }
    public void setChatSessionId(BigInteger chatSessionId) { this.chatSessionId = chatSessionId; }
    public String getRuntimeSessionId() { return runtimeSessionId; }
    public void setRuntimeSessionId(String runtimeSessionId) { this.runtimeSessionId = runtimeSessionId; }
    public String getSessionKey() { return sessionKey; }
    public void setSessionKey(String sessionKey) { this.sessionKey = sessionKey; }
    public Map<String, Object> getStateJson() { return stateJson; }
    public void setStateJson(Map<String, Object> stateJson) { this.stateJson = stateJson == null ? new LinkedHashMap<>() : stateJson; }
    public Long getVersion() { return version; }
    public void setVersion(Long version) { this.version = version; }
    public Long getCacheVersion() { return cacheVersion; }
    public void setCacheVersion(Long cacheVersion) { this.cacheVersion = cacheVersion; }
    public Date getLastAccessAt() { return lastAccessAt; }
    public void setLastAccessAt(Date lastAccessAt) { this.lastAccessAt = lastAccessAt; }
    public Date getExpiresAt() { return expiresAt; }
    public void setExpiresAt(Date expiresAt) { this.expiresAt = expiresAt; }
    @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; }
    public Integer getIsDeleted() { return isDeleted; }
    public void setIsDeleted(Integer isDeleted) { this.isDeleted = isDeleted; }
}
