web: detail závady s průběhem řešení, komentáři, přílohami a akcemi
This commit is contained in:
1 parent
5d8b71c435
commit
ac3ec6aff7
14 files changed
+1006
-56
No files matched your search
@@ -67,8 +67,105 @@ public sealed record CreateIssueRequest(string Title, string Description, int Ca
|
||||
/// <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>
|
||||
/// Detail závady. <c>AllowedActions</c> říká, co smí aktuální uživatel udělat (kódy z <see cref="IssueActions"/>),
|
||||
/// <c>RowVersion</c> se posílá zpět s každou úpravou a změnou stavu (optimistické zamykání, jinak 409).
|
||||
/// </summary>
|
||||
public sealed record IssueDetail(
|
||||
int Id, string Title, string Description, int CategoryId, int? BuildingId, string? LocationDetail, string Status,
|
||||
string Priority, int ReporterId, int? AssigneeId, DateTimeOffset CreatedAt, int RowVersion,
|
||||
IReadOnlyList<string> AllowedActions, IReadOnlyList<AttachmentDto> Attachments)
|
||||
{
|
||||
public bool Can(string action) => AllowedActions?.Contains(action) == true;
|
||||
}
|
||||
|
||||
public sealed record AttachmentDto(int Id, string FileName, string ContentType, long SizeBytes, DateTimeOffset CreatedAt);
|
||||
|
||||
/// <summary>Událost na časové ose závady – vytvoření, přiřazení, změna stavu i komentář (FR-17).</summary>
|
||||
public sealed record IssueEventDto(
|
||||
int Id, string EventType, string? FromStatus, string ToStatus, int ActorId, string ActorName, string? Note,
|
||||
DateTimeOffset OccurredAt);
|
||||
|
||||
/// <summary>Možný řešitel (jen pro vedení) s počtem jeho otevřených závad (FR-13).</summary>
|
||||
public sealed record AssignableUserDto(int Id, string FirstName, string LastName, string Role, int OpenIssues)
|
||||
{
|
||||
public string FullName => $"{FirstName} {LastName}";
|
||||
}
|
||||
|
||||
public sealed record EditIssueRequest(
|
||||
string Title, string Description, int CategoryId, int? BuildingId, string? LocationDetail, int RowVersion);
|
||||
|
||||
public sealed record AssignIssueRequest(int AssigneeId, string? Priority, int RowVersion);
|
||||
|
||||
public sealed record CommentRequest(string Text);
|
||||
|
||||
/// <summary>Stažená příloha. Proud čte přímo odpověď API a uvolní se spolu s ní.</summary>
|
||||
public sealed class ApiFile(Stream content, string contentType, string fileName, IDisposable response) : IDisposable
|
||||
{
|
||||
public Stream Content { get; } = content;
|
||||
public string ContentType { get; } = contentType;
|
||||
public string FileName { get; } = fileName;
|
||||
|
||||
public void Dispose() => response.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>Kódy akcí z <c>allowedActions</c> v detailu závady.</summary>
|
||||
public static class IssueActions
|
||||
{
|
||||
public const string Edit = "EDIT";
|
||||
public const string Assign = "ASSIGN";
|
||||
public const string StartWork = "START_WORK";
|
||||
public const string SubmitForVerification = "SUBMIT_FOR_VERIFICATION";
|
||||
public const string Confirm = "CONFIRM";
|
||||
public const string Reopen = "REOPEN";
|
||||
public const string Reject = "REJECT";
|
||||
public const string Comment = "COMMENT";
|
||||
public const string AddAttachments = "ADD_ATTACHMENTS";
|
||||
|
||||
/// <summary>Změny stavu v pořadí, v jakém je web nabízí (T4 – T9).</summary>
|
||||
public static readonly IReadOnlyList<string> Transitions = [StartWork, SubmitForVerification, Confirm, Reopen, Reject];
|
||||
|
||||
/// <summary>Akční endpoint <c>POST /issues/{id}/…</c> pro změnu stavu.</summary>
|
||||
public static string? TransitionPath(string? action) => action switch
|
||||
{
|
||||
StartWork => "start",
|
||||
SubmitForVerification => "submit-for-verification",
|
||||
Confirm => "confirm",
|
||||
Reopen => "reopen",
|
||||
Reject => "reject",
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// <summary>Zamítnutí a znovuotevření vyžadují důvod (T7 – T9).</summary>
|
||||
public static bool RequiresReason(string action) => action is Reopen or Reject;
|
||||
|
||||
/// <summary>Předání k ověření má nepovinnou poznámku (T5).</summary>
|
||||
public static bool AcceptsText(string action) => action is SubmitForVerification || RequiresReason(action);
|
||||
|
||||
/// <summary>Texty tlačítek – stejné jako v mobilní aplikaci.</summary>
|
||||
public static string Label(string action) => action switch
|
||||
{
|
||||
StartWork => "Zahájit řešení",
|
||||
SubmitForVerification => "Předat k ověření",
|
||||
Confirm => "Potvrdit vyřešení",
|
||||
Reopen => "Znovu otevřít závadu",
|
||||
Reject => "Zamítnout závadu",
|
||||
_ => action,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Priorita závady; názvy jako v mobilní aplikaci.</summary>
|
||||
public static class IssuePriorities
|
||||
{
|
||||
public static readonly IReadOnlyList<string> All = ["LOW", "NORMAL", "HIGH"];
|
||||
|
||||
public static string Label(string? priority) => priority switch
|
||||
{
|
||||
"LOW" => "Nízká",
|
||||
"HIGH" => "Vysoká",
|
||||
_ => "Běžná",
|
||||
};
|
||||
}
|
||||
|
||||
/// <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);
|
||||
Reference in new issue
Block a user