diff --git a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs index ac9129eca..bb271d4b2 100644 --- a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs +++ b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs @@ -140,7 +140,7 @@ namespace AuthServer.Host Configure(options => { // options.IsEnabledForGetRequests = true; - options.ApplicationName = "AuthServer"; + options.ApplicationName = "Identity-Server-STS"; }); Configure(options => diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs index 8871fa51a..820213e23 100644 --- a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs +++ b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs @@ -28,6 +28,7 @@ using Volo.Abp; using Volo.Abp.AspNetCore.Authentication.JwtBearer; using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; using Volo.Abp.AspNetCore.Security.Claims; +using Volo.Abp.Auditing; using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Autofac; @@ -209,6 +210,19 @@ namespace LINGYUN.Abp.BackendAdmin options.TenantResolvers.Insert(0, new AuthorizationTenantResolveContributor()); }); + Configure(options => + { + options.ApplicationName = "Backend-Admin"; + // 是否启用实体变更记录 + var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); + if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get()) + { + options + .EntityHistorySelectors + .AddAllEntities(); + } + }); + // Swagger context.Services.AddSwaggerGen( options => diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs index 7ffd9286f..a0850e287 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs @@ -16,6 +16,7 @@ using System; using System.Text; using Volo.Abp; using Volo.Abp.AspNetCore.Security.Claims; +using Volo.Abp.Auditing; using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.Autofac; using Volo.Abp.AutoMapper; @@ -122,6 +123,19 @@ namespace LINGYUN.ApiGateway options.IsEnabled = false; }); + Configure(options => + { + options.ApplicationName = "ApiGateWay-Admin"; + // 是否启用实体变更记录 + var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); + if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get()) + { + options + .EntityHistorySelectors + .AddAllEntities(); + } + }); + //Configure(options => //{ // options.TenantResolvers.Insert(0, new AuthorizationTenantResolveContributor()); diff --git a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs index 90c55321c..61ae931f1 100644 --- a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs +++ b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs @@ -24,6 +24,7 @@ using Volo.Abp.Account; using Volo.Abp.AspNetCore.Authentication.JwtBearer; using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; using Volo.Abp.AspNetCore.Security.Claims; +using Volo.Abp.Auditing; using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Autofac; @@ -150,6 +151,18 @@ namespace LINGYUN.Abp.IdentityServer4 options.DefaultReceiveEmail = "colin.in@foxmail.com"; }); + Configure(options => + { + options.ApplicationName = "Identity-Server-Admin"; + // 是否启用实体变更记录 + var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); + if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get()) + { + options + .EntityHistorySelectors + .AddAllEntities(); + } + }); Configure(options => { diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs index b465239df..a1d503d03 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs @@ -26,6 +26,7 @@ using Volo.Abp; using Volo.Abp.AspNetCore.Authentication.JwtBearer; using Volo.Abp.AspNetCore.MultiTenancy; using Volo.Abp.AspNetCore.Security.Claims; +using Volo.Abp.Auditing; using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.Autofac; using Volo.Abp.BlobStoring; @@ -184,6 +185,19 @@ namespace LINGYUN.Platform options.IsEnabled = true; }); + Configure(options => + { + options.ApplicationName = "Platform"; + // 是否启用实体变更记录 + var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); + if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get()) + { + options + .EntityHistorySelectors + .AddAllEntities(); + } + }); + Configure(options => { options.TenantResolvers.Insert(0, new AuthorizationTenantResolveContributor()); diff --git a/vueJs/src/api/auditing.ts b/vueJs/src/api/auditing.ts index ec2cf130a..5cd00a57d 100644 --- a/vueJs/src/api/auditing.ts +++ b/vueJs/src/api/auditing.ts @@ -82,6 +82,12 @@ export class SecurityLog { extraProperties?: {[key: string]: any} } +export enum ChangeType { + Created = 0, + Updated = 1, + Deleted = 2 +} + export class PropertyChange { id!: string newValue?: string @@ -93,7 +99,7 @@ export class PropertyChange { export class EntityChange { id!: string changeTime?: Date - changeType?: number + changeType?: ChangeType entityTenantId?: string entityId?: string entityTypeFullName?: string @@ -106,7 +112,7 @@ export class Action { serviceName?: string methodName?: string parameters?: string - executionTime?: Date + executionTime!: Date executionDuration?: number extraProperties?: {[key: string]: any} } diff --git a/vueJs/src/views/admin/auditing/audit-log/components/AuditLogProfile.vue b/vueJs/src/views/admin/auditing/audit-log/components/AuditLogProfile.vue index 3e66514bf..6488b3604 100644 --- a/vueJs/src/views/admin/auditing/audit-log/components/AuditLogProfile.vue +++ b/vueJs/src/views/admin/auditing/audit-log/components/AuditLogProfile.vue @@ -136,7 +136,7 @@ v-for="(action, index) in getActions" :key="index" :timestamp="getFormatDateTime(action.executionTime)" - :type="auditLog.httpStatusCode | httpStatusCodeFilter" + :type="auditLog.httpStatusCode | httpStatusCodeTimelineFilter" placement="top" > @@ -167,6 +167,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + import { Component, Vue, Prop, Watch } from 'vue-property-decorator' -import AuditingService, { Action, AuditLog } from '@/api/auditing' +import AuditingService, { Action, AuditLog, EntityChange, ChangeType } from '@/api/auditing' import { dateFormat } from '@/utils' import JsonEditor from '@/components/JsonEditor/index.vue' +const entityChangeTypeNameMap: { [key: number]: string } = { + [ChangeType.Created]: '新增', + [ChangeType.Updated]: '修改', + [ChangeType.Deleted]: '删除' +} +const entityChangeTypeTimelineMap: { [key: number]: string } = { + [ChangeType.Created]: 'success', + [ChangeType.Updated]: 'warning', + [ChangeType.Deleted]: 'danger' +} + @Component({ name: 'AuditLogProfile', components: { JsonEditor }, filters: { - httpStatusCodeFilter(httpStatusCode: number) { + httpStatusCodeTimelineFilter(httpStatusCode: number) { if (httpStatusCode >= 200 && httpStatusCode < 300) { return 'success' } @@ -225,6 +330,12 @@ import JsonEditor from '@/components/JsonEditor/index.vue' return 'danger' } return 'primary' + }, + entityChangeTypeNameFilter(type: ChangeType) { + return entityChangeTypeNameMap[type] + }, + entityChangeTypeTimelineFilter(type: ChangeType) { + return entityChangeTypeTimelineMap[type] } }, computed: { @@ -276,10 +387,28 @@ export default class extends Vue { get getActions() { if (this.auditLog.actions && this.auditLog.actions.length > 0) { - return this.auditLog.actions.reverse() + return this.sortByDateTime(this.auditLog.actions, 'executionTime') } return new Array() } + + get getEntitiesChanges() { + if (this.auditLog.entityChanges && this.auditLog.entityChanges.length > 0) { + return this.sortByDateTime(this.auditLog.entityChanges, 'changeTime') + } + return new Array() + } + + private sortByDateTime(array: Array, sortField: string) { + return array.sort((obj1, obj2) => { + if (obj1[sortField] && obj2[sortField]) { + const time1 = new Date(obj1[sortField]) + const time2 = new Date(obj2[sortField]) + return time1.getTime() - time2.getTime() + } + return 0 + }) + } } diff --git a/vueJs/src/views/admin/auditing/audit-log/index.vue b/vueJs/src/views/admin/auditing/audit-log/index.vue index 09a7212ec..b06dcd532 100644 --- a/vueJs/src/views/admin/auditing/audit-log/index.vue +++ b/vueJs/src/views/admin/auditing/audit-log/index.vue @@ -157,6 +157,21 @@ + + + 1000) { + return 'danger' + } } }, methods: { @@ -361,7 +390,7 @@ export default class extends mixins(DataListMiXin) { } -