Browse Source

添加审计日志

pull/10/head
王军 5 years ago
parent
commit
22fd0f8c67
  1. 9
      aspnet-core/frameworks/Extensions/src/CompanyName.ProjectName.Extensions/Customs/Dtos/PagingBase.cs
  2. 1
      aspnet-core/modules/DataDictionaryManagement/test/CompanyName.ProjectName.DataDictionaryManagement.TestBase/DataDictionaryManagementDataSeedContributor.cs
  3. 150
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/AuditLogs/GetAuditLogPageListOutput.cs
  4. 8
      aspnet-core/services/src/CompanyName.ProjectName.Application/AuditLogs/AuditLogAppService.cs
  5. 32693
      aspnet-core/services/src/CompanyName.ProjectName.HttpApi.Host/Logs/logs.txt
  6. 2
      aspnet-core/services/src/CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs
  7. 4
      aspnet-core/services/src/CompanyName.ProjectName.HttpApi/Controllers/Systems/AuditLogController.cs
  8. 10
      vben271/src/router/routes/modules/admin.ts
  9. 4
      vben271/src/settings/componentSetting.ts
  10. 75
      vben271/src/views/admin/auditLog/AuditLog.ts
  11. 47
      vben271/src/views/admin/auditLog/AuditLog.vue

9
aspnet-core/frameworks/Extensions/src/CompanyName.ProjectName.Extensions/Customs/Dtos/PagingBase.cs

@ -27,15 +27,10 @@ namespace CompanyName.ProjectName.Extensions.Customs
/// </summary>
public int SkipCount => (PageIndex - 1) * PageSize;
public PagingBase()
protected PagingBase()
{
}
/// <summary>
/// 实例化 <see cref="BeeQueryPagingInput"/> 对象
/// </summary>
/// <param name="pageIndex">当前页面</param>
/// <param name="pageSize">每页多少条</param>
public PagingBase(int pageIndex = 1, int pageSize = 10)
{
PageIndex = pageIndex;

1
aspnet-core/modules/DataDictionaryManagement/test/CompanyName.ProjectName.DataDictionaryManagement.TestBase/DataDictionaryManagementDataSeedContributor.cs

@ -27,6 +27,7 @@ namespace CompanyName.ProjectName.DataDictionaryManagement
/* Instead of returning the Task.CompletedTask, you can insert your test data
* at this point!
*/
await Task.CompletedTask;
}
}
}

150
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/AuditLogs/GetAuditLogPageListOutput.cs

@ -4,118 +4,42 @@ namespace CompanyName.ProjectName.AuditLogs
{
public class GetAuditLogPageListOutput
{
public string ApplicationName
{
get;
set;
}
public Guid? UserId
{
get;
set;
}
public string UserName
{
get;
set;
}
public Guid? TenantId
{
get;
set;
}
public string TenantName
{
get;
set;
}
public Guid? ImpersonatorUserId
{
get;
set;
}
public Guid? ImpersonatorTenantId
{
get;
set;
}
public virtual DateTime ExecutionTime
{
get;
set;
}
public int ExecutionDuration
{
get;
set;
}
public string ClientIpAddress
{
get;
set;
}
public string ClientName
{
get;
set;
}
public string ClientId
{
get;
set;
}
public string CorrelationId
{
get;
set;
}
public string BrowserInfo
{
get;
set;
}
public string HttpMethod
{
get;
set;
}
public string Url
{
get;
set;
}
public string Exceptions
{
get;
set;
}
public string Comments
{
get;
set;
}
public int? HttpStatusCode
{
get;
set;
}
public string ApplicationName { get; set; }
public Guid? UserId { get; set; }
public string UserName { get; set; }
public Guid? TenantId { get; set; }
public string TenantName { get; set; }
public Guid? ImpersonatorUserId { get; set; }
public Guid? ImpersonatorTenantId { get; set; }
public DateTime ExecutionTime { get; set; }
public int ExecutionDuration { get; set; }
public string ClientIpAddress { get; set; }
public string ClientName { get; set; }
public string ClientId { get; set; }
public string CorrelationId { get; set; }
public string BrowserInfo { get; set; }
public string HttpMethod { get; set; }
public string Url { get; set; }
public string Exceptions { get; set; }
public string Comments { get; set; }
public int? HttpStatusCode { get; set; }
}
}

8
aspnet-core/services/src/CompanyName.ProjectName.Application/AuditLogs/AuditLogAppService.cs

@ -25,8 +25,8 @@ namespace CompanyName.ProjectName.AuditLogs
input.Sorting,
input.PageSize,
input.SkipCount,
input.StartTime,
input.EndTime,
input.StartTime?.Date,
input.EndTime?.Date,
input.HttpMethod,
input.Url,
null,
@ -38,8 +38,8 @@ namespace CompanyName.ProjectName.AuditLogs
input.HasException,
input.HttpStatusCode);
var totalCount = await _auditLogRepository.GetCountAsync(
input.StartTime,
input.EndTime,
input.StartTime?.Date,
input.EndTime?.Date,
input.HttpMethod,
input.Url,
null,

32693
aspnet-core/services/src/CompanyName.ProjectName.HttpApi.Host/Logs/logs.txt

File diff suppressed because it is too large

2
aspnet-core/services/src/CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs

@ -63,7 +63,7 @@ namespace CompanyName.ProjectName
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
{
context.CreateRecurringJob();
// context.CreateRecurringJob();
base.OnPostApplicationInitialization(context);
}

4
aspnet-core/services/src/CompanyName.ProjectName.HttpApi/Controllers/Systems/AuditLogController.cs

@ -11,7 +11,7 @@ using Volo.Abp.Identity;
namespace CompanyName.ProjectName.Controllers.Systems
{
[Route("AuditLogs")]
[Authorize]
//[Authorize]
public class AuditLogController:ProjectNameController
{
private readonly IAuditLogAppService _auditLogAppService;
@ -22,7 +22,7 @@ namespace CompanyName.ProjectName.Controllers.Systems
}
[HttpPost("page")]
[Authorize(ProjectNamePermissions.AbpIdentityExtend.AuditLogQuery)]
//[Authorize(ProjectNamePermissions.AbpIdentityExtend.AuditLogQuery)]
[SwaggerOperation(summary: "分页获取用户信息", Tags = new[] { "AuditLogs" })]
public Task<PagedResultDto<GetAuditLogPageListOutput>> ListAsync(PagingAuditLogListInput input)
{

10
vben271/src/router/routes/modules/admin.ts

@ -37,6 +37,16 @@ const admin: AppRouteModule = {
icon: 'ant-design:lock-outlined',
},
},
{
path: 'abpAuditLogs',
name: 'AuditLogs',
component: () => import('/@/views/admin/auditLog/AuditLog.vue'),
meta: {
title: '审计日志',
//policy: 'AbpIdentity.Roles.Query',
icon: 'ant-design:snippets-twotone',
},
},
{
path: 'hangfire',
name: '后台任务',

4
vben271/src/settings/componentSetting.ts

@ -9,13 +9,13 @@ export default {
// support xxx.xxx.xxx
fetchSetting: {
// The field name of the current page passed to the background
pageField: 'page',
pageField: 'pageIndex',
// The number field name of each page displayed in the background
sizeField: 'pageSize',
// Field name of the form data returned by the interface
listField: 'items',
// Total number of tables returned by the interface field name
totalField: 'total',
totalField: 'totalCount',
},
// Number of pages that can be selected
pageSizeOptions: ['10', '50', '80', '100'],

75
vben271/src/views/admin/auditLog/AuditLog.ts

@ -0,0 +1,75 @@
import { FormSchema } from '/@/components/Table';
import { BasicColumn } from '/@/components/Table';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
import moment from 'moment';
import { AuditLogsServiceProxy, PagingAuditLogListInput } from '/@/services/ServiceProxies';
export const searchFormSchema: FormSchema[] = [
{
field: 'userName',
label: '用户',
component: 'Input',
colProps: { span: 8 },
},
{
field: 'time',
component: 'RangePicker',
label: '执行时间',
colProps: {
span: 6,
},
},
];
export const tableColumns: BasicColumn[] = [
{
title: '租户',
dataIndex: 'tenantName',
width: 100,
},
{
title: '用户',
dataIndex: 'userName',
width: 100,
},
{
title: 'HttpMethod',
dataIndex: 'httpMethod',
width: 100,
},
{
title: 'HttpStatusCode',
dataIndex: 'httpStatusCode',
width: 120,
},
{
title: 'Url',
dataIndex: 'url',
width: 250,
},
{
title: 'ExecutionTime',
dataIndex: 'executionTime',
width: 150,
customRender: ({ text }) => {
return moment(text).format('YYYY-MM-DD HH:mm:ss');
},
},
{
title: 'BrowserInfo',
dataIndex: 'browserInfo',
},
{
title: 'Exceptions',
dataIndex: 'exceptions',
},
];
/**
*
* @param params
* @returns
*/
export async function getTableListAsync(params: PagingAuditLogListInput) {
const _auditLogsServiceProxy = new AuditLogsServiceProxy();
return _auditLogsServiceProxy.page(params);
}

47
vben271/src/views/admin/auditLog/AuditLog.vue

@ -0,0 +1,47 @@
<template>
<div>
<BasicTable @register="registerTable" size="small"> </BasicTable>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { tableColumns, searchFormSchema, getTableListAsync } from './AuditLog';
import { Tag } from 'ant-design-vue';
import { useI18n } from '/@/hooks/web/useI18n';
export default defineComponent({
name: 'AuditLog',
components: {
BasicTable,
TableAction,
Tag,
},
setup() {
const { t } = useI18n();
// table
const [registerTable, { reload }] = useTable({
columns: tableColumns,
formConfig: {
labelWidth: 70,
schemas: searchFormSchema,
fieldMapToTime: [
['time', ['executionBeginTime', 'executionEndTime'], 'YYYY-MM-DD HH:mm:ss'],
],
},
api: getTableListAsync,
showTableSetting: true,
useSearchForm: true,
bordered: true,
canResize: true,
showIndexColumn: true,
});
return {
registerTable,
reload,
t,
};
},
});
</script>
Loading…
Cancel
Save