From aae8fc49815d2b82bf4fb1cc76b43652ca402a23 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 21 Mar 2024 11:31:50 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=90=A5=E4=B8=9A=E7=82=B9=E6=8E=A7?= =?UTF-8?q?=E5=88=B6(admin),unit=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/BusinessPlacePermissionsService.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Src/Dlhis.Basic/Places/Services/Implements/BusinessPlacePermissionsService.cs b/Src/Dlhis.Basic/Places/Services/Implements/BusinessPlacePermissionsService.cs index 2aaa3918..13af5110 100644 --- a/Src/Dlhis.Basic/Places/Services/Implements/BusinessPlacePermissionsService.cs +++ b/Src/Dlhis.Basic/Places/Services/Implements/BusinessPlacePermissionsService.cs @@ -9,6 +9,7 @@ using Dlhis.Basic.Places.Dtos; using Kurisu.SqlSugar.Extensions; using Dlhis.Sys.Api; using Microsoft.AspNetCore.Mvc; +using System.Security.Claims; namespace Dlhis.Basic.BusinessPlace.Services.Implements; @@ -51,15 +52,17 @@ public class BusinessPlacePermissionsService : IBusinessPlacePermissionsService public async Task> GetMyAsync() { var userId = _currentUser.GetIntSubjectId(); + var role = _currentUser.GetUserClaim(ClaimTypes.Role); + var isAdmin = role == "admin" || role == "tenant-admin"; - var guids = await _dbContext.Queryable() - .Where(x => x.ManagerUserId == userId) + var codes = await _dbContext.Queryable() + .WhereIF(!isAdmin, x => x.ManagerUserId == userId) .Select(x => x.BusinessPlaceCode) .Distinct() .ToListAsync(); return await _dbContext.Queryable() - .Where(x => guids.Contains(x.Code)) + .Where(x => codes.Contains(x.Code)) .Select() .ToListAsync(); }