Název, kategorie, budova, upřesnění místa, popis a až 5 příloh po 10 MB (JPG, PNG, HEIC, PDF, DOCX). Přílohy jdou do API v jednom multipart požadavku spolu s hlášením. Typ, velikost a počet souborů kontroluje už web, obsah souboru ověřuje API. Tlačítko Nahlásit závadu v menu a v seznamu, delší časový limit volání API kvůli nahrávání. Unit testy příloh, místa v seznamu a odeslání formuláře. Refs #23
75 lines
3.1 KiB
C#
75 lines
3.1 KiB
C#
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>Nové hlášení. Přílohy jdou ve stejném požadavku (multipart, pole <c>files</c>).</summary>
|
||
public sealed record CreateIssueRequest(string Title, string Description, int CategoryId, int? BuildingId, string? LocationDetail);
|
||
|
||
/// <summary>Soubor přeposílaný z formuláře webu do API.</summary>
|
||
public sealed record UploadFile(string FileName, string ContentType, Func<Stream> OpenRead);
|
||
|
||
/// <summary>Detail závady (zatím jen pole, která web používá).</summary>
|
||
public sealed record IssueDetail(int Id, string Title, string Status, int RowVersion, IReadOnlyList<string> AllowedActions);
|
||
|
||
/// <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);
|