移除手动创建 Token 的代码,改为调用 processEngine.StartAsync(instance) 自动从 Start 节点传播 Token 到后续节点。 更新测试以注入 ProcessEngine 依赖。
28 lines
827 B
C#
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);
|
|
}
|
|
}
|