Refactor authorization folder structure

This commit is contained in:
2026-08-19 11:39:44 +05:30
parent 56cd93c341
commit 45f374133f
32 changed files with 378 additions and 290 deletions
@@ -0,0 +1,30 @@
namespace Distribution.Infra.Authorization;
public class ScopeAccessService(IScopeRepository repo) : IScopeAccessService
{
public Task<bool> HasStoreScopeAsync(Guid userId, Guid storeId) =>
repo.HasStoreScopeAsync(userId, storeId);
public Task<bool> HasRouteScopeAsync(Guid userId, Guid routeId) =>
repo.HasRouteScopeAsync(userId, routeId);
public Task<bool> HasRegionScopeAsync(Guid userId, Guid regionId) =>
repo.HasRegionScopeAsync(userId, regionId);
public async Task<List<Guid>> GetAccessibleStoreIdsAsync(Guid userId)
{
var directStoreIds = await repo.GetDirectStoreIdsAsync(userId);
var routeIds = await repo.GetRouteIdsAsync(userId);
var regionIds = await repo.GetRegionIdsAsync(userId);
var storeIdsViaRoute = await repo.GetStoreIdsByRouteIdsAsync(routeIds);
var routeIdsViaRegion = await repo.GetRouteIdsByRegionIdsAsync(regionIds);
var storeIdsViaRegion = await repo.GetStoreIdsByRouteIdsAsync(routeIdsViaRegion);
return directStoreIds
.Concat(storeIdsViaRoute)
.Concat(storeIdsViaRegion)
.Distinct()
.ToList();
}
}