Msm.Workflow.Lib.Api.Controllers
1.9.0
dotnet add package Msm.Workflow.Lib.Api.Controllers --version 1.9.0
NuGet\Install-Package Msm.Workflow.Lib.Api.Controllers -Version 1.9.0
<PackageReference Include="Msm.Workflow.Lib.Api.Controllers" Version="1.9.0" />
<PackageVersion Include="Msm.Workflow.Lib.Api.Controllers" Version="1.9.0" />
<PackageReference Include="Msm.Workflow.Lib.Api.Controllers" />
paket add Msm.Workflow.Lib.Api.Controllers --version 1.9.0
#r "nuget: Msm.Workflow.Lib.Api.Controllers, 1.9.0"
#:package Msm.Workflow.Lib.Api.Controllers@1.9.0
#addin nuget:?package=Msm.Workflow.Lib.Api.Controllers&version=1.9.0
#tool nuget:?package=Msm.Workflow.Lib.Api.Controllers&version=1.9.0
Msm.Workflow.Lib.Api.Controllers
Pre-built REST API controllers cho MSM Workflow Engine - cung cấp CRUD endpoints sẵn có.
📦 Installation
<PackageReference Include="Msm.Workflow.Lib.Api.Controllers" Version="1.0.0" />
dotnet add package Msm.Workflow.Lib.Api.Controllers
📋 Overview
Package này cung cấp pre-built API controllers để tích hợp nhanh workflow engine vào ASP.NET Core application. Có thể sử dụng trực tiếp hoặc inherit để customize.
Contents
- WorkflowProcessesController: CRUD operations cho workflow processes
- WorkflowInstancesController: CRUD operations và workflow execution
- WorkflowTriggerController: Trigger workflow instances
- TenantsController: Multi-tenancy management
🎯 Usage
Register Controllers
using Msm.Workflow.Lib.Api.Controllers;
// In Program.cs or Startup.cs
services.AddWorkflowApiControllers();
Use Controllers Directly
Controllers sẽ tự động được map với routes (kebab-case):
WorkflowProcessesController (/api/workflow-processes):
GET /api/workflow-processes- List all processesPOST /api/workflow-processes- Create new processGET /api/workflow-processes/{id}- Get process by IDPUT /api/workflow-processes/{id}- Update processDELETE /api/workflow-processes/{id}- Delete processGET /api/workflow-processes/{processId}/steps- Get process stepsPOST /api/workflow-processes/{processId}/steps- Add step to processPUT /api/workflow-processes/steps/{stepId}- Update stepDELETE /api/workflow-processes/steps/{stepId}- Delete stepPOST /api/workflow-processes/steps/{stepId}/approvers- Add approver to stepPOST /api/workflow-processes/steps/{stepId}/actions- Add action to stepGET /api/workflow-processes/{processId}/transitions- Get transitionsPOST /api/workflow-processes/{processId}/transitions- Create transitionPUT /api/workflow-processes/{processId}/transitions/{transitionId}- Update transitionDELETE /api/workflow-processes/{processId}/transitions/{transitionId}- Delete transition
WorkflowInstancesController (/api/workflow-instances):
POST /api/workflow-instances/submit- Submit workflow instanceGET /api/workflow-instances- List instances (with filters)GET /api/workflow-instances/{id}- Get instance by IDGET /api/workflow-instances/pending/{userId}- Get pending items for userPOST /api/workflow-instances/items/{itemId}/approve- Approve workflow itemPOST /api/workflow-instances/items/{itemId}/reject- Reject workflow itemPOST /api/workflow-instances/{instanceId}/recall- Recall workflow instancePOST /api/workflow-instances/items/{itemId}/delegate- Delegate itemPOST /api/workflow-instances/items/{itemId}/reassign- Reassign itemPOST /api/workflow-instances/{instanceId}/adhoc-steps- Add ad-hoc step
WorkflowTriggerController (/api/workflow):
POST /api/workflow/trigger- Trigger workflow instance
TenantsController (/api/tenants):
GET /api/tenants- List all tenant schemasGET /api/tenants/{tenantKey}/exists- Check if schema existsPOST /api/tenants/{tenantKey}- Create tenant schemaDELETE /api/tenants/{tenantKey}- Delete tenant schema
Inherit and Customize
[ApiController]
[Route("api/[controller]")]
public class MyWorkflowController : BaseWorkflowController
{
public MyWorkflowController(
IWorkflowProcessService processService,
IWorkflowInstanceService instanceService)
: base(processService, instanceService)
{
}
// Add custom endpoints
[HttpPost("custom-action")]
public async Task<IActionResult> CustomAction()
{
// Your custom logic
}
}
Example API Calls
# Create workflow process
POST /api/workflow-processes
Content-Type: application/json
{
"name": "Purchase Order Approval",
"code": "PO_APPROVAL",
"objectType": "PURCHASE_ORDER",
"description": "Workflow for approving purchase orders"
}
# Submit workflow instance
POST /api/workflow-instances/submit
Content-Type: application/json
{
"processId": "guid-here",
"targetRecordId": "po-123",
"targetObjectType": "PURCHASE_ORDER",
"submittedBy": "user123",
"contextDataJson": "{\"amount\": 15000, \"department\": \"IT\"}",
"comments": "Requesting approval"
}
# Approve workflow item
POST /api/workflow-instances/items/{itemId}/approve
Content-Type: application/json
{
"approverId": "user456",
"comments": "Approved"
}
🔗 Dependencies
Msm.Workflow.Lib.Application(required)Microsoft.AspNetCore.App(framework reference)
📚 Related Packages
Msm.Workflow.Lib.Application- Required dependencyMsm.Workflow.Lib.Infrastructure- Required for data accessMsm.Workflow.Lib.Domain- Required for domain entities
🔒 Multi-Tenancy
Controllers hỗ trợ multi-tenancy qua x-tenant header:
# Request với tenant header
curl -H "x-tenant: tenant1" \
-H "Content-Type: application/json" \
http://localhost:5000/api/workflow-processes
📖 Documentation
For more information, see the main README.md and GETTING_STARTED.md.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- MediatR (>= 12.4.1)
- Msm.Workflow.Lib.Application (>= 1.9.0)
-
net8.0
- MediatR (>= 12.4.1)
- Msm.Workflow.Lib.Application (>= 1.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.