问题描述
我正在使用 aspnet 样板 react。
一切都按预期进行。租户、控制器,甚至 odata 控制器现在都运行良好。每个控制器为其实体写入审计数据。但我现在有兴趣访问这些审计数据。在数据库方面,数据被写入到诸如 auditLog 之类的表中,并作为每个实体表的附加列。
如何访问审计数据?收集工作正常。但不知道如何访问它并在前端显示。
我的尝试像
AsyncCrudAppService
或者编写 odata 控制器不起作用。
解决方法
[AbpAuthorize(PermissionNames.Pages_Users)]
[DisableAuditing]
public class AuditLogAppService : AsyncCrudAppService<AuditLog,AuditedEntityDto<long>,long,PagedResultRequestDto,AuditedEntityDto<long>>
{
public AuditLogAppService(
IRepository<AuditLog,long> repository,UserManager userManager,RoleManager roleManager,IRepository<Role> roleRepository,IPasswordHasher<User> passwordHasher,IAbpSession abpSession,LogInManager logInManager)
: base(repository)
{
}
public Task<ListResultDto<AuditLog>> GetAllAudits()
{
object audits = Repository.GetAll();
return Task.FromResult(new ListResultDto<AuditLog>(
ObjectMapper.Map<List<AuditLog>>(audits).ToList()
));
}
}