From 82c37ba110bd28503c37742e3bb346ed9ba78b5e Mon Sep 17 00:00:00 2001 From: WangJunZzz <510423039@qq.com> Date: Mon, 27 Jun 2022 21:38:34 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20=20=E5=8D=87=E7=BA=A7abp5.?= =?UTF-8?q?3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aspnet-core/Directory.Build.props | 27 +++++++++------- .../Lion.AbpPro.Extension.csproj | 5 +-- .../AbpProHttpApiHostModule.cs | 3 +- .../Extensions/RecurringJobsExtensions.cs | 6 ++-- .../appsettings.Staging.json | 4 +-- .../Lion.AbpPro.HttpApi.Host/appsettings.json | 4 +-- .../Roles/RoleAppService.cs | 2 +- .../Users/AccountAppService.cs | 14 ++++----- .../Users/UserAppService.cs | 31 ++++++++++++++++--- ...bpPro.HttpApi.Client.ConsoleTestApp.csproj | 2 +- 10 files changed, 60 insertions(+), 38 deletions(-) diff --git a/aspnet-core/Directory.Build.props b/aspnet-core/Directory.Build.props index 1c765496..bdd2a366 100644 --- a/aspnet-core/Directory.Build.props +++ b/aspnet-core/Directory.Build.props @@ -1,23 +1,27 @@  - 5.2.1 - 6.0.0 - 6.0.0 + 5.3.0 + 6.1.0 + 6.0.6 + 6.0.1 + 6.0.0 6.0.0-preview.4.21253.7 6.0.0 6.2.3 17.0.0 - 2.5.200 + 3.0.100 + 6.3.1 + 17.2.0 4.2.22 2.2.0 - 2.10.0 - 3.0.1 + 2.11.0 + 3.1.0 1.5.0 5.0.0 - 4.0.0 - 4.1.0 - 7.0.0 + 4.0.1 + 5.0.0 + 8.2.0 3.3.0 8.4.1 13.0.1 @@ -28,9 +32,8 @@ 2.4.1 2.4.3 17.0.0 - 2.6.1 - 6.0.11 - 3.0.100 + 2.6.4 + 6.0.15 \ No newline at end of file diff --git a/aspnet-core/frameworks/Extensions/src/Lion.AbpPro.Extension/Lion.AbpPro.Extension.csproj b/aspnet-core/frameworks/Extensions/src/Lion.AbpPro.Extension/Lion.AbpPro.Extension.csproj index 7de3dcdd..8d43885d 100644 --- a/aspnet-core/frameworks/Extensions/src/Lion.AbpPro.Extension/Lion.AbpPro.Extension.csproj +++ b/aspnet-core/frameworks/Extensions/src/Lion.AbpPro.Extension/Lion.AbpPro.Extension.csproj @@ -6,7 +6,7 @@ - + @@ -16,8 +16,5 @@ - - - diff --git a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.cs b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.cs index c24cef6d..1586aeb0 100644 --- a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.cs +++ b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.cs @@ -42,7 +42,6 @@ using Microsoft.AspNetCore.Mvc; using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.Identity; -using Volo.Abp.AspNetCore.ExceptionHandling; namespace Lion.AbpPro { @@ -89,7 +88,7 @@ namespace Lion.AbpPro { var app = context.GetApplicationBuilder(); var configuration = context.GetConfiguration(); - app.UseRequestLog(); + //app.UseRequestLog(); app.UseAbpRequestLocalization(); app.UseCorrelationId(); app.UseStaticFiles(); diff --git a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/RecurringJobsExtensions.cs b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/RecurringJobsExtensions.cs index f8d71897..2872a18d 100644 --- a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/RecurringJobsExtensions.cs +++ b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/RecurringJobsExtensions.cs @@ -1,3 +1,4 @@ +using System; using Hangfire; using Lion.AbpPro.Extensions.Hangfire; using Lion.AbpPro.Jobs; @@ -11,9 +12,8 @@ namespace Lion.AbpPro.Extensions public static void CreateRecurringJob(this ApplicationInitializationContext context) { using var scope = context.ServiceProvider.CreateScope(); - var testJob = - scope.ServiceProvider.GetService(); - RecurringJob.AddOrUpdate("测试Job", () => testJob.ExecuteAsync(), CronType.Minute(1)); + var testJob = scope.ServiceProvider.GetService(); + RecurringJob.AddOrUpdate("测试Job", () => testJob.ExecuteAsync(), CronType.Minute(1), TimeZoneInfo.Local); } } } \ No newline at end of file diff --git a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Staging.json b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Staging.json index 2b4e393d..0f0ba919 100644 --- a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Staging.json +++ b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Staging.json @@ -10,9 +10,9 @@ "Configuration": "localhost,password=mypassword,defaultdatabase=1" }, "Jwt": { - "Audience": "http://localhost:5010", + "Audience": "Lion.AbpPro", "SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=", - "Issuer": "YHWmsOperationApiGateway", + "Issuer": "Lion.AbpPro", "ExpirationTime": 30 }, "Cap": { diff --git a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json index bb8f32cf..596300c7 100644 --- a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json @@ -40,9 +40,9 @@ "Configuration": "localhost,password=mypassword,defaultdatabase=1" }, "Jwt": { - "Audience": "http://localhost:5010", + "Audience": "Lion.AbpPro", "SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=", - "Issuer": "YHWmsOperationApiGateway", + "Issuer": "Lion.AbpPro", "ExpirationTime": 30 }, "Cap": { diff --git a/aspnet-core/services/src/Lion.AbpPro.Application/Roles/RoleAppService.cs b/aspnet-core/services/src/Lion.AbpPro.Application/Roles/RoleAppService.cs index 0a90a657..5d1a0b98 100644 --- a/aspnet-core/services/src/Lion.AbpPro.Application/Roles/RoleAppService.cs +++ b/aspnet-core/services/src/Lion.AbpPro.Application/Roles/RoleAppService.cs @@ -31,7 +31,7 @@ namespace Lion.AbpPro.Roles /// /// 获取所有角色 /// - /// + [Authorize] public async Task> AllListAsync() { List source = diff --git a/aspnet-core/services/src/Lion.AbpPro.Application/Users/AccountAppService.cs b/aspnet-core/services/src/Lion.AbpPro.Application/Users/AccountAppService.cs index d7c448aa..81f78490 100644 --- a/aspnet-core/services/src/Lion.AbpPro.Application/Users/AccountAppService.cs +++ b/aspnet-core/services/src/Lion.AbpPro.Application/Users/AccountAppService.cs @@ -28,22 +28,22 @@ namespace Lion.AbpPro.Users private readonly JwtOptions _jwtOptions; private readonly Microsoft.AspNetCore.Identity.SignInManager _signInManager; private readonly IHttpClientFactory _httpClientFactory; - private readonly IConfiguration _configuretion; + private readonly IConfiguration _configuration; private readonly Volo.Abp.Domain.Repositories.IRepository _identityRoleRepository; - + public AccountAppService( IdentityUserManager userManager, IOptionsSnapshot jwtOptions, Microsoft.AspNetCore.Identity.SignInManager signInManager, IHttpClientFactory httpClientFactory, - IConfiguration configuretion, + IConfiguration configuration, Volo.Abp.Domain.Repositories.IRepository identityRoleRepository) { _userManager = userManager; _jwtOptions = jwtOptions.Value; _signInManager = signInManager; _httpClientFactory = httpClientFactory; - _configuretion = configuretion; + _configuration = configuration; _identityRoleRepository = identityRoleRepository; } @@ -94,12 +94,12 @@ namespace Lion.AbpPro.Users var headers = new Dictionary { { "Accept", $"application/json" } }; // 通过code获取access token var accessTokenUrl = - $"login/oauth/access_token?client_id={_configuretion.GetValue("HttpClient:Github:ClientId")}&client_secret={_configuretion.GetValue("HttpClient:Github:ClientSecret")}&code={code}"; + $"login/oauth/access_token?client_id={_configuration.GetValue("HttpClient:Github:ClientId")}&client_secret={_configuration.GetValue("HttpClient:Github:ClientSecret")}&code={code}"; var accessTokenResponse = await _httpClientFactory.GetAsync(HttpClientNameConsts.Github, accessTokenUrl, headers); // 获取github用户信息 headers.Add("Authorization", $"token {accessTokenResponse.Access_token}"); - headers.Add("User-Agent", _configuretion.GetValue("HttpClient:GithubApi:ClientName")); + headers.Add("User-Agent", _configuration.GetValue("HttpClient:GithubApi:ClientName")); var userResponse = await _httpClientFactory.GetAsync(HttpClientNameConsts.GithubApi, "/user", headers); var user = await _userManager.FindByEmailAsync(userResponse.email); @@ -140,7 +140,7 @@ namespace Lion.AbpPro.Users private async Task BuildResult(IdentityUser user) { - if (!user.IsActive) throw new BusinessException(AbpProDomainErrorCodes.UserLockedOut); + if (!user.IsActive) throw new BusinessException(AbpProDomainErrorCodes.UserLockedOut); var roles = await _userManager.GetRolesAsync(user); if (roles == null || roles.Count == 0) throw new AbpAuthorizationException(); var token = GenerateJwt(user.Id, user.UserName, user.Name, user.Email, diff --git a/aspnet-core/services/src/Lion.AbpPro.Application/Users/UserAppService.cs b/aspnet-core/services/src/Lion.AbpPro.Application/Users/UserAppService.cs index bcee144c..ad25e9b1 100644 --- a/aspnet-core/services/src/Lion.AbpPro.Application/Users/UserAppService.cs +++ b/aspnet-core/services/src/Lion.AbpPro.Application/Users/UserAppService.cs @@ -15,8 +15,11 @@ using Microsoft.Extensions.Options; using Volo.Abp; using Volo.Abp.Account; using Volo.Abp.Application.Dtos; +using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus; using Volo.Abp.Identity; using Volo.Abp.Users; +using IdentityUser = Volo.Abp.Identity.IdentityUser; namespace Lion.AbpPro.Users { @@ -28,19 +31,22 @@ namespace Lion.AbpPro.Users private readonly IIdentityUserRepository _identityUserRepository; private readonly IExcelExporter _excelExporter; private readonly IOptions _options; + private readonly IBulkImportUserRepository _bulkImportUserRepository; public UserAppService( IIdentityUserAppService identityUserAppService, IdentityUserManager userManager, IIdentityUserRepository userRepository, IExcelExporter excelExporter, IOptions options, - NotificationManager notificationManager) + NotificationManager notificationManager, + IBulkImportUserRepository bulkImportUserRepository) { _identityUserAppService = identityUserAppService; _userManager = userManager; _identityUserRepository = userRepository; _excelExporter = excelExporter; _options = options; + _bulkImportUserRepository = bulkImportUserRepository; } /// @@ -162,9 +168,26 @@ namespace Lion.AbpPro.Users [Authorize(AbpProPermissions.SystemManagement.UserEnable)] public async Task LockAsync(LockUserInput input) { - var identityUser = await _userManager.GetByIdAsync(input.UserId); - identityUser.SetIsActive(input.Locked); - await _userManager.UpdateAsync(identityUser); + var s = new IdentityUser(Guid.NewGuid(),Guid.NewGuid().ToString(),Guid.NewGuid().ToString()+"@qq.com"); + + await _bulkImportUserRepository.BulkInsertAsync(new List(){s}); + // throw new UserFriendlyException("Sdf"); + // var identityUser = await _userManager.GetByIdAsync(input.UserId); + // identityUser.SetIsActive(input.Locked); + // await _userManager.UpdateAsync(identityUser); } } +} + +public class TestEvent +{ + public string Type { get; set; } +} + +public class ttt : ILocalEventHandler, ITransientDependency +{ + public async Task HandleEventAsync(TestEvent eventData) + { + var s = "1"; + } } \ No newline at end of file diff --git a/aspnet-core/services/test/Lion.AbpPro.HttpApi.Client.ConsoleTestApp/Lion.AbpPro.HttpApi.Client.ConsoleTestApp.csproj b/aspnet-core/services/test/Lion.AbpPro.HttpApi.Client.ConsoleTestApp/Lion.AbpPro.HttpApi.Client.ConsoleTestApp.csproj index 4dba0ef3..f73c3611 100644 --- a/aspnet-core/services/test/Lion.AbpPro.HttpApi.Client.ConsoleTestApp/Lion.AbpPro.HttpApi.Client.ConsoleTestApp.csproj +++ b/aspnet-core/services/test/Lion.AbpPro.HttpApi.Client.ConsoleTestApp/Lion.AbpPro.HttpApi.Client.ConsoleTestApp.csproj @@ -24,7 +24,7 @@ - +