向宁 f49e0ea1e4 feat: Implement workflow and form management endpoints
- Added endpoints for managing form definitions including:
  - GetFormDefinitionById
  - GetFormDefinitionList
  - PublishFormDefinition
  - SubmitFormData
  - UpdateFormDefinition

- Added endpoints for managing workflow definitions including:
  - CreateWorkflowDefinition
  - DeleteWorkflowDefinition
  - DisableWorkflowDefinition
  - GetWorkflowDefinitionById
  - GetWorkflowDefinitionList
  - PublishWorkflowDefinition
  - UpdateWorkflowDefinition

- Added endpoints for managing workflow instances including:
  - GetWorkflowInstanceById
  - GetWorkflowInstanceList
  - MonitorWorkflowInstances
  - ResumeWorkflowInstance
  - StartWorkflowInstance
  - SuspendWorkflowInstance
  - WithdrawWorkflowInstance

- Added endpoints for managing workflow tasks including:
  - ApproveTask
  - DelegateTask
  - GetCcTasks
  - GetHistoryTasks
  - GetOverdueTasks
  - GetPendingTasks
  - GetTaskById
  - RejectTask
  - TransferTask
  - UrgeTask

- Introduced middleware for handling API responses and global exceptions.
- Configured application settings for database connection and JWT authentication.
2026-05-17 22:51:37 +08:00

56 lines
1.8 KiB
C#

using MediatR;
using Microsoft.EntityFrameworkCore;
using Workflow.Application.Common;
using Workflow.Application.Features.WorkflowTasks.DTOs;
using Workflow.Domain.Enums;
using Workflow.Infrastructure.Persistence;
using TaskStatus = Workflow.Domain.Enums.TaskStatus;
namespace Workflow.Application.Features.WorkflowTasks.Queries;
public record GetOverdueTasksQuery(
Guid? UserId,
int PageIndex,
int PageSize
) : IRequest<PagedResult<WorkflowTaskListItemDto>>;
public class GetOverdueTasksQueryHandler(WorkflowDbContext db)
: IRequestHandler<GetOverdueTasksQuery, PagedResult<WorkflowTaskListItemDto>>
{
public async Task<PagedResult<WorkflowTaskListItemDto>> Handle(GetOverdueTasksQuery request, CancellationToken cancellationToken)
{
var query = db.WorkflowTasks
.Where(t => t.Status == TaskStatus.Pending && t.DueAt != null && t.DueAt < DateTime.UtcNow);
if (request.UserId.HasValue)
{
query = query.Where(t => t.AssigneeId == request.UserId.Value);
}
var total = await query.CountAsync(cancellationToken);
var items = await query
.OrderBy(t => t.DueAt)
.Skip((request.PageIndex - 1) * request.PageSize)
.Take(request.PageSize)
.Select(t => new WorkflowTaskListItemDto(
t.Id,
t.InstanceId,
t.TokenId,
t.AssigneeId,
t.Status,
t.Title,
t.CompletedAt
))
.ToListAsync(cancellationToken);
return new PagedResult<WorkflowTaskListItemDto>
{
Items = items,
Total = total,
PageIndex = request.PageIndex,
PageSize = request.PageSize
};
}
}