Skip to content
bitzorcas
EN

Reference

Tickets module

Support ticket system — lifecycle management with state transitions, agent assignment, comments with file attachments, role-based authorization, and audit trail.

Last updated

The Tickets module provides a full support ticket system with lifecycle management, agent assignment, threaded comments, file attachments, and role-based access control.

Endpoints

EndpointMethodDescription
/api/ticketsPOSTOpen new ticket
/api/ticketsGETList tickets (paginated, filterable)
/api/tickets/{id}GETGet ticket details
/api/tickets/{id}/assignPOSTAssign to agent
/api/tickets/{id}/commentsPOSTAdd comment
/api/tickets/{id}/filesPOSTAttach file
/api/tickets/{id}/statusPATCHChange status

Architecture

TicketEndpoints (Minimal API)
TicketService
├── ITicketRepository → SqlSugarTicketRepository
├── TicketAuthorizationService (role + data scope checks)
├── ITicketAttachmentAccessService → FileAssetTicketAttachmentAccessService
├── ITicketEventPublisher → NullTicketEventPublisher
└── ITicketAuditSink → NullTicketAuditSink

Ticket entity

public class TicketEntity : TenantSoftDeleteEntityBase
{
public string Title { get; set; }
public string Description { get; set; }
public string Status { get; set; } // Open, InProgress, Resolved, Closed
public string Priority { get; set; } // Low, Normal, High, Critical
public string? AssignedToId { get; set; }
public string CreatedById { get; set; }
}

Lifecycle states

Open → InProgress → Resolved → Closed
↑ │ │
└───────┘ │
(reopened) │
Closed (terminal)

Authorization model

TicketAuthorizationService enforces role-based access:

RolePermissions
CreatorView own, add comments, reopen
AgentView assigned, change status, assign
AdminFull access across tenant
SystemCross-tenant read (audit)
public static class TicketPermissions
{
public const string TicketCreate = "ticket.create";
public const string TicketView = "ticket.view";
public const string TicketAssign = "ticket.assign";
public const string TicketStatusChange = "ticket.status.change";
public const string TicketComment = "ticket.comment";
public const string TicketManage = "ticket.manage";
}

Ticket roles

public static class TicketRoleNames
{
public const string Creator = "ticket.creator";
public const string Agent = "ticket.agent";
public const string Admin = "ticket.admin";
}

Pagination and filtering

public class TicketPage
{
public IReadOnlyList<Ticket> Items { get; }
public int TotalCount { get; }
public bool HasMore { get; }
}
public class TicketQuery
{
public string? Status { get; set; }
public string? Priority { get; set; }
public string? AssignedToId { get; set; }
public string? Search { get; set; }
public int Page { get; set; }
public int PageSize { get; set; }
}

See also