fix 营业点控制(admin),unit返回
This commit is contained in:
@@ -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<List<BusinessPlaceDto>> GetMyAsync()
|
||||
{
|
||||
var userId = _currentUser.GetIntSubjectId();
|
||||
var role = _currentUser.GetUserClaim(ClaimTypes.Role);
|
||||
var isAdmin = role == "admin" || role == "tenant-admin";
|
||||
|
||||
var guids = await _dbContext.Queryable<BusinessPlaceManagerRelationshipEntity>()
|
||||
.Where(x => x.ManagerUserId == userId)
|
||||
var codes = await _dbContext.Queryable<BusinessPlaceManagerRelationshipEntity>()
|
||||
.WhereIF(!isAdmin, x => x.ManagerUserId == userId)
|
||||
.Select(x => x.BusinessPlaceCode)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
|
||||
return await _dbContext.Queryable<BusinessPlaceEntity>()
|
||||
.Where(x => guids.Contains(x.Code))
|
||||
.Where(x => codes.Contains(x.Code))
|
||||
.Select<BusinessPlaceDto>()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user