|
|
|
@ -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}!");
|
|
|
|
|