добавлено логгирование
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Globalization;
|
||||
using FluentResults;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Tnsu.ApprovalRoute.Application.Common.Errors;
|
||||
using Tnsu.ApprovalRoute.Application.Common.Interfaces;
|
||||
@@ -15,7 +16,8 @@ public sealed class TemplateRouteService(
|
||||
ApprovalRouteDbContext db,
|
||||
ITnsuPortalClient portalClient,
|
||||
ICurrentUser currentUser,
|
||||
IOptions<TnsuPortalOptions> portalOptions)
|
||||
IOptions<TnsuPortalOptions> portalOptions,
|
||||
ILogger<TemplateRouteService> logger)
|
||||
{
|
||||
public async Task<Result<IReadOnlyList<TemplateRouteDto>>> ListAsync(int? requestTypeId, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -61,6 +63,7 @@ public sealed class TemplateRouteService(
|
||||
};
|
||||
db.TemplateRoutes.Add(entity);
|
||||
await db.SaveChangesAsync(cancellationToken);
|
||||
logger.LogInformation("Маршрут {RouteId} создан пользователем {Author}", entity.Id, currentUser.Email);
|
||||
|
||||
return Result.Ok(ToDto(entity));
|
||||
}
|
||||
@@ -81,6 +84,7 @@ public sealed class TemplateRouteService(
|
||||
entity.ByProject = r.ByProject;
|
||||
entity.RequiresControl = r.RequiresControl;
|
||||
await db.SaveChangesAsync(cancellationToken);
|
||||
logger.LogInformation("Маршрут {RouteId} изменён пользователем {Author}", entity.Id, currentUser.Email);
|
||||
|
||||
return Result.Ok(ToDto(entity));
|
||||
}
|
||||
@@ -105,6 +109,7 @@ public sealed class TemplateRouteService(
|
||||
entity.ByProject = byProject;
|
||||
entity.RequiresControl = r.RequiresControl ?? entity.RequiresControl;
|
||||
await db.SaveChangesAsync(cancellationToken);
|
||||
logger.LogInformation("Маршрут {RouteId} изменён пользователем {Author}", entity.Id, currentUser.Email);
|
||||
|
||||
return Result.Ok(ToDto(entity));
|
||||
}
|
||||
@@ -117,6 +122,7 @@ public sealed class TemplateRouteService(
|
||||
|
||||
db.TemplateRoutes.Remove(entity);
|
||||
await db.SaveChangesAsync(cancellationToken);
|
||||
logger.LogInformation("Маршрут {RouteId} удалён пользователем {Author}", id, currentUser.Email);
|
||||
|
||||
return Result.Ok();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user