wet 2 years ago
commit 4787c9abcb

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

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

Loading…
Cancel
Save