ReminderDto: разделить на ApprovalOverdueReminderDto и ProbationEndingReminderDto

Абстрактный базовый класс + два sealed-наследника вместо одного DTO с
опциональными полями под обе категории — так специфичные для каждого
вида напоминания поля не путаются с полями другого вида. Полиморфная
сериализация System.Text.Json ([JsonPolymorphic]/[JsonDerivedType])
нужна, иначе список IReadOnlyList<ReminderDto> сериализовался бы только
по общим полям базового класса.
This commit is contained in:
gorbenko.pavel
2026-08-27 12:31:45 +05:00
parent 874e41990c
commit 5d7503209a
5 changed files with 99 additions and 68 deletions
@@ -203,17 +203,16 @@ public sealed class ReminderService(
var deadline = activatedAt.AddHours(slaHours);
if (deadline >= now) continue;
reminders.Add(new ReminderDto(
reminders.Add(new ApprovalOverdueReminderDto(
row.ApproverEmail!,
(int)Math.Floor((now - deadline).TotalHours),
BuildUrl(type, row, listId),
row.AskOverdueReason ?? type.AskOverdueReason ?? false,
BuildUrl(type, row, listId),
type.Id,
type.Name,
row.TicketId,
row.Status,
uniqueCodes.GetValueOrDefault(row.TicketId),
ReminderCategory.ApprovalOverdue));
uniqueCodes.GetValueOrDefault(row.TicketId)));
}
return reminders;
@@ -417,24 +416,20 @@ public sealed class ReminderService(
return null;
}
return new ReminderDto(
Email: managerEmail,
HoursOverdue: 0,
Url: BuildProbationUrl(type, row, listId),
AskOverdueReason: false,
RequestTypeId: type.Id,
RequestTypeName: type.Name,
RequestId: row.Id,
Status: row.Status,
RequestUniqueCode: row.RequestUniqueCode,
Category: ReminderCategory.ProbationEnding,
return new ProbationEndingReminderDto(
ManagerEmail: managerEmail,
CandidateEmail: candidateEmail,
CandidateName: candidateName,
ProbationPeriod: row.ProbationPeriod,
HireDate: row.HireDate,
HireDate: hireDate,
ProbationEndsAt: probationEndsAt,
DaysUntilProbationEnds: daysLeft);
DaysUntilProbationEnds: daysLeft,
Url: BuildProbationUrl(type, row, listId),
RequestTypeId: type.Id,
RequestTypeName: type.Name,
RequestId: row.Id,
Status: row.Status,
RequestUniqueCode: row.RequestUniqueCode);
}
/// <summary>