using LifePayment.Application.Contracts; using LifePayment.Domain.Shared; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Caching; using Volo.Abp.Uow; namespace LifePayment.HttpApi { [Route("api/[controller]/[action]")] [ApiController] [Authorize] public class AreaController : AbpController { private readonly IAreaService _areaService; private readonly IDistributedCache> _distributedCache; private readonly IDistributedCache> _distributedAreaCache; public AreaController( IDistributedCache> distributedCache, IDistributedCache> distributedAreaCache, IAreaService areaService) { _areaService = areaService; _distributedCache = distributedCache; _distributedAreaCache = distributedAreaCache; } /// /// 获取省市区 /// /// [HttpGet] [AllowAnonymous] public async Task> GetAreaList() { return await _distributedAreaCache.GetOrAddAsync(LifePaymentConstant.区域信息缓存key, async () => { return await _areaService.GetAreaList(new GetAreaListInput()); }); } /// /// 资讯管理--适用区域 /// /// [HttpGet] public async Task> GetApplicableAreaList() { return await _areaService.GetAreaList(new GetAreaListInput { Layer = LifePaymentConstant.AreaLayerType.省, }); } /// /// 获取区域列表(省、市、区) /// /// /// [HttpPost] [UnitOfWork(IsDisabled = true)] public async Task> GetAreas(GetAreaListInput input) { return await _areaService.GetAreaList(input); } /// /// 搜索管理--列表(区域管理) /// /// [HttpGet] [AllowAnonymous] public async Task> GetRegionalManagementList() { return await _distributedCache.GetOrAddAsync(LifePaymentConstant.区域信息缓存key2, async () => { return await _areaService.GetRegionalManagementList(); }); } } }