wet 2 years ago
commit 4787c9abcb

@ -17,6 +17,7 @@ using System.Threading.Tasks;
using UAParser;
using Furion.RemoteRequest.Extensions;
using Newtonsoft.Json.Linq;
using Microsoft.Extensions.Logging;
namespace Myshipping.Core.Service;
@ -39,12 +40,14 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient
private readonly ISysConfigService _sysConfigService; // 验证码服务
private readonly IEventPublisher _eventPublisher;
private readonly ILogger<AuthService> _logger;
public AuthService(SqlSugarRepository<SysUser> sysUserRep, SqlSugarRepository<SysLogVis> sysLogVisRep, SqlSugarRepository<SysTenant> sysTenantRep,
IHttpContextAccessor httpContextAccessor,
ISysEmpService sysEmpService, ISysRoleService sysRoleService, ISysMenuService sysMenuService,
ISysAppService sysAppService, IClickWordCaptcha captchaHandle, ISysConfigService sysConfigService,
IEventPublisher eventPublisher
IEventPublisher eventPublisher,
ILogger<AuthService> logger
)
{
_sysUserRep = sysUserRep;
@ -58,6 +61,7 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient
_captchaHandle = captchaHandle;
_sysConfigService = sysConfigService;
_eventPublisher = eventPublisher;
_logger = logger;
}
/// <summary>
@ -327,10 +331,15 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient
var loginUrl = djyAuthUrl + "user/login";
var infoUrl = djyAuthUrl + "user/info";
_logger.LogInformation($"统一登录:{loginUrl}");
//跳转登录
var result = await loginUrl
.SetBody(new { code }, "application/json")
.PostAsStringAsync();
_logger.LogInformation($"登录返回:{result}");
var jRtn = JObject.Parse(result);
if (jRtn.GetIntValue("code") == 200)
{
@ -340,13 +349,17 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient
var headers = new Dictionary<string, object>();
headers.Add("Authorization", $"Bearer {token}");
_logger.LogInformation($"获取登录信息:{infoUrl}");
//获取登录信息
result = await infoUrl
.SetHeaders(headers)
.GetAsStringAsync();
_logger.LogInformation($"登录信息返回:{result}");
jRtn = JObject.Parse(result);
if (jRtn.GetIntValue("code") == 200)
{
jData = jRtn.GetJObjectValue("data");
var compId = jData.GetStringValue("compId");
@ -354,13 +367,13 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient
var userId = jData.GetStringValue("gid");
var showname = jData.GetStringValue("showname");
var tenant = _sysTenantRep.FirstOrDefault(x => x.CompId == compId);
var tenant = _sysTenantRep.AsQueryable().Filter(null, true).First(x => x.CompId == compId);
if (tenant == null)
{
throw Oops.Bah($"{comname}不存在,请先完成公司认证!");
}
var user = _sysUserRep.FirstOrDefault(u => u.DjyUserId == userId);
var user = _sysUserRep.AsQueryable().Filter(null, true).First(u => u.DjyUserId == userId);
if (tenant == null)
{
throw Oops.Bah($"{showname}不存在,请先加入公司{comname}");

@ -15,27 +15,27 @@
"InjectSpecificationDocument": true //swagger
},
"SpecificationDocumentSettings": {
"DocumentTitle": "Myshipping",
"DocumentTitle": "客户订舱平台",
"DocExpansionState": "None",
"GroupOpenApiInfos": [
{
"Group": "Application",
"Title": "业务模块",
"Description": "业务相关模块",
"Version": "1.0.0"
},
{
"Group": "Default",
"Title": "大简云平台",
"Title": "基础模块",
"Description": "",
"Version": "1.0.0"
},
{
"Group": "FlowCenter",
"Title": "流程中心",
"Description": "流程中心模块或插件。<br/>作者By MonsterUncle,QQ295228902",
"Description": "流程中心模块或插件。",
"Version": "1.0.0"
},
{
"Group": "Application",
"Title": "业务模块",
"Description": "独立业务模块",
"Version": "1.0.0"
}
]
},
"JWTSettings": {

Loading…
Cancel
Save