19 changed files with 327 additions and 64 deletions
@ -0,0 +1,7 @@ |
|||
namespace LINGYUN.Abp.Account; |
|||
|
|||
public class GetUserClaimStateDto |
|||
{ |
|||
public bool IsBound { get; set; } |
|||
public string Value { get; set; } |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Account; |
|||
|
|||
public class SecurityLogDto : ExtensibleEntityDto<Guid> |
|||
{ |
|||
public string ApplicationName { get; set; } |
|||
|
|||
public string Identity { get; set; } |
|||
|
|||
public string Action { get; set; } |
|||
|
|||
public Guid? UserId { get; set; } |
|||
|
|||
public string UserName { get; set; } |
|||
|
|||
public string TenantName { get; set; } |
|||
|
|||
public string ClientId { get; set; } |
|||
|
|||
public string CorrelationId { get; set; } |
|||
|
|||
public string ClientIpAddress { get; set; } |
|||
|
|||
public string BrowserInfo { get; set; } |
|||
|
|||
public DateTime CreationTime { get; set; } |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Account; |
|||
|
|||
public class SecurityLogGetListInput : PagedAndSortedResultRequestDto |
|||
{ |
|||
public DateTime? StartTime { get; set; } |
|||
public DateTime? EndTime { get; set; } |
|||
public string ApplicationName { get; set; } |
|||
public string Identity { get; set; } |
|||
public string ActionName { get; set; } |
|||
public string ClientId { get; set; } |
|||
public string CorrelationId { get; set; } |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Account; |
|||
|
|||
public interface IMySecurityLogAppService |
|||
{ |
|||
Task<PagedResultDto<SecurityLogDto>> GetListAsync(SecurityLogGetListInput input); |
|||
|
|||
Task<SecurityLogDto> GetAsync(Guid id); |
|||
|
|||
Task DeleteAsync(Guid id); |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using AutoMapper; |
|||
using LINGYUN.Abp.AuditLogging; |
|||
|
|||
namespace LINGYUN.Abp.Account; |
|||
|
|||
public class AbpAccountMapperProfile : Profile |
|||
{ |
|||
public AbpAccountMapperProfile() |
|||
{ |
|||
CreateMap<SecurityLog, SecurityLogDto>(MemberList.Destination); |
|||
} |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
using LINGYUN.Abp.AuditLogging; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace LINGYUN.Abp.Account; |
|||
|
|||
[Authorize] |
|||
public class MySecurityLogAppService : AccountApplicationServiceBase, IMySecurityLogAppService |
|||
{ |
|||
protected ISecurityLogManager SecurityLogManager { get; } |
|||
public MySecurityLogAppService(ISecurityLogManager securityLogManager) |
|||
{ |
|||
SecurityLogManager = securityLogManager; |
|||
} |
|||
public async virtual Task<SecurityLogDto> GetAsync(Guid id) |
|||
{ |
|||
var securityLog = await SecurityLogManager.GetAsync(id, includeDetails: true); |
|||
|
|||
return ObjectMapper.Map<SecurityLog, SecurityLogDto>(securityLog); |
|||
} |
|||
|
|||
public async virtual Task<PagedResultDto<SecurityLogDto>> GetListAsync(SecurityLogGetListInput input) |
|||
{ |
|||
var userId = CurrentUser.GetId(); |
|||
var securityLogCount = await SecurityLogManager |
|||
.GetCountAsync(input.StartTime, input.EndTime, |
|||
input.ApplicationName, input.Identity, input.ActionName, |
|||
userId, null, input.ClientId, input.CorrelationId |
|||
); |
|||
|
|||
var securityLogs = await SecurityLogManager |
|||
.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, |
|||
input.StartTime, input.EndTime, |
|||
input.ApplicationName, input.Identity, input.ActionName, |
|||
userId, null, input.ClientId, input.CorrelationId, |
|||
includeDetails: false |
|||
); |
|||
|
|||
return new PagedResultDto<SecurityLogDto>(securityLogCount, |
|||
ObjectMapper.Map<List<SecurityLog>, List<SecurityLogDto>>(securityLogs)); |
|||
} |
|||
|
|||
public async virtual Task DeleteAsync(Guid id) |
|||
{ |
|||
await SecurityLogManager.DeleteAsync(id); |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
using Asp.Versioning; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Account; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace LINGYUN.Abp.Account; |
|||
|
|||
[Authorize] |
|||
[Area("account")] |
|||
[ControllerName("SecurityLog")] |
|||
[Route($"/api/{AccountRemoteServiceConsts.ModuleName}/security-logs")] |
|||
[RemoteService(Name = AccountRemoteServiceConsts.RemoteServiceName)] |
|||
public class MySecurityLogController : AbpControllerBase, IMySecurityLogAppService |
|||
{ |
|||
private readonly IMySecurityLogAppService _service; |
|||
public MySecurityLogController(IMySecurityLogAppService service) |
|||
{ |
|||
_service = service; |
|||
} |
|||
|
|||
[HttpDelete] |
|||
[Route("{id}")] |
|||
public virtual Task DeleteAsync(Guid id) |
|||
{ |
|||
return _service.DeleteAsync(id); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("{id}")] |
|||
public virtual Task<SecurityLogDto> GetAsync(Guid id) |
|||
{ |
|||
return _service.GetAsync(id); |
|||
} |
|||
|
|||
[HttpGet] |
|||
public virtual Task<PagedResultDto<SecurityLogDto>> GetListAsync(SecurityLogGetListInput input) |
|||
{ |
|||
return _service.GetListAsync(input); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue