lixiaojun
2023-11-07 44ced5c9cd0e1380db237c498a19160f909807e9
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
namespace Yw.Application
{
    /// <summary>
    /// UnitType
    /// </summary>
    [Route("Unit/Type/Std")]
    [ApiDescriptionSettings("Unit", Name = "单位类型(Std)", Order = 8900)]
    public class SysUnitType_StdController : IDynamicApiController
    {
 
 
        /// <summary>
        /// 获取所有
        /// </summary>
        [Route("GetAll@V1.0")]
        [HttpGet]
        public List<SysUnitTypeStdDto> GetAll()
        {
            var keyContent = "Unit_Type_Std_GetAll";
            var cacheKey = MemoryCacheKeyHelper.GetKey(MemoryCacheKey.WebApiLevel, MemoryCacheKey.Module, keyContent);
            var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
            {
                var all = new Service.SysUnitType().GetAll();
                Service.SysUnitType.PublishCache(cacheKey);
                var vmList = all?.Select(x => new SysUnitTypeStdDto(x)).ToList();
                return vmList;
            }, CacheHelper.CacheLevel5);
            return vm_list;
        }
 
        /// <summary>
        /// 获取分页列表
        /// </summary>
        [Route("GetPageList@V1.0")]
        [HttpGet]
        public PageListOutput<SysUnitTypeStdDto> GetPageList([FromQuery][Required] PageInput input)
        {
            var list = new Service.SysUnitType().GetPageList(input.PageIndex, input.PageSize, out int Total);
            var vmList = list.Select(x => new SysUnitTypeStdDto(x)).ToList();
            return new PageListOutput<SysUnitTypeStdDto>() { Total = Total, List = vmList };
        }
 
        /// <summary>
        /// 通过 Code 获取
        /// </summary>
        [Route("GetByCode@V1.0")]
        [HttpGet]
        public SysUnitTypeStdDto GetByCode([FromQuery][Required] CodeInput input)
        {
            var model = new Service.SysUnitType().GetByCode(input.Code);
            return model == null ? null : new SysUnitTypeStdDto(model);
        }
 
    }
}