using Hotline.FlowEngine;
using Hotline.FlowEngine.Workflows;
using Hotline.Share.Dtos.Knowledge;
using Hotline.Share.Enums.KnowledgeBase;
using XF.Domain.Entities;

namespace Hotline.KnowledgeBase
{
    public interface IKnowledgeDomainService
    {
        /// <summary>
        /// 知识库-查询详情-增加浏览量
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        Task<Knowledge> KnowledgeInfo(string Id, CancellationToken cancellationToken);

        /// <summary>
        /// 知识库-修改
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<string> KnowledgeUpdate(UpdateKnowledgeDto dto, CancellationToken cancellationToken);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="know"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task KnowledgePvIncreaseAsync(Knowledge know, CancellationToken cancellationToken);

        /// <summary>
        /// 知识审批主表
        /// </summary>
        /// <param name="knowId">知识Id</param>
        /// <param name="eKnowledgeApplyType">申请类型</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<string> AddWorkFlowAsync(string knowId, EKnowledgeApplyType eKnowledgeApplyType, CancellationToken cancellationToken);

        /// <summary>
        /// 修改流程ID
        /// </summary>
        Task UpdateWorkFlowId(string workflowExternalId, string workflowId, List<HandlerGroupItem> handlerUsers, List<HandlerGroupItem> handlerOrgs, List<string> flowedUserIds, List<string> flowedOrgIds, CancellationToken cancellationToken);

        /// <summary>
        /// 修改指派人
        /// </summary>
        /// <param name="assignInfo"></param>
        /// <param name="knowledgeFlowId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task UpdateWorkAssign(FlowAssignInfo assignInfo, string? knowledgeFlowId, CancellationToken cancellationToken);

        /// <summary>
        /// 流程终止，处理知识状态
        /// </summary>
        /// <param name="workflow"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="UserFriendlyException"></exception>
        Task TerminateWorkKnowledge(Workflow workflow, CancellationToken cancellationToken);

        /// <summary>
        /// 流程审批完成，处理知识状态
        /// </summary>
        /// <param name="workflow"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task EndWorkKnowledge(Workflow workflow, CancellationToken cancellationToken);

        /////

        /// <summary>
        /// 知识库-新增
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<Knowledge> AddKnowledgeAsync(AddKnowledgeDto dto, CancellationToken cancellationToken);

        /// <summary>
        /// 插入知识审批数据
        /// </summary>
        Task<KnowledgeApprove> AddKnowledgeApproveAsync(EKnowledgeApproveType knowledgeApproveType, Knowledge kn, string? createOpinion,
            CancellationToken cancellation);

        /// <summary>
        /// 更新
        /// </summary>
        Task<Knowledge> UpdateKnowledgeAsync(UpdateKnowledgeDto dto, CancellationToken cancellation);

        /// <summary>
        /// 下架知识
        /// </summary>
        Task<Knowledge> OffShelfAsync(OffShelfKnowledgeDto dto, CancellationToken cancellation);
    }
}
