2026-12-02 00:26:42 +01:00
|
|
|
|
namespace Helpdesk.Web.Api;
|
|
|
|
|
|
|
|
|
|
|
|
// Kontrakt REST API /api/v1 tak, jak ho web používá. Web je tenký klient a na projekty
|
|
|
|
|
|
// backendu nemá referenci – DTO jsou zde zrcadlem dokumentace ve Swaggeru.
|
|
|
|
|
|
|
|
|
|
|
|
public sealed record UserDto(
|
|
|
|
|
|
int Id,
|
|
|
|
|
|
string Email,
|
|
|
|
|
|
string FirstName,
|
|
|
|
|
|
string LastName,
|
|
|
|
|
|
string? Phone,
|
|
|
|
|
|
string Role,
|
|
|
|
|
|
bool EmailNotificationsEnabled)
|
|
|
|
|
|
{
|
|
|
|
|
|
public string FullName => $"{FirstName} {LastName}";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public sealed record AuthResponse(
|
|
|
|
|
|
string AccessToken,
|
|
|
|
|
|
DateTimeOffset AccessTokenExpiresAt,
|
|
|
|
|
|
string RefreshToken,
|
|
|
|
|
|
DateTimeOffset RefreshTokenExpiresAt,
|
|
|
|
|
|
UserDto User)
|
|
|
|
|
|
{
|
|
|
|
|
|
public TokenSet Tokens => new(AccessToken, AccessTokenExpiresAt, RefreshToken, RefreshTokenExpiresAt);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Pár tokenů uložený v autentizační cookie webu.</summary>
|
|
|
|
|
|
public sealed record TokenSet(
|
|
|
|
|
|
string AccessToken,
|
|
|
|
|
|
DateTimeOffset AccessTokenExpiresAt,
|
|
|
|
|
|
string RefreshToken,
|
|
|
|
|
|
DateTimeOffset RefreshTokenExpiresAt);
|
|
|
|
|
|
|
|
|
|
|
|
public sealed record LoginRequest(string Email, string Password);
|
|
|
|
|
|
|
|
|
|
|
|
public sealed record RegisterRequest(string Email, string Password, string FirstName, string LastName);
|
|
|
|
|
|
|
|
|
|
|
|
public sealed record RefreshTokenRequest(string RefreshToken);
|
|
|
|
|
|
|
|
|
|
|
|
public sealed record EmailTokenRequest(string Token);
|
|
|
|
|
|
|
|
|
|
|
|
public sealed record ForgotPasswordRequest(string Email);
|
|
|
|
|
|
|
|
|
|
|
|
public sealed record ResetPasswordRequest(string Token, string NewPassword);
|
|
|
|
|
|
|
|
|
|
|
|
public sealed record UpdateProfileRequest(string FirstName, string LastName, string? Phone, bool EmailNotificationsEnabled);
|
2026-12-02 13:50:01 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>Stránkovaný seznam z API: <c>{ items, totalCount, page, pageSize }</c>.</summary>
|
|
|
|
|
|
public sealed record PagedResult<T>(IReadOnlyList<T> Items, int TotalCount, int Page, int PageSize)
|
|
|
|
|
|
{
|
|
|
|
|
|
public int PageCount => PageSize <= 0 ? 0 : (int)Math.Ceiling(TotalCount / (double)PageSize);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public sealed record CategoryDto(int Id, string Name, string? Description, bool IsActive);
|
|
|
|
|
|
|
|
|
|
|
|
public sealed record BuildingDto(int Id, string Code, string Name, string? Address, bool IsActive);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Závada v seznamu. Kategorie a budova jsou jen ID – názvy doplňuje web z číselníků.</summary>
|
|
|
|
|
|
public sealed record IssueSummary(
|
|
|
|
|
|
int Id, string Title, int CategoryId, int? BuildingId, string? LocationDetail, string Status,
|
|
|
|
|
|
string Priority, int ReporterId, int? AssigneeId, DateTimeOffset CreatedAt);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Filtry <c>GET /api/v1/issues</c>; prázdné hodnoty se do dotazu neposílají.</summary>
|
|
|
|
|
|
public sealed record IssueListQuery(string? Status = null, bool Mine = false, string Sort = "newest", int Page = 1, int PageSize = 20);
|