feat: 完成审计日志模块引入
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
@@ -8,24 +9,29 @@ using Yi.Framework.AuditLogging.Domain.Shared.Consts;
|
||||
namespace Yi.Framework.AuditLogging.Domain.Entities;
|
||||
|
||||
[DisableAuditing]
|
||||
[SugarTable("YiAuditLogAction")]
|
||||
[SugarIndex($"index_{nameof(AuditLogId)}", nameof(AuditLogId), OrderByType.Asc)]
|
||||
[SugarIndex($"index_{nameof(TenantId)}_{nameof(ExecutionTime)}", nameof(TenantId), OrderByType.Asc, nameof(ServiceName), OrderByType.Asc, nameof(MethodName), OrderByType.Asc, nameof(ExecutionTime), OrderByType.Asc)]
|
||||
public class AuditLogActionEntity : Entity<Guid>, IMultiTenant
|
||||
{
|
||||
public virtual Guid? TenantId { get; protected set; }
|
||||
|
||||
public virtual Guid AuditLogId { get; protected set; }
|
||||
|
||||
public virtual string ServiceName { get; protected set; }
|
||||
public virtual string? ServiceName { get; protected set; }
|
||||
|
||||
public virtual string MethodName { get; protected set; }
|
||||
public virtual string? MethodName { get; protected set; }
|
||||
|
||||
public virtual string Parameters { get; protected set; }
|
||||
public virtual string? Parameters { get; protected set; }
|
||||
|
||||
public virtual DateTime ExecutionTime { get; protected set; }
|
||||
public virtual DateTime? ExecutionTime { get; protected set; }
|
||||
|
||||
public virtual int ExecutionDuration { get; protected set; }
|
||||
public virtual int? ExecutionDuration { get; protected set; }
|
||||
|
||||
|
||||
protected AuditLogActionEntity()
|
||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||
public override Guid Id { get; protected set; }
|
||||
public AuditLogActionEntity()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Volo.Abp.Auditing;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
@@ -7,6 +8,9 @@ using Yi.Framework.AuditLogging.Domain.Shared.Consts;
|
||||
namespace Yi.Framework.AuditLogging.Domain.Entities
|
||||
{
|
||||
[DisableAuditing]
|
||||
[SugarTable("YiAuditLog")]
|
||||
[SugarIndex($"index_{nameof(ExecutionTime)}", nameof(TenantId), OrderByType.Asc,nameof(ExecutionTime), OrderByType.Asc)]
|
||||
[SugarIndex($"index_{nameof(ExecutionTime)}_{nameof(UserId)}",nameof(TenantId), OrderByType.Asc, nameof(UserId), OrderByType.Asc, nameof(ExecutionTime), OrderByType.Asc)]
|
||||
public class AuditLogAggregateRoot: AggregateRoot<Guid>, IMultiTenant
|
||||
{
|
||||
public AuditLogAggregateRoot()
|
||||
@@ -68,49 +72,60 @@ namespace Yi.Framework.AuditLogging.Domain.Entities
|
||||
Comments = comments.Truncate(AuditLogConsts.MaxCommentsLength);
|
||||
}
|
||||
|
||||
public virtual string ApplicationName { get; set; }
|
||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||
public override Guid Id { get; protected set; }
|
||||
|
||||
public virtual string? ApplicationName { get; set; }
|
||||
|
||||
public virtual Guid? UserId { get; protected set; }
|
||||
|
||||
public virtual string UserName { get; protected set; }
|
||||
public virtual string? UserName { get; protected set; }
|
||||
|
||||
public virtual string TenantName { get; protected set; }
|
||||
public virtual string? TenantName { get; protected set; }
|
||||
|
||||
public virtual Guid? ImpersonatorUserId { get; protected set; }
|
||||
|
||||
public virtual string ImpersonatorUserName { get; protected set; }
|
||||
public virtual string? ImpersonatorUserName { get; protected set; }
|
||||
|
||||
public virtual Guid? ImpersonatorTenantId { get; protected set; }
|
||||
|
||||
public virtual string ImpersonatorTenantName { get; protected set; }
|
||||
public virtual string? ImpersonatorTenantName { get; protected set; }
|
||||
|
||||
public virtual DateTime ExecutionTime { get; protected set; }
|
||||
public virtual DateTime? ExecutionTime { get; protected set; }
|
||||
|
||||
public virtual int ExecutionDuration { get; protected set; }
|
||||
public virtual int? ExecutionDuration { get; protected set; }
|
||||
|
||||
public virtual string ClientIpAddress { get; protected set; }
|
||||
public virtual string? ClientIpAddress { get; protected set; }
|
||||
|
||||
public virtual string ClientName { get; protected set; }
|
||||
public virtual string? ClientName { get; protected set; }
|
||||
|
||||
public virtual string ClientId { get; set; }
|
||||
public virtual string? ClientId { get; set; }
|
||||
|
||||
public virtual string CorrelationId { get; set; }
|
||||
public virtual string? CorrelationId { get; set; }
|
||||
|
||||
public virtual string BrowserInfo { get; protected set; }
|
||||
public virtual string? BrowserInfo { get; protected set; }
|
||||
|
||||
public virtual string HttpMethod { get; protected set; }
|
||||
public virtual string? HttpMethod { get; protected set; }
|
||||
|
||||
public virtual string Url { get; protected set; }
|
||||
public virtual string? Url { get; protected set; }
|
||||
|
||||
public virtual string Exceptions { get; protected set; }
|
||||
public virtual string? Exceptions { get; protected set; }
|
||||
|
||||
public virtual string Comments { get; protected set; }
|
||||
public virtual string? Comments { get; protected set; }
|
||||
|
||||
public virtual int? HttpStatusCode { get; set; }
|
||||
|
||||
public virtual Guid? TenantId { get; protected set; }
|
||||
public virtual List<EntityChangeEntity> EntityChanges { get; protected set; }
|
||||
|
||||
public virtual List<AuditLogActionEntity> Actions { get; protected set; }
|
||||
//导航属性
|
||||
[Navigate(NavigateType.OneToMany, nameof(EntityChangeEntity.AuditLogId))]
|
||||
public virtual List<EntityChangeEntity> EntityChanges { get; protected set; }
|
||||
|
||||
//导航属性
|
||||
[Navigate(NavigateType.OneToMany, nameof(AuditLogActionEntity.AuditLogId))]
|
||||
public virtual List<AuditLogActionEntity> Actions { get; protected set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public override ExtraPropertyDictionary ExtraProperties { get; protected set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Volo.Abp.Auditing;
|
||||
using System.Reflection;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Guids;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
@@ -6,23 +8,30 @@ using Yi.Framework.AuditLogging.Domain.Shared.Consts;
|
||||
|
||||
namespace Yi.Framework.AuditLogging.Domain.Entities
|
||||
{
|
||||
[SugarTable("YiEntityChange")]
|
||||
[SugarIndex($"index_{nameof(AuditLogId)}", nameof(AuditLogId), OrderByType.Asc)]
|
||||
[SugarIndex($"index_{nameof(TenantId)}_{nameof(EntityId)}", nameof(TenantId), OrderByType.Asc, nameof(EntityTypeFullName), OrderByType.Asc, nameof(EntityId), OrderByType.Asc)]
|
||||
public class EntityChangeEntity : Entity<Guid>, IMultiTenant
|
||||
{
|
||||
public EntityChangeEntity() { }
|
||||
|
||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||
public override Guid Id { get; protected set; }
|
||||
public virtual Guid AuditLogId { get; protected set; }
|
||||
|
||||
public virtual Guid? TenantId { get; protected set; }
|
||||
|
||||
public virtual DateTime ChangeTime { get; protected set; }
|
||||
public virtual DateTime? ChangeTime { get; protected set; }
|
||||
|
||||
public virtual EntityChangeType ChangeType { get; protected set; }
|
||||
public virtual EntityChangeType? ChangeType { get; protected set; }
|
||||
|
||||
public virtual Guid? EntityTenantId { get; protected set; }
|
||||
|
||||
public virtual string EntityId { get; protected set; }
|
||||
public virtual string? EntityId { get; protected set; }
|
||||
|
||||
public virtual string EntityTypeFullName { get; protected set; }
|
||||
|
||||
public virtual ICollection<EntityPropertyChangeEntity> PropertyChanges { get; protected set; }
|
||||
public virtual string? EntityTypeFullName { get; protected set; }
|
||||
[Navigate(NavigateType.OneToMany, nameof(EntityPropertyChangeEntity.EntityChangeId))]
|
||||
public virtual List<EntityPropertyChangeEntity> PropertyChanges { get; protected set; }
|
||||
|
||||
|
||||
public EntityChangeEntity(
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Guids;
|
||||
@@ -11,6 +12,9 @@ using Yi.Framework.AuditLogging.Domain.Shared.Consts;
|
||||
|
||||
namespace Yi.Framework.AuditLogging.Domain.Entities
|
||||
{
|
||||
[SugarTable("YiEntityPropertyChange")]
|
||||
|
||||
[SugarIndex($"index_{nameof(EntityChangeId)}", nameof(EntityChangeId), OrderByType.Asc)]
|
||||
public class EntityPropertyChangeEntity:Entity<Guid>, IMultiTenant
|
||||
{
|
||||
public EntityPropertyChangeEntity()
|
||||
@@ -33,15 +37,18 @@ namespace Yi.Framework.AuditLogging.Domain.Entities
|
||||
PropertyName = entityChangeInfo.PropertyName.TruncateFromBeginning(EntityPropertyChangeConsts.MaxPropertyNameLength);
|
||||
PropertyTypeFullName = entityChangeInfo.PropertyTypeFullName.TruncateFromBeginning(EntityPropertyChangeConsts.MaxPropertyTypeFullNameLength);
|
||||
}
|
||||
|
||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||
public override Guid Id { get; protected set; }
|
||||
public virtual Guid? TenantId { get; protected set; }
|
||||
public virtual Guid EntityChangeId { get; protected set; }
|
||||
public virtual Guid? EntityChangeId { get; protected set; }
|
||||
|
||||
public virtual string NewValue { get; protected set; }
|
||||
public virtual string? NewValue { get; protected set; }
|
||||
|
||||
public virtual string OriginalValue { get; protected set; }
|
||||
public virtual string? OriginalValue { get; protected set; }
|
||||
|
||||
public virtual string PropertyName { get; protected set; }
|
||||
public virtual string? PropertyName { get; protected set; }
|
||||
|
||||
public virtual string PropertyTypeFullName { get; protected set; }
|
||||
public virtual string? PropertyTypeFullName { get; protected set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user