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

import com.qqchen.deploy.backend.framework.annotation.LogicDelete;
import com.qqchen.deploy.backend.workflow.dto.definition.workflow.WorkflowDefinitionGraph;
import com.qqchen.deploy.backend.workflow.enums.WorkflowDefinitionStatusEnums;
import com.qqchen.deploy.backend.workflow.entity.converter.WorkflowGraphType;
import com.qqchen.deploy.backend.framework.domain.Entity;
import jakarta.persistence.Column;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;

/**
 * 工作流定义实体
 */
@Data
@Table(name = "workflow_definition")
@jakarta.persistence.Entity
@EqualsAndHashCode(callSuper = true)
@LogicDelete
public class WorkflowDefinition extends Entity<Long> {

    /**
     * 流程名称
     */
    @Column(nullable = false)
    private String name;

    /**
     * 流程标识
     */
    @Column(name = "`key`", nullable = false)
    private String key;

    /**
     * 流程分类ID（外键关联workflow_category）
     */
    @Column(name = "category_id")
    private Long categoryId;

    /**
     * 启动表单ID（外键关联form_definition）
     */
    @Column(name = "form_definition_id")
    private Long formDefinitionId;

    @Column(name = "process_definition_id")
    private String processDefinitionId;

    /**
     * 流程版本
     */
    @Column(name = "flow_version", nullable = false)
    private Integer flowVersion;

    /**
     * BPMN XML内容
     */
    @Column(name = "bpmn_xml", columnDefinition = "TEXT")
    private String bpmnXml;

    /**
     * 流程图数据，包含节点和连线的位置、样式等信息
     */
    @Type(WorkflowGraphType.class)
    @Column(name = "graph", columnDefinition = "json")
    private WorkflowDefinitionGraph graph;


    /**
     * 流程状态
     */
    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private WorkflowDefinitionStatusEnums status;

    /**
     * 流程描述
     */
    @Column(columnDefinition = "TEXT")
    private String description;
}
