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(); }