package com.qqchen.deploy.backend.workflow.entity;

import com.qqchen.deploy.backend.framework.domain.Entity;
import com.qqchen.deploy.backend.workflow.enums.WorkflowInstanceStatusEnums;
import com.qqchen.deploy.backend.workflow.enums.WorkflowNodeInstanceStatusEnums;
import jakarta.persistence.Column;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 工作流节点实例实体
 */
@Data
@Table(name = "workflow_node_instance")
@jakarta.persistence.Entity
@EqualsAndHashCode(callSuper = true)
public class WorkflowNodeInstance extends Entity<Long> {

    @Column(name = "workflow_definition_id", nullable = false)
    private Long workflowDefinitionId;

    /**
     * 工作流实例ID
     */
    @Column(name = "workflow_instance_id", nullable = false)
    private Long workflowInstanceId;

    @Column(name = "process_instance_id", nullable = false)
    private String processInstanceId;

    @Column(name = "execution_id", nullable = false)
    private String executionId;

    /**
     * 节点ID
     */
    @Column(name = "node_id", nullable = false)
    private String nodeId;

    /**
     * 节点名称
     */
    @Column(name = "node_name", nullable = false)
    private String nodeName;

    /**
     * 节点类型
     */
    @Column(name = "node_type", nullable = false)
    private String nodeType;

    /**
     * 节点状态
     */
    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private WorkflowNodeInstanceStatusEnums status;

    /**
     * 开始时间
     */
    @Column(name = "start_time")
    private LocalDateTime startTime;

    /**
     * 结束时间
     */
    @Column(name = "end_time")
    private LocalDateTime endTime;

    /**
     * 节点变量(JSON)
     */
    @Column(columnDefinition = "TEXT")
    private String variables;

    /**
     * 错误信息
     */
    @Column(name = "error_message", columnDefinition = "TEXT")
    private String errorMessage;
}
