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