using FoodLabeling.Application.Contracts.Dtos.AuthScope; using FoodLabeling.Application.Contracts.IServices; using FoodLabeling.Application.Helpers; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Volo.Abp.Application.Services; using Volo.Abp.Caching; using Yi.Framework.SqlSugarCore.Abstractions; namespace FoodLabeling.Application.Services; /// /// 登录后 Company → Region → Location 级联选店(Web 管理端)。 /// [Authorize] public class AuthScopeAppService : ApplicationService, IAuthScopeAppService { private readonly ISqlSugarDbContext _dbContext; private readonly IDistributedCache _workingScopeCache; public AuthScopeAppService( ISqlSugarDbContext dbContext, IDistributedCache workingScopeCache) { _dbContext = dbContext; _workingScopeCache = workingScopeCache; } /// [HttpGet("auth-scope/companies")] public virtual Task> GetCompaniesAsync() => AuthScopeQueryHelper.GetCompaniesAsync(CurrentUser, _dbContext); /// [HttpGet("auth-scope/regions")] public virtual Task> GetRegionsAsync([FromQuery] string partnerId) => AuthScopeQueryHelper.GetRegionsAsync(CurrentUser, _dbContext, partnerId); /// [HttpGet("auth-scope/locations")] public virtual Task> GetLocationsAsync( [FromQuery] string partnerId, [FromQuery] string groupId) => AuthScopeQueryHelper.GetLocationsAsync(CurrentUser, _dbContext, partnerId, groupId); /// [HttpPost("auth-scope/select-location")] public virtual Task SelectLocationAsync(AuthScopeSelectLocationInputVo input) => AuthScopeQueryHelper.SelectLocationAsync(CurrentUser, _dbContext, _workingScopeCache, input); /// [HttpGet("auth-scope/current-scope")] public virtual Task GetCurrentScopeAsync() => AuthScopeQueryHelper.GetCurrentScopeAsync(CurrentUser, _dbContext, _workingScopeCache); }