feat: 搭建完成审计日志模块
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.AuditLogging;
|
||||
|
||||
namespace Yi.AuditLogging.SqlSugarCore.Entities
|
||||
{
|
||||
public class AuditLogEntity : AuditLog
|
||||
{
|
||||
public AuditLogEntity() { }
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,22 @@
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Linq.Expressions;
|
||||
using System.Net;
|
||||
using Mapster;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.AuditLogging;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Yi.AuditLogging.SqlSugarCore.Entities;
|
||||
using Yi.Framework.AuditLogging.Domain;
|
||||
using Yi.Framework.AuditLogging.Domain.Entities;
|
||||
using Yi.Framework.AuditLogging.Domain.Repositories;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
using Yi.Framework.SqlSugarCore.Repositories;
|
||||
|
||||
namespace Yi.AuditLogging.SqlSugarCore;
|
||||
namespace Yi.Framework.AuditLogging.SqlSugarCore.Repositories;
|
||||
|
||||
public class SqlSugarCoreAuditLogRepository : SqlSugarObjectRepository<AuditLog, Guid>, IAuditLogRepository
|
||||
public class SqlSugarCoreAuditLogRepository : SqlSugarRepository<AuditLogAggregateRoot, Guid>, IAuditLogRepository
|
||||
{
|
||||
public virtual async Task<List<AuditLog>> GetListAsync(
|
||||
public SqlSugarCoreAuditLogRepository(ISugarDbContextProvider<ISqlSugarDbContext> sugarDbContextProvider) : base(sugarDbContextProvider)
|
||||
{
|
||||
}
|
||||
public virtual async Task<List<AuditLogAggregateRoot>> GetListAsync(
|
||||
string sorting = null,
|
||||
int maxResultCount = 50,
|
||||
int skipCount = 0,
|
||||
@@ -32,8 +33,7 @@ public class SqlSugarCoreAuditLogRepository : SqlSugarObjectRepository<AuditLog,
|
||||
int? minExecutionDuration = null,
|
||||
bool? hasException = null,
|
||||
HttpStatusCode? httpStatusCode = null,
|
||||
bool includeDetails = false,
|
||||
CancellationToken cancellationToken = default)
|
||||
bool includeDetails = false)
|
||||
{
|
||||
var query = await GetListQueryAsync(
|
||||
startTime,
|
||||
@@ -53,10 +53,10 @@ public class SqlSugarCoreAuditLogRepository : SqlSugarObjectRepository<AuditLog,
|
||||
);
|
||||
|
||||
var auditLogs = await query
|
||||
.OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(AuditLog.ExecutionTime) + " DESC" : sorting)
|
||||
.ToPageListAsync(skipCount, maxResultCount, cancellationToken);
|
||||
.OrderBy(sorting.IsNullOrWhiteSpace() ? (nameof(AuditLogAggregateRoot.ExecutionTime) + " DESC") : sorting)
|
||||
.ToPageListAsync(skipCount, maxResultCount);
|
||||
|
||||
return auditLogs.Adapt<List<AuditLog>>();
|
||||
return auditLogs;
|
||||
}
|
||||
|
||||
public virtual async Task<long> GetCountAsync(
|
||||
@@ -91,12 +91,12 @@ public class SqlSugarCoreAuditLogRepository : SqlSugarObjectRepository<AuditLog,
|
||||
httpStatusCode
|
||||
);
|
||||
|
||||
var totalCount = await query.CountAsync(cancellationToken);
|
||||
var totalCount = await query.CountAsync();
|
||||
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
protected virtual async Task<ISugarQueryable<AuditLogEntity>> GetListQueryAsync(
|
||||
protected virtual async Task<ISugarQueryable<AuditLogAggregateRoot>> GetListQueryAsync(
|
||||
DateTime? startTime = null,
|
||||
DateTime? endTime = null,
|
||||
string httpMethod = null,
|
||||
@@ -113,7 +113,7 @@ public class SqlSugarCoreAuditLogRepository : SqlSugarObjectRepository<AuditLog,
|
||||
bool includeDetails = false)
|
||||
{
|
||||
var nHttpStatusCode = (int?)httpStatusCode;
|
||||
return (await GetDbContextAsync()).Queryable<AuditLogEntity>()
|
||||
return _DbQueryable
|
||||
.WhereIF(startTime.HasValue, auditLog => auditLog.ExecutionTime >= startTime)
|
||||
.WhereIF(endTime.HasValue, auditLog => auditLog.ExecutionTime <= endTime)
|
||||
.WhereIF(hasException.HasValue && hasException.Value, auditLog => auditLog.Exceptions != null && auditLog.Exceptions != "")
|
||||
@@ -135,34 +135,35 @@ public class SqlSugarCoreAuditLogRepository : SqlSugarObjectRepository<AuditLog,
|
||||
DateTime endDate,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await (await GetDbContextAsync()).Queryable<AuditLogEntity>()
|
||||
var result = await _DbQueryable
|
||||
.Where(a => a.ExecutionTime < endDate.AddDays(1) && a.ExecutionTime > startDate)
|
||||
.OrderBy(t => t.ExecutionTime)
|
||||
.GroupBy(t => new { t.ExecutionTime.Date })
|
||||
.Select(g => new { Day = SqlFunc.AggregateMin(g.ExecutionTime), avgExecutionTime = SqlFunc.AggregateAvg(g.ExecutionDuration) })
|
||||
.ToListAsync(cancellationToken);
|
||||
.ToListAsync();
|
||||
|
||||
return result.ToDictionary(element => element.Day.ClearTime(), element => (double)element.avgExecutionTime);
|
||||
}
|
||||
|
||||
public virtual async Task<EntityChange> GetEntityChange(
|
||||
|
||||
public virtual async Task<EntityChangeEntity> GetEntityChange(
|
||||
Guid entityChangeId,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var entityChange = await (await GetDbContextAsync()).Queryable<EntityChange>()
|
||||
var entityChange = await (await GetDbContextAsync()).Queryable<EntityChangeEntity>()
|
||||
.Where(x => x.Id == entityChangeId)
|
||||
.OrderBy(x => x.Id)
|
||||
.FirstAsync(cancellationToken);
|
||||
.FirstAsync();
|
||||
|
||||
if (entityChange == null)
|
||||
{
|
||||
throw new EntityNotFoundException(typeof(EntityChange));
|
||||
throw new EntityNotFoundException(typeof(EntityChangeEntity));
|
||||
}
|
||||
|
||||
return entityChange;
|
||||
}
|
||||
|
||||
public virtual async Task<List<EntityChange>> GetEntityChangeListAsync(
|
||||
public virtual async Task<List<EntityChangeEntity>> GetEntityChangeListAsync(
|
||||
string sorting = null,
|
||||
int maxResultCount = 50,
|
||||
int skipCount = 0,
|
||||
@@ -177,8 +178,8 @@ public class SqlSugarCoreAuditLogRepository : SqlSugarObjectRepository<AuditLog,
|
||||
{
|
||||
var query = await GetEntityChangeListQueryAsync(auditLogId, startTime, endTime, changeType, entityId, entityTypeFullName, includeDetails);
|
||||
|
||||
return await query.OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(EntityChange.ChangeTime) + " DESC" : sorting)
|
||||
.ToPageListAsync(skipCount, maxResultCount, cancellationToken);
|
||||
return await query.OrderBy(sorting.IsNullOrWhiteSpace() ? (nameof(EntityChangeEntity.ChangeTime) + " DESC") : sorting)
|
||||
.ToPageListAsync(skipCount, maxResultCount);
|
||||
}
|
||||
|
||||
public virtual async Task<long> GetEntityChangeCountAsync(
|
||||
@@ -192,17 +193,16 @@ public class SqlSugarCoreAuditLogRepository : SqlSugarObjectRepository<AuditLog,
|
||||
{
|
||||
var query = await GetEntityChangeListQueryAsync(auditLogId, startTime, endTime, changeType, entityId, entityTypeFullName);
|
||||
|
||||
var totalCount = await query.CountAsync(cancellationToken);
|
||||
var totalCount = await query.CountAsync();
|
||||
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public virtual async Task<EntityChangeWithUsername> GetEntityChangeWithUsernameAsync(
|
||||
Guid entityChangeId,
|
||||
CancellationToken cancellationToken = default)
|
||||
Guid entityChangeId)
|
||||
{
|
||||
var auditLog = await (await GetDbContextAsync()).Queryable<AuditLogEntity>()
|
||||
.Where(x => x.EntityChanges.Any(y => y.Id == entityChangeId)).FirstAsync(cancellationToken);
|
||||
var auditLog = await _DbQueryable
|
||||
.Where(x => x.EntityChanges.Any(y => y.Id == entityChangeId)).FirstAsync();
|
||||
|
||||
return new EntityChangeWithUsername()
|
||||
{
|
||||
@@ -218,15 +218,14 @@ public class SqlSugarCoreAuditLogRepository : SqlSugarObjectRepository<AuditLog,
|
||||
{
|
||||
var dbContext = await GetDbContextAsync();
|
||||
|
||||
var query = dbContext.Queryable<EntityChange>()
|
||||
var query = dbContext.Queryable<EntityChangeEntity>()
|
||||
.Where(x => x.EntityId == entityId && x.EntityTypeFullName == entityTypeFullName);
|
||||
return await query.LeftJoin<AuditLogEntity>((change, audit) => change.AuditLogId == audit.Id)
|
||||
.Select((change, audit) => new EntityChangeWithUsername { EntityChange = change, UserName = audit.UserName }, true)
|
||||
.OrderByDescending(x => x.EntityChange.ChangeTime).ToListAsync(cancellationToken);
|
||||
|
||||
return await query.LeftJoin<AuditLogAggregateRoot>((x, audit) => x.AuditLogId == audit.Id)
|
||||
.Select((x, audit) => new EntityChangeWithUsername { EntityChange = x, UserName = audit.UserName })
|
||||
.OrderByDescending(x => x.EntityChange.ChangeTime).ToListAsync();
|
||||
}
|
||||
|
||||
protected virtual async Task<ISugarQueryable<EntityChange>> GetEntityChangeListQueryAsync(
|
||||
protected virtual async Task<ISugarQueryable<EntityChangeEntity>> GetEntityChangeListQueryAsync(
|
||||
Guid? auditLogId = null,
|
||||
DateTime? startTime = null,
|
||||
DateTime? endTime = null,
|
||||
@@ -236,7 +235,7 @@ public class SqlSugarCoreAuditLogRepository : SqlSugarObjectRepository<AuditLog,
|
||||
bool includeDetails = false)
|
||||
{
|
||||
return (await GetDbContextAsync())
|
||||
.Queryable<EntityChange>()
|
||||
.Queryable<EntityChangeEntity>()
|
||||
.WhereIF(auditLogId.HasValue, e => e.AuditLogId == auditLogId)
|
||||
.WhereIF(startTime.HasValue, e => e.ChangeTime >= startTime)
|
||||
.WhereIF(endTime.HasValue, e => e.ChangeTime <= endTime)
|
||||
@@ -244,106 +243,4 @@ public class SqlSugarCoreAuditLogRepository : SqlSugarObjectRepository<AuditLog,
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(entityId), e => e.EntityId == entityId)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(entityTypeFullName), e => e.EntityTypeFullName.Contains(entityTypeFullName));
|
||||
}
|
||||
|
||||
Task<List<AuditLog>> IAuditLogRepository.GetListAsync(string sorting, int maxResultCount, int skipCount, DateTime? startTime, DateTime? endTime, string httpMethod, string url, Guid? userId, string userName, string applicationName, string clientIpAddress, string correlationId, int? maxExecutionDuration, int? minExecutionDuration, bool? hasException, HttpStatusCode? httpStatusCode, bool includeDetails, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Task<AuditLog> GetAsync(Expression<Func<AuditLog, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task DeleteAsync(Expression<Func<AuditLog, bool>> predicate, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task DeleteDirectAsync(Expression<Func<AuditLog, bool>> predicate, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
IQueryable<AuditLog> IReadOnlyRepository<AuditLog>.WithDetails()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IQueryable<AuditLog> WithDetails(params Expression<Func<AuditLog, object>>[] propertySelectors)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Task<IQueryable<AuditLog>> IReadOnlyRepository<AuditLog>.WithDetailsAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IQueryable<AuditLog>> WithDetailsAsync(params Expression<Func<AuditLog, object>>[] propertySelectors)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Task<IQueryable<AuditLog>> IReadOnlyRepository<AuditLog>.GetQueryableAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<List<AuditLog>> GetListAsync(Expression<Func<AuditLog, bool>> predicate, bool includeDetails = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<AuditLog> InsertAsync(AuditLog entity, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task InsertManyAsync(IEnumerable<AuditLog> entities, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<AuditLog> UpdateAsync(AuditLog entity, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task UpdateManyAsync(IEnumerable<AuditLog> entities, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task DeleteAsync(AuditLog entity, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task DeleteManyAsync(IEnumerable<AuditLog> entities, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Task<AuditLog> IReadOnlyBasicRepository<AuditLog, Guid>.GetAsync(Guid id, bool includeDetails, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Task<AuditLog?> IReadOnlyBasicRepository<AuditLog, Guid>.FindAsync(Guid id, bool includeDetails, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Task<List<AuditLog>> IReadOnlyBasicRepository<AuditLog>.GetListAsync(bool includeDetails, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Task<List<AuditLog>> IReadOnlyBasicRepository<AuditLog>.GetPagedListAsync(int skipCount, int maxResultCount, string sorting, bool includeDetails, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,10 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\framework\Yi.Framework.Mapster\Yi.Framework.Mapster.csproj" />
|
||||
<ProjectReference Include="..\..\..\framework\Yi.Framework.SqlSugarCore\Yi.Framework.SqlSugarCore.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.AuditLogging.Domain\Yi.Framework.AuditLogging.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
using System.Reflection;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.AuditLogging;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Yi.Framework.SqlSugarCore;
|
||||
|
||||
namespace Yi.AuditLogging.SqlSugarCore
|
||||
{
|
||||
public class YiAuditLoggingDbContext : SqlSugarDbContext
|
||||
{
|
||||
public YiAuditLoggingDbContext(IAbpLazyServiceProvider lazyServiceProvider) : base(lazyServiceProvider)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void EntityService(PropertyInfo property, EntityColumnInfo column)
|
||||
{
|
||||
base.EntityService(property, column);
|
||||
column.DbTableName = AbpAuditLoggingDbProperties.DbTablePrefix + "AuditLogs";
|
||||
|
||||
column.IfTable<AuditLog>()
|
||||
|
||||
.UpdateProperty(x => x.Id,
|
||||
x =>
|
||||
{
|
||||
x.IsPrimarykey = true;
|
||||
})
|
||||
|
||||
.UpdateProperty(x => x.ApplicationName,
|
||||
x =>
|
||||
{
|
||||
x.Length = AuditLogConsts.MaxApplicationNameLength;
|
||||
x.DbColumnName = nameof(AuditLog.ApplicationName);
|
||||
});
|
||||
|
||||
|
||||
// builder.Entity<AuditLog>(b =>
|
||||
// {
|
||||
// b.ToTable(AbpAuditLoggingDbProperties.DbTablePrefix + "AuditLogs", AbpAuditLoggingDbProperties.DbSchema);
|
||||
|
||||
// b.ConfigureByConvention();
|
||||
|
||||
// b.Property(x => x.ApplicationName).HasMaxLength(AuditLogConsts.MaxApplicationNameLength).HasColumnName(nameof(AuditLog.ApplicationName));
|
||||
// b.Property(x => x.ClientIpAddress).HasMaxLength(AuditLogConsts.MaxClientIpAddressLength).HasColumnName(nameof(AuditLog.ClientIpAddress));
|
||||
// b.Property(x => x.ClientName).HasMaxLength(AuditLogConsts.MaxClientNameLength).HasColumnName(nameof(AuditLog.ClientName));
|
||||
// b.Property(x => x.ClientId).HasMaxLength(AuditLogConsts.MaxClientIdLength).HasColumnName(nameof(AuditLog.ClientId));
|
||||
// b.Property(x => x.CorrelationId).HasMaxLength(AuditLogConsts.MaxCorrelationIdLength).HasColumnName(nameof(AuditLog.CorrelationId));
|
||||
// b.Property(x => x.BrowserInfo).HasMaxLength(AuditLogConsts.MaxBrowserInfoLength).HasColumnName(nameof(AuditLog.BrowserInfo));
|
||||
// b.Property(x => x.HttpMethod).HasMaxLength(AuditLogConsts.MaxHttpMethodLength).HasColumnName(nameof(AuditLog.HttpMethod));
|
||||
// b.Property(x => x.Url).HasMaxLength(AuditLogConsts.MaxUrlLength).HasColumnName(nameof(AuditLog.Url));
|
||||
// b.Property(x => x.HttpStatusCode).HasColumnName(nameof(AuditLog.HttpStatusCode));
|
||||
|
||||
// b.Property(x => x.Comments).HasMaxLength(AuditLogConsts.MaxCommentsLength).HasColumnName(nameof(AuditLog.Comments));
|
||||
// b.Property(x => x.ExecutionDuration).HasColumnName(nameof(AuditLog.ExecutionDuration));
|
||||
// b.Property(x => x.ImpersonatorTenantId).HasColumnName(nameof(AuditLog.ImpersonatorTenantId));
|
||||
// b.Property(x => x.ImpersonatorUserId).HasColumnName(nameof(AuditLog.ImpersonatorUserId));
|
||||
// b.Property(x => x.ImpersonatorTenantName).HasMaxLength(AuditLogConsts.MaxTenantNameLength).HasColumnName(nameof(AuditLog.ImpersonatorTenantName));
|
||||
// b.Property(x => x.ImpersonatorUserName).HasMaxLength(AuditLogConsts.MaxUserNameLength).HasColumnName(nameof(AuditLog.ImpersonatorUserName));
|
||||
// b.Property(x => x.UserId).HasColumnName(nameof(AuditLog.UserId));
|
||||
// b.Property(x => x.UserName).HasMaxLength(AuditLogConsts.MaxUserNameLength).HasColumnName(nameof(AuditLog.UserName));
|
||||
// b.Property(x => x.TenantId).HasColumnName(nameof(AuditLog.TenantId));
|
||||
// b.Property(x => x.TenantName).HasMaxLength(AuditLogConsts.MaxTenantNameLength).HasColumnName(nameof(AuditLog.TenantName));
|
||||
|
||||
// b.HasMany(a => a.Actions).WithOne().HasForeignKey(x => x.AuditLogId).IsRequired();
|
||||
// b.HasMany(a => a.EntityChanges).WithOne().HasForeignKey(x => x.AuditLogId).IsRequired();
|
||||
|
||||
// b.HasIndex(x => new { x.TenantId, x.ExecutionTime });
|
||||
// b.HasIndex(x => new { x.TenantId, x.UserId, x.ExecutionTime });
|
||||
|
||||
// b.ApplyObjectExtensionMappings();
|
||||
// });
|
||||
|
||||
// builder.Entity<AuditLogAction>(b =>
|
||||
// {
|
||||
// b.ToTable(AbpAuditLoggingDbProperties.DbTablePrefix + "AuditLogActions", AbpAuditLoggingDbProperties.DbSchema);
|
||||
|
||||
// b.ConfigureByConvention();
|
||||
|
||||
// b.Property(x => x.AuditLogId).HasColumnName(nameof(AuditLogAction.AuditLogId));
|
||||
// b.Property(x => x.ServiceName).HasMaxLength(AuditLogActionConsts.MaxServiceNameLength).HasColumnName(nameof(AuditLogAction.ServiceName));
|
||||
// b.Property(x => x.MethodName).HasMaxLength(AuditLogActionConsts.MaxMethodNameLength).HasColumnName(nameof(AuditLogAction.MethodName));
|
||||
// b.Property(x => x.Parameters).HasMaxLength(AuditLogActionConsts.MaxParametersLength).HasColumnName(nameof(AuditLogAction.Parameters));
|
||||
// b.Property(x => x.ExecutionTime).HasColumnName(nameof(AuditLogAction.ExecutionTime));
|
||||
// b.Property(x => x.ExecutionDuration).HasColumnName(nameof(AuditLogAction.ExecutionDuration));
|
||||
|
||||
// b.HasIndex(x => new { x.AuditLogId });
|
||||
// b.HasIndex(x => new { x.TenantId, x.ServiceName, x.MethodName, x.ExecutionTime });
|
||||
|
||||
// b.ApplyObjectExtensionMappings();
|
||||
// });
|
||||
|
||||
// builder.Entity<EntityChange>(b =>
|
||||
// {
|
||||
// b.ToTable(AbpAuditLoggingDbProperties.DbTablePrefix + "EntityChanges", AbpAuditLoggingDbProperties.DbSchema);
|
||||
|
||||
// b.ConfigureByConvention();
|
||||
|
||||
// b.Property(x => x.EntityTypeFullName).HasMaxLength(EntityChangeConsts.MaxEntityTypeFullNameLength).IsRequired().HasColumnName(nameof(EntityChange.EntityTypeFullName));
|
||||
// b.Property(x => x.EntityId).HasMaxLength(EntityChangeConsts.MaxEntityIdLength).IsRequired().HasColumnName(nameof(EntityChange.EntityId));
|
||||
// b.Property(x => x.AuditLogId).IsRequired().HasColumnName(nameof(EntityChange.AuditLogId));
|
||||
// b.Property(x => x.ChangeTime).IsRequired().HasColumnName(nameof(EntityChange.ChangeTime));
|
||||
// b.Property(x => x.ChangeType).IsRequired().HasColumnName(nameof(EntityChange.ChangeType));
|
||||
// b.Property(x => x.TenantId).HasColumnName(nameof(EntityChange.TenantId));
|
||||
|
||||
// b.HasMany(a => a.PropertyChanges).WithOne().HasForeignKey(x => x.EntityChangeId);
|
||||
|
||||
// b.HasIndex(x => new { x.AuditLogId });
|
||||
// b.HasIndex(x => new { x.TenantId, x.EntityTypeFullName, x.EntityId });
|
||||
|
||||
// b.ApplyObjectExtensionMappings();
|
||||
// });
|
||||
|
||||
// builder.Entity<EntityPropertyChange>(b =>
|
||||
// {
|
||||
// b.ToTable(AbpAuditLoggingDbProperties.DbTablePrefix + "EntityPropertyChanges", AbpAuditLoggingDbProperties.DbSchema);
|
||||
|
||||
// b.ConfigureByConvention();
|
||||
|
||||
// b.Property(x => x.NewValue).HasMaxLength(EntityPropertyChangeConsts.MaxNewValueLength).HasColumnName(nameof(EntityPropertyChange.NewValue));
|
||||
// b.Property(x => x.PropertyName).HasMaxLength(EntityPropertyChangeConsts.MaxPropertyNameLength).IsRequired().HasColumnName(nameof(EntityPropertyChange.PropertyName));
|
||||
// b.Property(x => x.PropertyTypeFullName).HasMaxLength(EntityPropertyChangeConsts.MaxPropertyTypeFullNameLength).IsRequired().HasColumnName(nameof(EntityPropertyChange.PropertyTypeFullName));
|
||||
// b.Property(x => x.OriginalValue).HasMaxLength(EntityPropertyChangeConsts.MaxOriginalValueLength).HasColumnName(nameof(EntityPropertyChange.OriginalValue));
|
||||
|
||||
// b.HasIndex(x => new { x.EntityChangeId });
|
||||
|
||||
// b.ApplyObjectExtensionMappings();
|
||||
// });
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,17 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Volo.Abp.AuditLogging;
|
||||
using Volo.Abp.Modularity;
|
||||
using Yi.Framework.AuditLogging.Domain.Repositories;
|
||||
using Yi.Framework.AuditLogging.SqlSugarCore.Repositories;
|
||||
using Yi.Framework.SqlSugarCore;
|
||||
|
||||
namespace Yi.AuditLogging.SqlSugarCore
|
||||
{
|
||||
[DependsOn(typeof(AbpAuditLoggingDomainModule))]
|
||||
[DependsOn(typeof(YiFrameworkSqlSugarCoreModule))]
|
||||
public class YiFrameworkAuditLoggingSqlSugarCoreModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
context.Services.Replace(new ServiceDescriptor(typeof(IAuditLogRepository), typeof(SqlSugarCoreAuditLogRepository), lifetime: ServiceLifetime.Transient));
|
||||
context.Services.TryAddYiDbContext<YiAuditLoggingDbContext>();
|
||||
{
|
||||
context.Services.AddTransient<IAuditLogRepository, SqlSugarCoreAuditLogRepository>();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user