11 changed files with 127 additions and 56 deletions
@ -1,21 +1,35 @@ |
|||||
using System.Threading.Tasks; |
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
using CompanyName.ProjectName.Extensions.Customs.Dtos; |
using CompanyName.ProjectName.Extensions.Customs.Dtos; |
||||
using CompanyName.ProjectName.QueryManagement.ElasticSearchs.Dtos; |
using CompanyName.ProjectName.QueryManagement.ElasticSearchs.Dtos; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
|
||||
namespace CompanyName.ProjectName.QueryManagement.ElasticSearchs |
namespace CompanyName.ProjectName.QueryManagement.ElasticSearchs |
||||
{ |
{ |
||||
public class LogAppService : QueryManagementAppService, ILogAppService |
public class LogAppService : QueryManagementAppService, ILogAppService |
||||
{ |
{ |
||||
private readonly ICompanyNameProjectNameLogRepository _companyNameProjectNameLogRepository; |
private readonly ICompanyNameProjectNameLogRepository _companyNameProjectNameLogRepository; |
||||
|
private readonly IConfiguration _configuration; |
||||
|
|
||||
public LogAppService(ICompanyNameProjectNameLogRepository companyNameProjectNameLogRepository) |
public LogAppService( |
||||
|
ICompanyNameProjectNameLogRepository companyNameProjectNameLogRepository, |
||||
|
IConfiguration configuration) |
||||
{ |
{ |
||||
_companyNameProjectNameLogRepository = companyNameProjectNameLogRepository; |
_companyNameProjectNameLogRepository = companyNameProjectNameLogRepository; |
||||
|
_configuration = configuration; |
||||
} |
} |
||||
|
|
||||
public Task<CustomePagedResultDto<PagingElasticSearchLogOutput>> PaingLogAsync(PagingElasticSearchLogInput input) |
public async Task<CustomePagedResultDto<PagingElasticSearchLogOutput>> PaingLogAsync(PagingElasticSearchLogInput input) |
||||
{ |
{ |
||||
return _companyNameProjectNameLogRepository.PaingAsync(input); |
var enabled = _configuration.GetValue<bool>("LogToElasticSearch:Enabled", false); |
||||
|
if (enabled) |
||||
|
{ |
||||
|
return await _companyNameProjectNameLogRepository.PaingAsync(input); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return new CustomePagedResultDto<PagingElasticSearchLogOutput>(0, new List<PagingElasticSearchLogOutput>()); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,7 +1,39 @@ |
|||||
namespace CompanyName.ProjectName.Users |
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Identity; |
||||
|
|
||||
|
namespace CompanyName.ProjectName.Users |
||||
{ |
{ |
||||
public class UserDataSeedContributor |
public class UserDataSeedContributor : IDataSeedContributor, ITransientDependency |
||||
|
{ |
||||
|
private readonly IdentityUserManager _userManager; |
||||
|
private readonly IdentityRoleManager _identityRoleManager; |
||||
|
|
||||
|
public UserDataSeedContributor( |
||||
|
IdentityUserManager userManager, |
||||
|
IdentityRoleManager identityRoleManager) |
||||
{ |
{ |
||||
|
_userManager = userManager; |
||||
|
_identityRoleManager = identityRoleManager; |
||||
|
} |
||||
|
|
||||
|
public async Task SeedAsync(DataSeedContext context) |
||||
|
{ |
||||
|
const string adminUserName = "admin"; |
||||
|
var adminUser = await _userManager.FindByNameAsync(adminUserName); |
||||
|
if (adminUser != null) |
||||
|
{ |
||||
|
await _userManager.SetLockoutEndDateAsync(adminUser, DateTimeOffset.UtcNow.AddDays(-1)); |
||||
|
} |
||||
|
|
||||
|
var role = await _identityRoleManager.FindByNameAsync(adminUserName); |
||||
|
if (role != null) |
||||
|
{ |
||||
|
role.IsDefault = true; |
||||
|
await _identityRoleManager.UpdateAsync(role); |
||||
|
} |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
Loading…
Reference in new issue