You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.5 KiB
64 lines
2.5 KiB
3 years ago
|
using Microsoft.AspNetCore.Authorization;
|
||
|
using Sanhe.Abp.Auditing.Features;
|
||
|
using Sanhe.Abp.Auditing.Permissions;
|
||
|
using Sanhe.Abp.AuditLogging;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel.DataAnnotations;
|
||
|
using System.Threading.Tasks;
|
||
|
using Volo.Abp.Application.Dtos;
|
||
|
using Volo.Abp.Features;
|
||
|
|
||
|
namespace Sanhe.Abp.Auditing.AuditLogs
|
||
|
{
|
||
|
[Authorize(AuditingPermissionNames.AuditLog.Default)]
|
||
|
[RequiresFeature(AuditingFeatureNames.Logging.AuditLog)]
|
||
|
public class AuditLogAppService : AuditingApplicationServiceBase, IAuditLogAppService
|
||
|
{
|
||
|
protected IAuditLogManager AuditLogManager { get; }
|
||
|
|
||
|
public AuditLogAppService(IAuditLogManager auditLogManager)
|
||
|
{
|
||
|
AuditLogManager = auditLogManager;
|
||
|
}
|
||
|
|
||
|
public virtual async Task<AuditLogDto> GetAsync(Guid id)
|
||
|
{
|
||
|
var auditLog = await AuditLogManager.GetAsync(id, includeDetails: true);
|
||
|
|
||
|
return ObjectMapper.Map<AuditLog, AuditLogDto>(auditLog);
|
||
|
}
|
||
|
|
||
|
public virtual async Task<PagedResultDto<AuditLogDto>> GetListAsync(AuditLogGetByPagedDto input)
|
||
|
{
|
||
|
var auditLogCount = await AuditLogManager
|
||
|
.GetCountAsync(input.StartTime, input.EndTime,
|
||
|
input.HttpMethod, input.Url,
|
||
|
input.UserId, input.UserName,
|
||
|
input.ApplicationName, input.CorrelationId,
|
||
|
input.ClientId, input.ClientIpAddress,
|
||
|
input.MaxExecutionDuration, input.MinExecutionDuration,
|
||
|
input.HasException, input.HttpStatusCode);
|
||
|
|
||
|
var auditLogs = await AuditLogManager
|
||
|
.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount,
|
||
|
input.StartTime, input.EndTime,
|
||
|
input.HttpMethod, input.Url,
|
||
|
input.UserId, input.UserName,
|
||
|
input.ApplicationName, input.CorrelationId,
|
||
|
input.ClientId, input.ClientIpAddress,
|
||
|
input.MaxExecutionDuration, input.MinExecutionDuration,
|
||
|
input.HasException, input.HttpStatusCode, includeDetails: false);
|
||
|
|
||
|
return new PagedResultDto<AuditLogDto>(auditLogCount,
|
||
|
ObjectMapper.Map<List<AuditLog>, List<AuditLogDto>>(auditLogs));
|
||
|
}
|
||
|
|
||
|
[Authorize(AuditingPermissionNames.AuditLog.Delete)]
|
||
|
public virtual async Task DeleteAsync([Required] Guid id)
|
||
|
{
|
||
|
await AuditLogManager.DeleteAsync(id);
|
||
|
}
|
||
|
}
|
||
|
}
|