using Hotline.FlowEngine.Notifications;
using Hotline.FlowEngine.WorkflowModules;
using Hotline.KnowledgeBase;
using MediatR;

namespace Hotline.Application.Handlers.FlowEngine;

public class WorkflowTerminalHandler : INotificationHandler<TerminalWorkflowNotify>
{

    private readonly IKnowledgeDomainService _knowledgeDomainService;
    public WorkflowTerminalHandler(IKnowledgeDomainService knowledgeDomainService)
    {
        _knowledgeDomainService = knowledgeDomainService;
    }

    /// <summary>Handles a notification</summary>
    /// <param name="notification">The notification</param>
    /// <param name="cancellationToken">Cancellation token</param>
    public async Task Handle(TerminalWorkflowNotify notification, CancellationToken cancellationToken)
    {
        var workflow = notification.Workflow;

        switch (workflow.ModuleCode)
        {
            case WorkflowModuleConsts.KnowledgeAdd://新增知识库
            case WorkflowModuleConsts.KnowledgeDelete://删除知识库
                await _knowledgeDomainService.TerminateWorkKnowledge(workflow, cancellationToken);
                break;


        }
    }
}