49 changed files with 1980 additions and 428 deletions
@ -1,10 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<PackageReference Include="NEST" Version="7.14.1" /> |
|||
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="4.4.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -1,9 +0,0 @@ |
|||
using System; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Lion.Abp.ElasticSearch |
|||
{ |
|||
public class LionAbpElasticSearchModule : AbpModule |
|||
{ |
|||
} |
|||
} |
|||
@ -1,31 +0,0 @@ |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.NotificationManagement.Notifications.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace CompanyName.ProjectName.NotificationManagement.Notifications |
|||
{ |
|||
public interface IQueryNotificationAppService : IApplicationService |
|||
{ |
|||
/// <summary>
|
|||
/// 分页获取用户普通文本消息
|
|||
/// </summary>
|
|||
/// <param name="listInput"></param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<PagedResultDto<PagingNotificationListOutput>> GetPageTextNotificationByUserIdAsync( |
|||
PagingNotificationListInput listInput, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
/// <summary>
|
|||
/// 分页获取广播消息
|
|||
/// </summary>
|
|||
/// <param name="listInput"></param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<PagedResultDto<PagingNotificationListOutput>> GetPageBroadCastNotificationByUserIdAsync( |
|||
PagingNotificationListInput listInput, |
|||
CancellationToken cancellationToken = default); |
|||
} |
|||
} |
|||
@ -1,68 +0,0 @@ |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.NotificationManagement.Notifications.Dtos; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Users; |
|||
|
|||
|
|||
namespace CompanyName.ProjectName.NotificationManagement.Notifications |
|||
{ |
|||
public class QueryNotificationAppService : NotificationManagementAppService, IQueryNotificationAppService |
|||
{ |
|||
private readonly IDapperNotificationRepository _dapperNotificationRepository; |
|||
private readonly ICurrentUser _currentUser; |
|||
|
|||
public QueryNotificationAppService(IDapperNotificationRepository dapperNotificationRepository, ICurrentUser currentUser) |
|||
{ |
|||
_dapperNotificationRepository = dapperNotificationRepository; |
|||
_currentUser = currentUser; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 分页获取用户普通文本消息
|
|||
/// </summary>
|
|||
/// <param name="listInput"></param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
public async Task<PagedResultDto<PagingNotificationListOutput>> GetPageTextNotificationByUserIdAsync( |
|||
PagingNotificationListInput listInput, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
if (!_currentUser.Id.HasValue) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
var totalCount = |
|||
await _dapperNotificationRepository.GetPageTextNotificationCountByUserIdAsync(_currentUser.Id.Value, cancellationToken); |
|||
var list = await _dapperNotificationRepository.GetPageTextNotificationByUserIdAsync(_currentUser.Id.Value, |
|||
listInput.PageSize, |
|||
listInput.SkipCount, cancellationToken); |
|||
return new PagedResultDto<PagingNotificationListOutput>(totalCount, list); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 分页获取广播消息
|
|||
/// </summary>
|
|||
/// <param name="listInput"></param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
public async Task<PagedResultDto<PagingNotificationListOutput>> GetPageBroadCastNotificationByUserIdAsync( |
|||
PagingNotificationListInput listInput, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
if (!_currentUser.Id.HasValue) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
var totalCount = |
|||
await _dapperNotificationRepository.GetPageBroadCastNotificationCountByUserIdAsync(_currentUser.Id.Value, |
|||
cancellationToken); |
|||
var list = await _dapperNotificationRepository.GetPageBroadCastNotificationByUserIdAsync(_currentUser.Id.Value, |
|||
listInput.PageSize, |
|||
listInput.SkipCount, cancellationToken); |
|||
return new PagedResultDto<PagingNotificationListOutput>(totalCount, list); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.ElasticsearchRepository.Dto; |
|||
using Lion.Abp.Extension; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace CompanyName.ProjectName.ElasticSearchs |
|||
{ |
|||
public interface ICompanyNameProjectNameLogAppService : IApplicationService |
|||
{ |
|||
/// <summary>
|
|||
/// 分页查询es日志
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
Task<CustomePagedResultDto<PagingElasticSearchLogOutput>> PaingAsync(PagingElasticSearchLogInput input); |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.Roles.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace CompanyName.ProjectName.Roles |
|||
{ |
|||
public interface IRolePermissionAppService : IApplicationService |
|||
{ |
|||
|
|||
Task<PermissionOutput> GetPermissionAsync(GetPermissionInput input); |
|||
|
|||
Task UpdatePermissionAsync(UpdateRolePermissionsInput input); |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using EasyAbp.Abp.SettingUi.Dto; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace CompanyName.ProjectName.Settings |
|||
{ |
|||
public interface ISettingAppService : IApplicationService |
|||
{ |
|||
/// <summary>
|
|||
/// 获取setting信息
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
Task<List<SettingGroup>> GetAsync(); |
|||
|
|||
/// <summary>
|
|||
/// 更新setting
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
Task UpdateAsync(UpdateSettingInput input); |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.ElasticsearchRepository; |
|||
using CompanyName.ProjectName.ElasticsearchRepository.Dto; |
|||
using Lion.Abp.Extension; |
|||
|
|||
namespace CompanyName.ProjectName.ElasticSearchs |
|||
{ |
|||
public class CompanyNameProjectNameLogAppService:ProjectNameAppService,ICompanyNameProjectNameLogAppService |
|||
{ |
|||
private readonly ICompanyNameProjectNameLogRepository _companyNameProjectNameLogRepository; |
|||
|
|||
public CompanyNameProjectNameLogAppService(ICompanyNameProjectNameLogRepository companyNameProjectNameLogRepository) |
|||
{ |
|||
_companyNameProjectNameLogRepository = companyNameProjectNameLogRepository; |
|||
} |
|||
|
|||
public Task<CustomePagedResultDto<PagingElasticSearchLogOutput>> PaingAsync(PagingElasticSearchLogInput input) |
|||
{ |
|||
return _companyNameProjectNameLogRepository.PaingAsync(input); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,149 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.Roles.Dtos; |
|||
using Volo.Abp.PermissionManagement; |
|||
|
|||
namespace CompanyName.ProjectName.Roles |
|||
{ |
|||
public class RolePermissionAppService : ProjectNameAppService, IRolePermissionAppService |
|||
{ |
|||
private readonly IPermissionAppService _rolePermissionAppService; |
|||
|
|||
public RolePermissionAppService(IPermissionAppService rolePermissionAppService) |
|||
{ |
|||
_rolePermissionAppService = rolePermissionAppService; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取所有权限
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public async Task<PermissionOutput> GetPermissionAsync(GetPermissionInput input) |
|||
{ |
|||
var permissions = |
|||
await _rolePermissionAppService.GetAsync(input.ProviderName, input.ProviderKey); |
|||
return BuildTreeData(permissions.Groups); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 更新权限
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
public async Task UpdatePermissionAsync(UpdateRolePermissionsInput input) |
|||
{ |
|||
await _rolePermissionAppService.UpdateAsync(input.ProviderName, input.ProviderKey, |
|||
input.UpdatePermissionsDto); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 生成权限树
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
private PermissionOutput BuildTreeData(List<PermissionGroupDto> input) |
|||
{ |
|||
var result = new PermissionOutput(); |
|||
var excludes = new List<string> |
|||
{ |
|||
"AbpIdentity.Users.ManagePermissions", |
|||
"FeatureManagement", |
|||
"FeatureManagement.ManageHostFeatures", |
|||
// "AbpTenantManagement",
|
|||
// "AbpTenantManagement.Tenants",
|
|||
// "AbpTenantManagement.Tenants.Create",
|
|||
// "AbpTenantManagement.Tenants.Update",
|
|||
// "AbpTenantManagement.Tenants.Delete",
|
|||
"AbpTenantManagement.Tenants.ManageFeatures", |
|||
// "AbpTenantManagement.Tenants.ManageConnectionStrings",
|
|||
"SettingManagement", |
|||
"SettingManagement.Emailing", |
|||
"SettingUi" |
|||
}; |
|||
|
|||
var permissions = new List<PermissionTreeDto>(); |
|||
|
|||
foreach (var group in input) |
|||
{ |
|||
if (excludes.Any(e => e == group.Name)) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
var groupPermission = new PermissionTreeDto |
|||
{ Key = @group.Name, Title = @group.DisplayName }; |
|||
groupPermission.Key = group.Name; |
|||
groupPermission.Title = |
|||
group.Name == "AbpIdentity" |
|||
? L["Permission:SystemManagement"] |
|||
: group.DisplayName; |
|||
foreach (var item in group.Permissions) |
|||
{ |
|||
result.AllGrants.Add(item.Name); |
|||
if (item.IsGranted) |
|||
{ |
|||
result.Grants.Add(item.Name); |
|||
} |
|||
|
|||
//获取ParentName=null的权限
|
|||
var management = group.Permissions |
|||
.Where(e => string.IsNullOrWhiteSpace(e.ParentName)).ToList(); |
|||
|
|||
foreach (var managementItem in management) |
|||
{ |
|||
if (groupPermission.Children.Any(e => e.Key == managementItem.Name)) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
{ |
|||
var managementPermission = new PermissionTreeDto() |
|||
{ |
|||
Key = managementItem.Name, |
|||
Title = managementItem.DisplayName |
|||
}; |
|||
// 获取management下权限
|
|||
var childrenPermission = @group.Permissions |
|||
.Where(e => e.ParentName == managementItem.Name) |
|||
.ToList(); |
|||
foreach (var childrenPermissionItem in childrenPermission) |
|||
{ |
|||
managementPermission.Children.Add(new PermissionTreeDto() |
|||
{ |
|||
Key = childrenPermissionItem.Name, |
|||
Title = childrenPermissionItem.DisplayName |
|||
}); |
|||
} |
|||
|
|||
groupPermission.Children.Add(managementPermission); |
|||
} |
|||
} |
|||
} |
|||
|
|||
permissions.Add(groupPermission); |
|||
} |
|||
|
|||
result.Permissions = permissions; |
|||
|
|||
var settingUIPermisstion = "SettingUi.ShowSettingPage"; |
|||
// https://github.com/EasyAbp/Abp.SettingUi/blob/develop/src/EasyAbp.Abp.SettingUi.Application/SettingUiAppService.cs
|
|||
// 因为使用的SettingUI模块,想把权限添加到系统管理下
|
|||
result.Permissions.First(e => e.Key == "AbpIdentity").Children.Add( |
|||
new PermissionTreeDto() |
|||
{ |
|||
Key = settingUIPermisstion, |
|||
Title = L["Permission:SettingUi:ShowSettingPage"] |
|||
}); |
|||
result.AllGrants.Add(settingUIPermisstion); |
|||
|
|||
var setting = input.First(e => e.Name == "SettingUi").Permissions |
|||
.First(e => e.Name == settingUIPermisstion); |
|||
if (setting.IsGranted) |
|||
{ |
|||
result.Grants.Add(settingUIPermisstion); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using EasyAbp.Abp.SettingUi; |
|||
using EasyAbp.Abp.SettingUi.Dto; |
|||
|
|||
namespace CompanyName.ProjectName.Settings |
|||
{ |
|||
public class SettingAppService : ProjectNameAppService, ISettingAppService |
|||
{ |
|||
private readonly ISettingUiAppService _settingUiAppService; |
|||
|
|||
public SettingAppService(ISettingUiAppService settingUiAppService) |
|||
{ |
|||
_settingUiAppService = settingUiAppService; |
|||
} |
|||
|
|||
|
|||
public async Task<List<SettingGroup>> GetAsync() |
|||
{ |
|||
return await _settingUiAppService.GroupSettingDefinitions(); |
|||
} |
|||
|
|||
public async Task UpdateAsync(UpdateSettingInput input) |
|||
{ |
|||
await _settingUiAppService.SetSettingValues(input.Values); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Core" Version="4.4.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="NEST" Version="7.14.1" /> |
|||
<ProjectReference Include="..\CompanyName.ProjectName.Domain\CompanyName.ProjectName.Domain.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,69 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.ElasticsearchRepository.Dto; |
|||
using Lion.Abp.Extension; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Nest; |
|||
|
|||
namespace CompanyName.ProjectName.ElasticsearchRepository |
|||
{ |
|||
public class CompanyNameProjectNameLogRepository : ElasticsearchBasicRepository, |
|||
ICompanyNameProjectNameLogRepository |
|||
{ |
|||
private readonly IConfiguration _configuration; |
|||
|
|||
public CompanyNameProjectNameLogRepository( |
|||
IElasticsearchProvider elasticsearchProvider, |
|||
IConfiguration configuration) : base(elasticsearchProvider) |
|||
{ |
|||
_configuration = configuration; |
|||
} |
|||
|
|||
public async Task<CustomePagedResultDto<PagingElasticSearchLogOutput>> PaingAsync( |
|||
PagingElasticSearchLogInput input) |
|||
{ |
|||
var IndexName = |
|||
_configuration.GetValue<string>("ElasticSearch:SearchIndexFormat"); |
|||
// 默认查询当天
|
|||
input.StartCreationTime = input.StartCreationTime?.AddMilliseconds(-1) ?? |
|||
DateTime.Now.Date.AddMilliseconds(-1); |
|||
input.EndCreationTime = |
|||
input.EndCreationTime?.AddDays(1).AddMilliseconds(-1) ?? |
|||
DateTime.Now.Date.AddDays(1).AddMilliseconds(-1); |
|||
var mustFilters = |
|||
new List<Func<QueryContainerDescriptor<PagingElasticSearchLogOutput>, |
|||
QueryContainer>> |
|||
{ |
|||
t => t.DateRange(f => |
|||
f.Field(fd => fd.CreationTime).TimeZone("Asia/Shanghai") |
|||
.GreaterThanOrEquals(input.StartCreationTime.Value)), |
|||
t => t.DateRange( |
|||
f => f.Field(fd => fd.CreationTime).TimeZone("Asia/Shanghai") |
|||
.LessThanOrEquals(input.EndCreationTime.Value)) |
|||
}; |
|||
|
|||
if (!string.IsNullOrWhiteSpace(input.Filter)) |
|||
{ |
|||
mustFilters.Add(t => |
|||
t.MatchPhrase(f => f.Field(fd => fd.Message).Query(input.Filter.Trim()))); |
|||
} |
|||
|
|||
var result = await Client.SearchAsync<PagingElasticSearchLogOutput>(e => e |
|||
.Index(IndexName) |
|||
.From(input.SkipCount) |
|||
.Size(input.PageSize) |
|||
.Sort(s => s.Descending(sd => sd.CreationTime)) |
|||
.Query(q => q.Bool(qb => qb.Filter(mustFilters)))); |
|||
|
|||
if (result.HitsMetadata != null) |
|||
{ |
|||
return new CustomePagedResultDto<PagingElasticSearchLogOutput>( |
|||
result.HitsMetadata.Total.Value, result.Documents.ToList()); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using Lion.Abp.Extension; |
|||
|
|||
namespace CompanyName.ProjectName.ElasticsearchRepository.Dto |
|||
{ |
|||
public class PagingElasticSearchLogInput : PagingBase |
|||
{ |
|||
public string Filter { get; set; } |
|||
|
|||
public DateTime? StartCreationTime { get; set; } |
|||
|
|||
public DateTime? EndCreationTime { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using System; |
|||
using Nest; |
|||
|
|||
namespace CompanyName.ProjectName.ElasticsearchRepository.Dto |
|||
{ |
|||
[Serializable] |
|||
public class PagingElasticSearchLogOutput |
|||
{ |
|||
/// <summary>
|
|||
/// 日志级别
|
|||
/// </summary>
|
|||
public string Level { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 日志内容
|
|||
/// </summary>
|
|||
public string Message { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
[PropertyName("@timestamp")] |
|||
public DateTime CreationTime { get; set; } |
|||
} |
|||
} |
|||
@ -1,7 +1,7 @@ |
|||
using Nest; |
|||
using Volo.Abp.Domain.Services; |
|||
|
|||
namespace Lion.Abp.ElasticSearch |
|||
namespace CompanyName.ProjectName.ElasticsearchRepository |
|||
{ |
|||
public abstract class ElasticsearchBasicRepository : DomainService |
|||
{ |
|||
@ -0,0 +1,17 @@ |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.ElasticsearchRepository.Dto; |
|||
using Lion.Abp.Extension; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace CompanyName.ProjectName.ElasticsearchRepository |
|||
{ |
|||
public interface ICompanyNameProjectNameLogRepository : ITransientDependency |
|||
{ |
|||
/// <summary>
|
|||
/// 分页查询es日志
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
Task<CustomePagedResultDto<PagingElasticSearchLogOutput>> PaingAsync(PagingElasticSearchLogInput input); |
|||
} |
|||
} |
|||
@ -1,7 +1,7 @@ |
|||
using Nest; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Lion.Abp.ElasticSearch |
|||
namespace CompanyName.ProjectName.ElasticsearchRepository |
|||
{ |
|||
public interface IElasticsearchProvider : ISingletonDependency |
|||
{ |
|||
@ -0,0 +1,10 @@ |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace CompanyName.ProjectName.ElasticsearchRepository |
|||
{ |
|||
|
|||
public class ProjectNameElasticSearchModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.ElasticsearchRepository.Dto; |
|||
using CompanyName.ProjectName.ElasticSearchs; |
|||
using CompanyName.ProjectName.Permissions; |
|||
using Lion.Abp.Extension; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Swashbuckle.AspNetCore.Annotations; |
|||
|
|||
namespace CompanyName.ProjectName.Controllers.Systems |
|||
{ |
|||
[Route("EsLog")] |
|||
public class CompanyNameProjectNameLogController: ProjectNameController,ICompanyNameProjectNameLogAppService |
|||
{ |
|||
private readonly ICompanyNameProjectNameLogAppService _companyNameProjectNameLogAppService; |
|||
|
|||
public CompanyNameProjectNameLogController(ICompanyNameProjectNameLogAppService companyNameProjectNameLogAppService) |
|||
{ |
|||
_companyNameProjectNameLogAppService = companyNameProjectNameLogAppService; |
|||
} |
|||
|
|||
[HttpPost("page")] |
|||
[SwaggerOperation(summary: "分页获取Es日志", Tags = new[] { "EsLog" })] |
|||
[Authorize(Policy = ProjectNamePermissions.SystemManagement.ES)] |
|||
public Task<CustomePagedResultDto<PagingElasticSearchLogOutput>> PaingAsync(PagingElasticSearchLogInput input) |
|||
{ |
|||
return _companyNameProjectNameLogAppService.PaingAsync(input); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
Loading…
Reference in new issue