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
56
57
58
namespace Yw.Application
{
    /// <summary>
    /// UnitValue
    /// </summary>
    [Route("Unit/Value/Std")]
    [ApiDescriptionSettings("Unit", Name = "单位值(Std)", Order = 7900)]
    public class SysUnitValue_StdController : IDynamicApiController
    {
 
        /// <summary>
        /// 通过 TypeID 获取
        /// </summary>
        [Route("GetByTypeID@V1.0")]
        [HttpGet]
        public List<SysUnitValueStdDto> GetByTypeID([FromQuery][Required] TypeIDInput input)
        {
            var typeId = input.TypeID;
 
            var keyContent = $"Unit_Value_Std_GetByTypeID_{typeId}";
            var cacheKey = MemoryCacheKeyHelper.GetKey(MemoryCacheKey.WebApiLevel, MemoryCacheKey.Module, keyContent);
            var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
            {
                var all = new Service.SysUnitValue().GetByTypeID(typeId);
                Service.SysUnitValue.PublishCache(cacheKey);
                var vmList = all?.Select(x => new SysUnitValueStdDto(x)).ToList();
                return vmList;
            }, CacheHelper.CacheLevel5);
            return vm_list;
        }
 
        /// <summary>
        /// 通过类型编码获取
        /// </summary>
        [Route("GetByTypeCode@V1.0")]
        [HttpGet]
        public List<SysUnitValueStdDto> GetByTypeCode([FromQuery][Required] CodeInput input)
        {
            var typeCode = input.Code;
 
            var keyContent = $"Unit_Value_Std_GetByTypeCode_{typeCode}";
            var cacheKey = MemoryCacheKeyHelper.GetKey(MemoryCacheKey.WebApiLevel, MemoryCacheKey.Module, keyContent);
            var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
            {
                var all = new Service.SysUnitValue().GetByTypeCode(typeCode);
                Service.SysUnitValue.PublishCache(cacheKey);
                var vmList = all?.Select(x => new SysUnitValueStdDto(x)).ToList();
                return vmList;
            }, CacheHelper.CacheLevel5);
            return vm_list;
        }
 
 
 
 
 
    }
}