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<List<AreaInfo>> _distributedCache; private readonly IDistributedCache<List<AreaDto>> _distributedAreaCache; public AreaController( IDistributedCache<List<AreaInfo>> distributedCache, IDistributedCache<List<AreaDto>> distributedAreaCache, IAreaService areaService) { _areaService = areaService; _distributedCache = distributedCache; _distributedAreaCache = distributedAreaCache; } /// <summary> /// 获å–çœå¸‚区 /// </summary> /// <returns></returns> [HttpGet] [AllowAnonymous] public async Task<List<AreaDto>> GetAreaList() { return await _distributedAreaCache.GetOrAddAsync(LifePaymentConstant.区域信æ¯ç¼“å˜key, async () => { return await _areaService.GetAreaList(new GetAreaListInput()); }); } /// <summary> /// 资讯管ç†--适用区域 /// </summary> /// <returns></returns> [HttpGet] public async Task<List<AreaDto>> GetApplicableAreaList() { return await _areaService.GetAreaList(new GetAreaListInput { Layer = LifePaymentConstant.AreaLayerType.çœ, }); } /// <summary> /// 获å–区域列表(çœã€å¸‚ã€åŒºï¼‰ /// </summary> /// <param name="input"></param> /// <returns></returns> [HttpPost] [UnitOfWork(IsDisabled = true)] public async Task<List<AreaDto>> GetAreas(GetAreaListInput input) { return await _areaService.GetAreaList(input); } /// <summary> /// æœç´¢ç®¡ç†--列表(区域管ç†) /// </summary> /// <returns></returns> [HttpGet] [AllowAnonymous] public async Task<List<AreaInfo>> GetRegionalManagementList() { return await _distributedCache.GetOrAddAsync(LifePaymentConstant.区域信æ¯ç¼“å˜key2, async () => { return await _areaService.GetRegionalManagementList(); }); } } }