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

import com.qqchen.deploy.backend.framework.repository.IBaseRepository;
import com.qqchen.deploy.backend.workflow.dto.WorkflowDefinitionDTO;
import com.qqchen.deploy.backend.workflow.entity.WorkflowDefinition;
import com.qqchen.deploy.backend.workflow.enums.WorkflowDefinitionStatusEnums;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * 工作流定义仓库
 */
@Repository
public interface IWorkflowDefinitionRepository extends IBaseRepository<WorkflowDefinition, Long> {
    /**
     * 根据流程标识和版本查询
     */
    WorkflowDefinition findByKeyAndVersionAndDeletedFalse(String key, Integer version);
    
    /**
     * 检查流程标识是否存在
     */
    boolean existsByKeyAndDeletedFalse(String key);

    Optional<WorkflowDefinition> findByKey(String businessKey);

    Page<WorkflowDefinition> findByStatus(WorkflowDefinitionStatusEnums workflowStatusEnums, Pageable pageable);

    List<WorkflowDefinition> findByStatus(WorkflowDefinitionStatusEnums workflowDefinitionStatusEnums);
}
