zhengyuxuan
2025-03-31 9810e089cb8f0615e333f7e79606e3a0a56e7787
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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();
            });
        }
    }
}