feat: add Logs
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using mws.backend.dotnet.application.Audit;
|
||||
using mws.backend.dotnet.application.Common;
|
||||
|
||||
namespace mws.backend.dotnet.api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/audit")]
|
||||
[Authorize]
|
||||
public class AuditController(ISender sender) : ControllerBase
|
||||
{
|
||||
[HttpGet("actions")]
|
||||
public async Task<ActionResult<PagedResult<ActionLogDto>>> GetActions(
|
||||
[FromQuery] DateTimeOffset? from,
|
||||
[FromQuery] DateTimeOffset? to,
|
||||
[FromQuery] string? actor,
|
||||
[FromQuery] string? action,
|
||||
[FromQuery] string? entityType,
|
||||
[FromQuery] Guid? entityId,
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 20,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var filter = new ActionLogFilter(from, to, actor, action, entityType, entityId);
|
||||
return Ok(await sender.Send(new GetActionLogsQuery(User.GetUserId(), filter, page, pageSize), ct));
|
||||
}
|
||||
|
||||
[HttpGet("logins")]
|
||||
public async Task<ActionResult<PagedResult<LoginLogDto>>> GetLogins(
|
||||
[FromQuery] DateTimeOffset? from,
|
||||
[FromQuery] DateTimeOffset? to,
|
||||
[FromQuery] string? username,
|
||||
[FromQuery] bool? success,
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 20,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var filter = new LoginLogFilter(from, to, username, success);
|
||||
return Ok(await sender.Send(new GetLoginLogsQuery(User.GetUserId(), filter, page, pageSize), ct));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user