From 71b32d2d23c1f43008c1ecf0e472dd42ac951c0c Mon Sep 17 00:00:00 2001 From: douhandong Date: Wed, 29 May 2024 14:29:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Core/Service/Auth/AuthService.cs | 15 ++++++++++++--- Myshipping.Core/Service/Auth/Dto/LoginInput.cs | 11 +++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Myshipping.Core/Service/Auth/AuthService.cs b/Myshipping.Core/Service/Auth/AuthService.cs index 350826b6..5d048d7a 100644 --- a/Myshipping.Core/Service/Auth/AuthService.cs +++ b/Myshipping.Core/Service/Auth/AuthService.cs @@ -47,6 +47,8 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient private readonly ILogger _logger; + private readonly SqlSugarRepository _pingtaiUser; // 平台用户 + public AuthService(SqlSugarRepository sysUserRep, SqlSugarRepository sysLogVisRep, SqlSugarRepository sysTenantRep, IHttpContextAccessor httpContextAccessor, ISysCacheService cache, ISysEmpService sysEmpService, ISysRoleService sysRoleService, ISysMenuService sysMenuService, @@ -513,10 +515,17 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient GetAuthorizationKeyInput data = JsonConvert.DeserializeObject(_cache.Get(input.Key)); var datainfo = _sysUserRep.AsQueryable().Filter(null, true).First(u => u.DjyUserId == data.UserId); - + //获取缓存的权限,将权限缓存 - await _cache.SetAsync(datainfo.UserCode, data.Authority); - + //如果类型为公司,将公司下所有用户关联出 + + if (data.AuthorityType == 2) + { + data.Authority = _pingtaiUser.Where(t => data.Authority.Contains(t.CompId)).Select(t => t.GID).ToList(); + } + + await _cache.SetAsync(datainfo.UserCode + "Authorization", data.Authority); + //获取对应租户 var tenant = _sysTenantRep.Single(datainfo.TenantId); //颁发token diff --git a/Myshipping.Core/Service/Auth/Dto/LoginInput.cs b/Myshipping.Core/Service/Auth/Dto/LoginInput.cs index 0093e9f3..e116e0a4 100644 --- a/Myshipping.Core/Service/Auth/Dto/LoginInput.cs +++ b/Myshipping.Core/Service/Auth/Dto/LoginInput.cs @@ -1,4 +1,5 @@ using Furion.DependencyInjection; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Ubiety.Dns.Core; @@ -40,8 +41,14 @@ public class GetAuthorizationKeyInput /// /// 权限范围 /// - public string Authority { get; set; } - + public List Authority { get; set; } + + + /// + /// 权限类型(1用户,2公司) + /// + public int AuthorityType { get; set; } + } ///