Update bulk delete endpoints and request model
Refactor the bulk delete endpoint to include a new primary route while deprecating the old one. Expand the request model to support workflow definition filters and adjust response instantiation for clarity. Update obsolete API route prefix guidance for consistency across modules.
This commit is contained in:
parent
44b61aa24e
commit
a9eb326c5e
|
|
@ -20,7 +20,7 @@ public class HttpActivityOptions
|
|||
/// <summary>
|
||||
/// The prefix used for API routes.
|
||||
/// </summary>
|
||||
[Obsolete("Use ElsaApiOptions from Elsa.Workflows.Api instead.")]
|
||||
[Obsolete("Use ApiEndpointOptions from Elsa.Workflows.Api instead.")]
|
||||
public string ApiRoutePrefix { get; set; } = "elsa/api";
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -10,15 +10,23 @@ internal class BulkDelete(IWorkflowInstanceManager store) : ElsaEndpoint<Request
|
|||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/bulk-actions/delete/workflow-instances/by-id");
|
||||
Post(
|
||||
"/bulk-actions/delete/workflow-instances",
|
||||
"/bulk-actions/delete/workflow-instances/by-id" // Deprecated route.
|
||||
);
|
||||
ConfigurePermissions("delete:workflow-instances");
|
||||
}
|
||||
|
||||
public override async Task<Response> ExecuteAsync(Request request, CancellationToken cancellationToken)
|
||||
{
|
||||
var filter = new WorkflowInstanceFilter { Ids = request.Ids };
|
||||
var filter = new WorkflowInstanceFilter
|
||||
{
|
||||
Ids = request.Ids,
|
||||
DefinitionId = request.WorkflowDefinitionId,
|
||||
DefinitionIds = request.WorkflowDefinitionIds,
|
||||
};
|
||||
var count = await store.BulkDeleteAsync(filter, cancellationToken);
|
||||
|
||||
return new Response(count);
|
||||
return new(count);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,9 @@ namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.BulkDelete;
|
|||
|
||||
internal class Request
|
||||
{
|
||||
public ICollection<string> Ids { get; set; } = default!;
|
||||
public ICollection<string>? Ids { get; set; }
|
||||
public string? WorkflowDefinitionId { get; set; }
|
||||
public ICollection<string>? WorkflowDefinitionIds { get; set; }
|
||||
}
|
||||
|
||||
internal class Response(long deletedCount)
|
||||
|
|
|
|||
Loading…
Reference in a new issue