Files
NTBug/web/Helpdesk.Web/Api/ApiModels.cs
T
PatTheEvil 2fe939ba5c web: seznam Moje hlášení
Závady nahlášené přihlášeným uživatelem od nejnovějších: filtr podle stavu,
stránkování, štítky stavů, kategorie a místo z číselníků a čas v českém
pásmu. Položka v menu a site.js pro automatické odeslání filtru (bez
inline skriptů kvůli CSP).

Refs #22
2026-12-02 13:50:01 +01:00

66 lines
2.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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);
/// <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);