work-flow/src/Workflow.Api/Endpoints/WorkflowInstance/WithdrawWorkflowInstanceEndpoint.cs
向宁 d9cf703615 fix: StartWorkflowInstance 调用 ProcessEngine 自动传播 Token
移除手动创建 Token 的代码,改为调用 processEngine.StartAsync(instance)
自动从 Start 节点传播 Token 到后续节点。
更新测试以注入 ProcessEngine 依赖。
2026-05-20 20:44:46 +08:00

28 lines
827 B
C#

using FastEndpoints;
using MediatR;
using Workflow.Application.Features.WorkflowInstances.Commands;
using Workflow.Domain.Common;
namespace Workflow.Api.Endpoints.WorkflowInstance;
public class WithdrawWorkflowInstanceEndpoint(IMediator mediator, ICurrentUserContext userContext) : EndpointWithoutRequest
{
public override void Configure()
{
Post("/workflow-instances/{Id}/withdraw");
AllowAnonymous();
Summary(s =>
{
s.Summary = "Withdraw a workflow instance (initiator only)";
});
}
public override async Task HandleAsync(CancellationToken ct)
{
var id = Route<Guid>("Id");
var userId = userContext.GetUserId();
await mediator.Send(new WithdrawWorkflowInstanceCommand(id, userId), ct);
await Send.OkAsync(ct);
}
}