Auto approve (#21)
Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz> Reviewed-on: http://git.tnsu.kz/gorbenko.pavel/tnsu-approval-route/pulls/21
This commit was merged in pull request #21.
This commit is contained in:
@@ -2,6 +2,9 @@ using Tnsu.ApprovalRoute.Domain.Enums;
|
||||
|
||||
namespace Tnsu.ApprovalRoute.Application.TemplateRouteSteps;
|
||||
|
||||
// AutoApprove — «согласовать шаг автоматически по истечении SLA». Обычный bool,
|
||||
// а не три состояния: наследовать его неоткуда (см. TemplateRouteStep.AutoApprove).
|
||||
//
|
||||
// SlaHours/AskOverdueReason у шага перекрывают одноимённые поля типа заявки.
|
||||
// null — «не задано, наследовать», поэтому оба поля nullable и необязательны
|
||||
// (0 часов и false — это осознанный выбор, а не «пусто»). Добавлены в конец
|
||||
@@ -24,7 +27,8 @@ public sealed record TemplateRouteStepDto(
|
||||
ConditionsLogic ConditionsLogic,
|
||||
string? Warning = null,
|
||||
int? SlaHours = null,
|
||||
bool? AskOverdueReason = null);
|
||||
bool? AskOverdueReason = null,
|
||||
bool AutoApprove = false);
|
||||
|
||||
public sealed record CreateTemplateRouteStepRequest(
|
||||
int OrderNo,
|
||||
@@ -37,7 +41,8 @@ public sealed record CreateTemplateRouteStepRequest(
|
||||
IReadOnlyList<RouteStepConditionDto>? Conditions,
|
||||
ConditionsLogic ConditionsLogic,
|
||||
int? SlaHours = null,
|
||||
bool? AskOverdueReason = null);
|
||||
bool? AskOverdueReason = null,
|
||||
bool AutoApprove = false);
|
||||
|
||||
public sealed record UpdateTemplateRouteStepRequest(
|
||||
int OrderNo,
|
||||
@@ -50,7 +55,8 @@ public sealed record UpdateTemplateRouteStepRequest(
|
||||
IReadOnlyList<RouteStepConditionDto>? Conditions,
|
||||
ConditionsLogic ConditionsLogic,
|
||||
int? SlaHours = null,
|
||||
bool? AskOverdueReason = null);
|
||||
bool? AskOverdueReason = null,
|
||||
bool AutoApprove = false);
|
||||
|
||||
/// <summary>
|
||||
/// Как и остальные поля PATCH, Conditions=null означает «не менять». Отличить
|
||||
@@ -68,4 +74,5 @@ public sealed record PatchTemplateRouteStepRequest(
|
||||
IReadOnlyList<RouteStepConditionDto>? Conditions,
|
||||
ConditionsLogic? ConditionsLogic = null,
|
||||
int? SlaHours = null,
|
||||
bool? AskOverdueReason = null);
|
||||
bool? AskOverdueReason = null,
|
||||
bool? AutoApprove = null);
|
||||
|
||||
+5
-2
@@ -97,7 +97,8 @@ public sealed class TemplateRouteStepService(
|
||||
ConditionsLogic = r.ConditionsLogic,
|
||||
Conditions = ToEntities(r.Conditions),
|
||||
SlaHours = r.SlaHours,
|
||||
AskOverdueReason = r.AskOverdueReason
|
||||
AskOverdueReason = r.AskOverdueReason,
|
||||
AutoApprove = r.AutoApprove
|
||||
};
|
||||
db.TemplateRouteSteps.Add(entity);
|
||||
await db.SaveChangesAsync(cancellationToken);
|
||||
@@ -153,6 +154,7 @@ public sealed class TemplateRouteStepService(
|
||||
ReplaceConditions(entity, r.Conditions);
|
||||
entity.SlaHours = r.SlaHours;
|
||||
entity.AskOverdueReason = r.AskOverdueReason;
|
||||
entity.AutoApprove = r.AutoApprove;
|
||||
await db.SaveChangesAsync(cancellationToken);
|
||||
logger.LogInformation(
|
||||
"Шаг {StepId} маршрута {RouteId} изменён пользователем {Author}", entity.Id, route.Id, currentUser.Email);
|
||||
@@ -224,6 +226,7 @@ public sealed class TemplateRouteStepService(
|
||||
// наследованию SLA от типа заявки можно через PUT.
|
||||
entity.SlaHours = r.SlaHours ?? entity.SlaHours;
|
||||
entity.AskOverdueReason = r.AskOverdueReason ?? entity.AskOverdueReason;
|
||||
entity.AutoApprove = r.AutoApprove ?? entity.AutoApprove;
|
||||
await db.SaveChangesAsync(cancellationToken);
|
||||
logger.LogInformation(
|
||||
"Шаг {StepId} маршрута {RouteId} изменён пользователем {Author}", entity.Id, route.Id, currentUser.Email);
|
||||
@@ -366,5 +369,5 @@ public sealed class TemplateRouteStepService(
|
||||
|
||||
private static TemplateRouteStepDto ToDto(TemplateRouteStep e) => new(
|
||||
e.Id, e.OrderNo, e.ExecutorEmail, e.Position, e.ProjectRole, e.HeadType, e.Status, e.RouteId, e.AllowReassignToOtherApprovers,
|
||||
ToDtos(e.Conditions), e.ConditionsLogic, null, e.SlaHours, e.AskOverdueReason);
|
||||
ToDtos(e.Conditions), e.ConditionsLogic, null, e.SlaHours, e.AskOverdueReason, e.AutoApprove);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user