2026-02-24 20:44:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
|
using Volo.Abp;
|
|
|
|
|
|
using Volo.Abp.Application.Dtos;
|
|
|
|
|
|
using Volo.Abp.Application.Services;
|
|
|
|
|
|
using Volo.Abp.AuditLogging;
|
|
|
|
|
|
using Volo.Abp.Uow;
|
|
|
|
|
|
using static Sozsoft.Platform.Data.Seeds.SeedConsts;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Sozsoft.Platform.AuditLogs;
|
|
|
|
|
|
|
|
|
|
|
|
public interface IAuditLogAppService
|
|
|
|
|
|
: ICrudAppService<AuditLogDto, Guid>
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-28 08:23:21 +00:00
|
|
|
|
[Authorize(AppCodes.IdentityManagement.AuditLogs)]
|
2026-02-24 20:44:16 +00:00
|
|
|
|
public class AuditLogAppService
|
|
|
|
|
|
: CrudAppService<AuditLog, AuditLogDto, Guid>
|
|
|
|
|
|
, IAuditLogAppService
|
|
|
|
|
|
{
|
|
|
|
|
|
public AuditLogAppService(IAuditLogRepository auditLogRepository) : base(auditLogRepository)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<AuditLogDto> GetAsync(Guid id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var entity = await Repository.GetAsync(id, includeDetails: true);
|
|
|
|
|
|
|
|
|
|
|
|
return await MapToGetOutputDtoAsync(entity);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[UnitOfWork]
|
|
|
|
|
|
public override async Task<PagedResultDto<AuditLogDto>> GetListAsync(PagedAndSortedResultRequestDto input)
|
|
|
|
|
|
{
|
|
|
|
|
|
var query = await CreateFilteredQueryAsync(input);
|
|
|
|
|
|
|
|
|
|
|
|
var totalCount = await AsyncExecuter.CountAsync(query);
|
|
|
|
|
|
|
|
|
|
|
|
query = ApplySorting(query, input);
|
|
|
|
|
|
query = ApplyPaging(query, input);
|
|
|
|
|
|
|
|
|
|
|
|
// EntityChanges ile birlikte getir (N+1 query önlenir)
|
|
|
|
|
|
var auditLogRepository = (IAuditLogRepository)Repository;
|
|
|
|
|
|
var auditLogsWithDetails = await auditLogRepository.GetListAsync(
|
|
|
|
|
|
sorting: input.Sorting,
|
|
|
|
|
|
maxResultCount: input.MaxResultCount,
|
|
|
|
|
|
skipCount: input.SkipCount,
|
|
|
|
|
|
includeDetails: true
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// Mapping tek seferde yap
|
|
|
|
|
|
var entityDtos = ObjectMapper.Map<List<AuditLog>, List<AuditLogDto>>(auditLogsWithDetails);
|
|
|
|
|
|
|
|
|
|
|
|
// EntityChangeCount'u doldur (artık EntityChanges yüklü)
|
|
|
|
|
|
foreach (var dto in entityDtos)
|
|
|
|
|
|
{
|
|
|
|
|
|
var auditLog = auditLogsWithDetails.FirstOrDefault(a => a.Id == dto.Id);
|
|
|
|
|
|
dto.EntityChangeCount = auditLog?.EntityChanges?.Count ?? 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new PagedResultDto<AuditLogDto>(
|
|
|
|
|
|
totalCount,
|
|
|
|
|
|
entityDtos
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Audit Log kayitlarini gormek istiyoruz fakat degistirmek istemiyoruz
|
|
|
|
|
|
[RemoteService(IsEnabled = false)]
|
|
|
|
|
|
public override Task<AuditLogDto> CreateAsync(AuditLogDto input)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[RemoteService(IsEnabled = false)]
|
|
|
|
|
|
public override Task<AuditLogDto> UpdateAsync(Guid id, AuditLogDto input)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[RemoteService(IsEnabled = false)]
|
|
|
|
|
|
public override Task DeleteAsync(Guid id)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|