From 5fcc7d73fb39065daac935192473e9204660cbd0 Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Fri, 19 May 2023 16:06:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=8F=B8=E4=BA=BA=E5=91=98=E5=8F=98?= =?UTF-8?q?=E5=8A=A8MQ=E5=9C=B0=E5=9D=80=E8=8E=B7=E5=8F=96=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20=E8=B7=B3=E8=BD=AC=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MQ/RecCompanyUserChangeService.cs | 10 +++++----- Myshipping.Core/Myshipping.Core.xml | 5 +++++ Myshipping.Core/Service/Auth/AuthService.cs | 20 +++++++------------ Myshipping.Web.Core/applicationconfig.json | 2 +- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Myshipping.Core/MQ/RecCompanyUserChangeService.cs b/Myshipping.Core/MQ/RecCompanyUserChangeService.cs index a14462f..74cf87a 100644 --- a/Myshipping.Core/MQ/RecCompanyUserChangeService.cs +++ b/Myshipping.Core/MQ/RecCompanyUserChangeService.cs @@ -50,7 +50,8 @@ namespace Myshipping.Core.MQ { base.Dispose(); _serviceScope.Dispose(); - mqConn.Close(); + if (mqConn != null && mqConn.IsOpen) + mqConn.Close(); _logger.LogInformation("RecCompanyUserChangeService Dispose"); } @@ -59,7 +60,7 @@ namespace Myshipping.Core.MQ { _logger.LogInformation("RecCompanyUserChangeService ExecuteAsync"); - return Task.Run(async () => + return Task.Run(() => { _logger.LogInformation("RecCompanyUserChangeService ExecuteAsync RunTask"); @@ -67,9 +68,8 @@ namespace Myshipping.Core.MQ string QueueName = $"djy.comp&user.change.{DateTime.Now.Ticks}"; ConnectionFactory factory = new ConnectionFactory(); - var cache = _serviceScope.ServiceProvider.GetService(); - var sysConfig = await cache.GetAllSysConfig(); - var mqUrl = sysConfig.First(x => x.Code == "CompanyUserChangeMqUrl").Value; + var repoSysCfg = _serviceScope.ServiceProvider.GetService>(); + var mqUrl = repoSysCfg.FirstOrDefault(x => x.Code == "CompanyUserChangeMqUrl").Value; factory.Uri = new Uri(mqUrl); mqConn = factory.CreateConnection("客户订舱平台"); diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 6e66eeb..52909c5 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -3880,6 +3880,11 @@ 租户类型 + + + 大简云公司ID + + 定时任务 diff --git a/Myshipping.Core/Service/Auth/AuthService.cs b/Myshipping.Core/Service/Auth/AuthService.cs index 809302e..8316c22 100644 --- a/Myshipping.Core/Service/Auth/AuthService.cs +++ b/Myshipping.Core/Service/Auth/AuthService.cs @@ -85,6 +85,12 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient throw Oops.Oh(ErrorCode.D1017); //获取对应租户 var tenant = _sysTenantRep.Single(user.TenantId); + // 生成Token令牌 + return await GetLoginToken(user, tenant); + } + + private async Task GetLoginToken(SysUser user, SysTenant tenant) + { // 生成Token令牌 //var accessToken = await _jwtBearerManager.CreateTokenAdmin(user); var accessToken = JWTEncryption.Encrypt(new Dictionary @@ -360,20 +366,8 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient throw Oops.Bah($"{showname}不存在,请先加入公司{comname}!"); } - //var accessToken = JWTEncryption.Encrypt(dic); - - //// 设置Swagger自动登录 - //_httpContextAccessor.HttpContext.SigninToSwagger(accessToken); - - //// 生成刷新Token令牌 - //var refreshToken = JWTEncryption.GenerateRefreshToken(accessToken, 30); - - //// 设置刷新Token令牌 - //_httpContextAccessor.HttpContext.Response.Headers["x-access-token"] = refreshToken; - - //return accessToken; + return await GetLoginToken(user, tenant); - return null; } else { diff --git a/Myshipping.Web.Core/applicationconfig.json b/Myshipping.Web.Core/applicationconfig.json index 9b63aab..2b43003 100644 --- a/Myshipping.Web.Core/applicationconfig.json +++ b/Myshipping.Web.Core/applicationconfig.json @@ -55,7 +55,7 @@ }, "Cache": { "CacheType": "RedisCache", // RedisCache - "RedisConnectionString": "192.168.0.80:6379,password=,defaultDatabase=11" + "RedisConnectionString": "192.168.0.80:6379,password=,defaultDatabase=12" }, "SnowId": { "WorkerId": "1" // 取值范围0~63,默认1