feat: add Logs
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
using AutoMapper;
|
||||
using MediatR;
|
||||
using mws.backend.dotnet.application.Audit;
|
||||
using mws.backend.dotnet.application.Common;
|
||||
using mws.backend.dotnet.domain.Roles;
|
||||
|
||||
namespace mws.backend.dotnet.application.Permissions;
|
||||
|
||||
public record CreateRoleCommand(SaveRoleRequest Request) : IRequest<RoleDto>;
|
||||
public record CreateRoleCommand(SaveRoleRequest Request) : IRequest<RoleDto>, IAuditableRequest
|
||||
{
|
||||
public string Action => "Role.Create";
|
||||
public string EntityType => "Role";
|
||||
public string? EntityName => Request.Name;
|
||||
}
|
||||
|
||||
public class CreateRoleHandler(IUnitOfWork uow, IMapper mapper) : IRequestHandler<CreateRoleCommand, RoleDto>
|
||||
{
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
using MediatR;
|
||||
using mws.backend.dotnet.application.Audit;
|
||||
using mws.backend.dotnet.application.Common;
|
||||
|
||||
namespace mws.backend.dotnet.application.Permissions;
|
||||
|
||||
public record DeleteRoleCommand(Guid Id) : IRequest;
|
||||
public record DeleteRoleCommand(Guid Id) : IRequest, IAuditableRequest
|
||||
{
|
||||
public string Action => "Role.Delete";
|
||||
public string EntityType => "Role";
|
||||
public Guid? EntityId => Id;
|
||||
}
|
||||
|
||||
public class DeleteRoleHandler(IUnitOfWork uow) : IRequestHandler<DeleteRoleCommand>
|
||||
public class DeleteRoleHandler(IUnitOfWork uow, IAuditContext auditContext) : IRequestHandler<DeleteRoleCommand>
|
||||
{
|
||||
public async Task Handle(DeleteRoleCommand command, CancellationToken ct)
|
||||
{
|
||||
@@ -24,5 +30,7 @@ public class DeleteRoleHandler(IUnitOfWork uow) : IRequestHandler<DeleteRoleComm
|
||||
|
||||
uow.Roles.Remove(role);
|
||||
await uow.SaveChangesAsync(ct);
|
||||
|
||||
auditContext.EntityName = role.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
using AutoMapper;
|
||||
using MediatR;
|
||||
using mws.backend.dotnet.application.Audit;
|
||||
using mws.backend.dotnet.application.Common;
|
||||
|
||||
namespace mws.backend.dotnet.application.Permissions;
|
||||
|
||||
public record UpdateRoleCommand(Guid Id, SaveRoleRequest Request) : IRequest<RoleDto>;
|
||||
public record UpdateRoleCommand(Guid Id, SaveRoleRequest Request) : IRequest<RoleDto>, IAuditableRequest
|
||||
{
|
||||
public string Action => "Role.Update";
|
||||
public string EntityType => "Role";
|
||||
public Guid? EntityId => Id;
|
||||
public string? EntityName => Request.Name;
|
||||
}
|
||||
|
||||
public class UpdateRoleHandler(IUnitOfWork uow, IMapper mapper) : IRequestHandler<UpdateRoleCommand, RoleDto>
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using mws.backend.dotnet.application.Audit;
|
||||
|
||||
namespace mws.backend.dotnet.application.Permissions;
|
||||
|
||||
public enum PermissionAction
|
||||
@@ -28,9 +30,10 @@ public class PermissionEntryDto
|
||||
public bool CanDelete { get; set; }
|
||||
}
|
||||
|
||||
public class RoleDto
|
||||
public class RoleDto : IHasEntityId
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid EntityId => Id;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public bool IsSystem { get; set; }
|
||||
public List<PermissionEntryDto> Permissions { get; set; } = [];
|
||||
|
||||
@@ -13,6 +13,8 @@ public static class ScreenCatalog
|
||||
new("users", "Users", "/users"),
|
||||
new("permissions", "Permissions", "/settings/permission"),
|
||||
new("masterdata", "Master Data", "/settings/masterdata"),
|
||||
new("actionlogs", "Action Logs", "/settings/actionlogs"),
|
||||
new("loginlogs", "Login Logs", "/settings/loginlogs"),
|
||||
];
|
||||
|
||||
public static readonly IReadOnlySet<string> Keys = Screens.Select(s => s.Key).ToHashSet();
|
||||
|
||||
Reference in New Issue
Block a user