using Hotline.FlowEngine.Workflows;
using Hotline.Repository.SqlSugar.DataPermissions;
using SqlSugar;
using XF.Domain.Dependency;

namespace Hotline.Repository.SqlSugar.FlowEngine;

public class WorkflowRepository : BaseRepository<Workflow>, IWorkflowRepository, IScopeDependency
{
    public WorkflowRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider) : base(uow, dataPermissionFilterBuilder, serviceProvider)
    {
    }

    public async Task UpdateNavigateAsync(Workflow workflow, CancellationToken cancellationToken)
    {
        await Db.UpdateNav(workflow)
            .Include(d => d.Traces)
            .Include(d => d.Steps)
            .ExecuteCommandAsync();
    }
}