Browse Source
Merge pull request #1079 from colinin/bulk-delete-log
✨ feat: 增加日志批量删除接口.
pull/1091/head
yx lin
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with
129 additions and
0 deletions
-
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/LINGYUN/Abp/AuditLogging/Elasticsearch/ElasticsearchAuditLogManager.cs
-
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/LINGYUN/Abp/AuditLogging/Elasticsearch/ElasticsearchSecurityLogManager.cs
-
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.EntityFrameworkCore/LINGYUN/Abp/AuditLogging/EntityFrameworkCore/AuditLogManager.cs
-
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.EntityFrameworkCore/LINGYUN/Abp/AuditLogging/EntityFrameworkCore/SecurityLogManager.cs
-
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/LINGYUN/Abp/AuditLogging/DefaultAuditLogManager.cs
-
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/LINGYUN/Abp/AuditLogging/DefaultSecurityLogManager.cs
-
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/LINGYUN/Abp/AuditLogging/IAuditLogManager.cs
-
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/LINGYUN/Abp/AuditLogging/ISecurityLogManager.cs
-
aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/AuditLogs/AuditLogDeleteManyInput.cs
-
aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/AuditLogs/IAuditLogAppService.cs
-
aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/SecurityLogs/ISecurityLogAppService.cs
-
aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN/Abp/Auditing/SecurityLogs/SecurityLogDeleteManyInput.cs
-
aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN/Abp/Auditing/AuditLogs/AuditLogAppService.cs
-
aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN/Abp/Auditing/SecurityLogs/SecurityLogAppService.cs
-
aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/AuditLogs/AuditLogController.cs
-
aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN/Abp/Auditing/SecurityLogs/SecurityLogController.cs
-
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/en.json
-
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/zh-Hans.json
|
|
|
@ -188,6 +188,19 @@ public class ElasticsearchAuditLogManager : IAuditLogManager, ITransientDependen |
|
|
|
cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
public async virtual Task DeleteManyAsync(List<Guid> ids, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
var client = _clientFactory.Create(); |
|
|
|
|
|
|
|
await client.DeleteByQueryAsync<AuditLog>( |
|
|
|
x => x.Index(CreateIndex()) |
|
|
|
.Query(query => |
|
|
|
query.Terms(terms => |
|
|
|
terms.Field(field => field.Id) |
|
|
|
.Terms(ids))), |
|
|
|
cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
public async virtual Task<string> SaveAsync( |
|
|
|
AuditLogInfo auditInfo, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
|
|
|
|
@ -95,6 +95,19 @@ public class ElasticsearchSecurityLogManager : ISecurityLogManager, ITransientDe |
|
|
|
cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
public async virtual Task DeleteManyAsync(List<Guid> ids, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
var client = _clientFactory.Create(); |
|
|
|
|
|
|
|
await client.DeleteByQueryAsync<SecurityLog>( |
|
|
|
x => x.Index(CreateIndex()) |
|
|
|
.Query(query => |
|
|
|
query.Terms(terms => |
|
|
|
terms.Field(field => field.Id) |
|
|
|
.Terms(ids))), |
|
|
|
cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
public async virtual Task<List<SecurityLog>> GetListAsync( |
|
|
|
string sorting = null, |
|
|
|
int maxResultCount = 50, |
|
|
|
|
|
|
|
@ -141,6 +141,15 @@ public class AuditLogManager : IAuditLogManager, ITransientDependency |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public async virtual Task DeleteManyAsync(List<Guid> ids, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
using (var uow = UnitOfWorkManager.Begin(true)) |
|
|
|
{ |
|
|
|
await AuditLogRepository.DeleteManyAsync(ids); |
|
|
|
await uow.CompleteAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public async virtual Task<string> SaveAsync( |
|
|
|
AuditLogInfo auditInfo, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
|
|
|
|
@ -40,6 +40,16 @@ public class SecurityLogManager : ISecurityLogManager, ITransientDependency |
|
|
|
UnitOfWorkManager = unitOfWorkManager; |
|
|
|
} |
|
|
|
|
|
|
|
public async virtual Task DeleteManyAsync(List<Guid> ids, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
using (var uow = UnitOfWorkManager.Begin(requiresNew: true)) |
|
|
|
{ |
|
|
|
await IdentitySecurityLogRepository.DeleteManyAsync(ids, |
|
|
|
cancellationToken: cancellationToken); |
|
|
|
await uow.CompleteAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public async virtual Task SaveAsync( |
|
|
|
SecurityLogInfo securityLogInfo, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
|
|
|
|
@ -92,4 +92,10 @@ public class DefaultAuditLogManager : IAuditLogManager, ISingletonDependency |
|
|
|
Logger.LogDebug("No audit log manager is available!"); |
|
|
|
return Task.CompletedTask; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual Task DeleteManyAsync(List<Guid> ids, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
Logger.LogDebug("No audit log manager is available!"); |
|
|
|
return Task.CompletedTask; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -83,4 +83,10 @@ public class DefaultSecurityLogManager : ISecurityLogManager, ISingletonDependen |
|
|
|
Logger.LogDebug("No security log manager is available!"); |
|
|
|
return Task.CompletedTask; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual Task DeleteManyAsync(List<Guid> ids, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
Logger.LogDebug("No security log manager is available!"); |
|
|
|
return Task.CompletedTask; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -18,6 +18,10 @@ public interface IAuditLogManager |
|
|
|
Guid id, |
|
|
|
CancellationToken cancellationToken = default); |
|
|
|
|
|
|
|
Task DeleteManyAsync( |
|
|
|
List<Guid> ids, |
|
|
|
CancellationToken cancellationToken = default); |
|
|
|
|
|
|
|
Task<string> SaveAsync( |
|
|
|
AuditLogInfo auditInfo, |
|
|
|
CancellationToken cancellationToken = default); |
|
|
|
|
|
|
|
@ -17,6 +17,10 @@ public interface ISecurityLogManager |
|
|
|
Guid id, |
|
|
|
CancellationToken cancellationToken = default); |
|
|
|
|
|
|
|
Task DeleteManyAsync( |
|
|
|
List<Guid> ids, |
|
|
|
CancellationToken cancellationToken = default); |
|
|
|
|
|
|
|
Task SaveAsync( |
|
|
|
SecurityLogInfo securityLogInfo, |
|
|
|
CancellationToken cancellationToken = default); |
|
|
|
|
|
|
|
@ -0,0 +1,10 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
|
|
|
|
namespace LINGYUN.Abp.Auditing.AuditLogs; |
|
|
|
public class AuditLogDeleteManyInput |
|
|
|
{ |
|
|
|
[Required] |
|
|
|
public List<Guid> Ids { get; set; } |
|
|
|
} |
|
|
|
@ -12,4 +12,6 @@ public interface IAuditLogAppService : IApplicationService |
|
|
|
Task<AuditLogDto> GetAsync(Guid id); |
|
|
|
|
|
|
|
Task DeleteAsync(Guid id); |
|
|
|
|
|
|
|
Task DeleteManyAsync(AuditLogDeleteManyInput input); |
|
|
|
} |
|
|
|
|
|
|
|
@ -12,4 +12,6 @@ public interface ISecurityLogAppService : IApplicationService |
|
|
|
Task<SecurityLogDto> GetAsync(Guid id); |
|
|
|
|
|
|
|
Task DeleteAsync(Guid id); |
|
|
|
|
|
|
|
Task DeleteManyAsync(SecurityLogDeleteManyInput input); |
|
|
|
} |
|
|
|
|
|
|
|
@ -0,0 +1,10 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
|
|
|
|
namespace LINGYUN.Abp.Auditing.SecurityLogs; |
|
|
|
public class SecurityLogDeleteManyInput |
|
|
|
{ |
|
|
|
[Required] |
|
|
|
public List<Guid> Ids { get; set; } |
|
|
|
} |
|
|
|
@ -59,4 +59,10 @@ public class AuditLogAppService : AuditingApplicationServiceBase, IAuditLogAppSe |
|
|
|
{ |
|
|
|
await AuditLogManager.DeleteAsync(id); |
|
|
|
} |
|
|
|
|
|
|
|
[Authorize(AuditingPermissionNames.AuditLog.Delete)] |
|
|
|
public async virtual Task DeleteManyAsync(AuditLogDeleteManyInput input) |
|
|
|
{ |
|
|
|
await AuditLogManager.DeleteManyAsync(input.Ids); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -52,4 +52,10 @@ public class SecurityLogAppService : AuditingApplicationServiceBase, ISecurityLo |
|
|
|
{ |
|
|
|
await SecurityLogManager.DeleteAsync(id); |
|
|
|
} |
|
|
|
|
|
|
|
[Authorize(AuditingPermissionNames.SecurityLog.Delete)] |
|
|
|
public async virtual Task DeleteManyAsync(SecurityLogDeleteManyInput input) |
|
|
|
{ |
|
|
|
await SecurityLogManager.DeleteManyAsync(input.Ids); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -32,6 +32,14 @@ public class AuditLogController : AbpControllerBase, IAuditLogAppService |
|
|
|
await AuditLogAppService.DeleteAsync(id); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpDelete] |
|
|
|
[Route("bulk")] |
|
|
|
[Authorize(AuditingPermissionNames.AuditLog.Delete)] |
|
|
|
public async virtual Task DeleteManyAsync([FromBody] AuditLogDeleteManyInput input) |
|
|
|
{ |
|
|
|
await AuditLogAppService.DeleteManyAsync(input); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
[Route("{id}")] |
|
|
|
public async virtual Task<AuditLogDto> GetAsync(Guid id) |
|
|
|
|
|
|
|
@ -32,6 +32,14 @@ public class SecurityLogController : AbpControllerBase, ISecurityLogAppService |
|
|
|
await SecurityLogAppService.DeleteAsync(id); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpDelete] |
|
|
|
[Route("bulk")] |
|
|
|
[Authorize(AuditingPermissionNames.SecurityLog.Delete)] |
|
|
|
public async virtual Task DeleteManyAsync([FromBody] SecurityLogDeleteManyInput input) |
|
|
|
{ |
|
|
|
await SecurityLogAppService.DeleteManyAsync(input); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
[Route("{id}")] |
|
|
|
public async virtual Task<SecurityLogDto> GetAsync(Guid id) |
|
|
|
|
|
|
|
@ -87,6 +87,12 @@ |
|
|
|
"SetPassword": "Set Password", |
|
|
|
"LockTime": "Lock Time", |
|
|
|
"LockType": "Lock Type", |
|
|
|
"LockType:Seconds": "Seconds", |
|
|
|
"LockType:Minutes": "Minutes", |
|
|
|
"LockType:Hours": "Hours", |
|
|
|
"LockType:Days": "Days", |
|
|
|
"LockType:Months": "Months", |
|
|
|
"LockType:Years": "Years", |
|
|
|
"Confirmed": "Confirmed", |
|
|
|
"UnConfirmed": "UnConfirmed", |
|
|
|
"UnActived": "UnActived", |
|
|
|
|
|
|
|
@ -87,6 +87,12 @@ |
|
|
|
"SetPassword": "设置密码", |
|
|
|
"LockTime": "锁定时间", |
|
|
|
"LockType": "锁定类型", |
|
|
|
"LockType:Seconds": "秒", |
|
|
|
"LockType:Minutes": "分", |
|
|
|
"LockType:Hours": "时", |
|
|
|
"LockType:Days": "天", |
|
|
|
"LockType:Months": "月", |
|
|
|
"LockType:Years": "年", |
|
|
|
"Confirmed": "已确认", |
|
|
|
"UnConfirmed": "未确认", |
|
|
|
"UnActived": "未启用", |
|
|
|
|