package com.fs.company.service;

import com.fs.common.core.domain.AjaxResult;
import com.fs.company.domain.CompanyUser;
import com.fs.company.domain.CompanyWorkflow;
import com.fs.company.domain.CompanyWorkflowNode;
import com.fs.company.domain.CompanyWorkflowNodeType;
import com.fs.company.param.CompanyWorkflowSaveParam;
import com.fs.company.param.CompanyWorkflowUpdateBindWCParam;
import com.fs.company.vo.CompanyWorkflowExportVO;
import com.fs.company.vo.CompanyWorkflowNodeVoiceVo;
import com.fs.company.vo.CompanyWorkflowVO;
import com.fs.company.vo.OptionVO;

import java.util.List;

/**
 * AI工作流Service接口
 *
 * @author fs
 * @date 2026-01-06
 */
public interface ICompanyWorkflowService {

    /**
     * 查询工作流
     */
    CompanyWorkflowVO selectCompanyWorkflowById(Long workflowId);

    /**
     * 查询工作流列表
     */
    List<CompanyWorkflow> selectCompanyWorkflowList(CompanyWorkflow fsAiWorkflow);

    /**
     * 保存工作流(新增或更新)
     */
    Long saveCompanyWorkflow(CompanyWorkflowSaveParam param);

    /**
     * 修改工作流状态
     */
    int updateCompanyWorkflowStatus(Long workflowId, Integer status);

    /**
     * 删除工作流
     */
    int deleteCompanyWorkflowByIds(Long[] workflowIds);

    /**
     * 复制工作流
     */
    Long copyCompanyWorkflow(Long workflowId);

    /**
     * 获取所有启用的节点类型
     */
    List<CompanyWorkflowNodeType> selectAllEnabledNodeTypes();
    /**
     * 导出工作流JSON(包含节点、连接顺序、节点类型)
     */
    CompanyWorkflowExportVO exportWorkflowJson(Long workflowId);

    List<CompanyUser> listCompanyUser();

    /**
     * 根据企业用户ID查询工作流的指定类型节点
     * @param companyUserId 企业用户ID
     * @param nodeTypes 节点类型列表(如: start, end, ai_chat)
     * @return 节点列表
     */
    List<CompanyWorkflowNode> selectWorkflowNodesByCompanyUserId(Long companyUserId, List<String> nodeTypes);

    /**
     * 更新节点的voiceUrl
     * @param nodeId 节点ID
     * @param voiceUrl 语音URL
     * @param companyUserId 企业用户ID(用于校验归属)
     * @return 1成功 0失败 -1节点不存在 -2无权限
     */
    int updateNodeVoiceUrl(Long nodeId, String voiceUrl, Long companyUserId);

    CompanyUser getCompanyUserById(Long id);

    Boolean checkCompanyUserBeUsed(Long companyUserId);

    AjaxResult updateWorkflowBindCompanyUser(CompanyWorkflowUpdateBindWCParam param);

    AjaxResult getBindCompanyUserByWorkflowId(Long workflowId);

    List<CompanyWorkflowNodeVoiceVo> getMyWorkflowNodes(Long companyUserId);

    List<OptionVO> optionList(Long companyId);
}
