diff --git a/Myshipping.Application/Service/Fee/Dto/FeeCodeDto.cs b/Myshipping.Application/Service/Fee/Dto/FeeCodeDto.cs index cd70450d..bd8a85de 100644 --- a/Myshipping.Application/Service/Fee/Dto/FeeCodeDto.cs +++ b/Myshipping.Application/Service/Fee/Dto/FeeCodeDto.cs @@ -1,11 +1,4 @@ using Myshipping.Core; -using SqlSugar; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Myshipping.Application.Service.Fee.Dto { @@ -14,7 +7,7 @@ namespace Myshipping.Application.Service.Fee.Dto /// /// ID /// - public long Id { get; set; } + public long Id { get; set; } /// /// 费用代码,录入费用是作为检索 @@ -105,13 +98,12 @@ namespace Myshipping.Application.Service.Fee.Dto /// 默认是否开票 /// public bool IsInvoice { get; set; } - } /// /// 查询 /// - public class FeeCodePageInput: PageInputBase + public class FeeCodePageInput : PageInputBase { /// /// 费用代码,录入费用是作为检索 @@ -128,16 +120,21 @@ namespace Myshipping.Application.Service.Fee.Dto /// /// 台账列表 /// - public class FeeCodePageOutput: FeeCodeDto + public class FeeCodePageOutput : FeeCodeDto { - + } /// /// 保存 /// - public class FeeCodeSaveDto: FeeCodeDto + public class FeeCodeSaveDto : FeeCodeDto { } + + public class FeeCodeCacheDto : FeeCodeDto + { + public long TenantId { get; set; } + } } diff --git a/Myshipping.Application/Service/Fee/FeeCodeService.cs b/Myshipping.Application/Service/Fee/FeeCodeService.cs index bd256b34..0ee90865 100644 --- a/Myshipping.Application/Service/Fee/FeeCodeService.cs +++ b/Myshipping.Application/Service/Fee/FeeCodeService.cs @@ -101,6 +101,8 @@ namespace Myshipping.Application await _repCode.UpdateAsync(entity); } + await CacheFeeCode(); + return entity.Adapt(); } @@ -129,6 +131,43 @@ namespace Myshipping.Application var list = await _repCode.AsQueryable().Filter(null, true).Where(x => ids.Contains(x.Id)).ToListAsync(); list.ForEach(x => x.IsDeleted = true); await _repCode.AsUpdateable(list).ExecuteCommandAsync(); + await CacheFeeCode(); + } + + /// + /// 获取费用代码列表 + /// + /// + [HttpGet("/FeeCode/List")] + public async Task> List() + { + var cacheList = await _cache.GetAsync>(CommonConst.CACHE_KEY_FEE_CODE); + if (cacheList?.Any() == true) + { + List result = cacheList.Where(f => f.TenantId == UserManager.TENANT_ID).ToList(); + return result; + } + else + { + var cacheFeeCode = await CacheFeeCode(); + + List result = cacheFeeCode.Where(f => f.TenantId == UserManager.TENANT_ID).ToList(); + return result; + } + } + + /// + /// 缓存费用代码列表 + /// + [NonAction] + public async Task> CacheFeeCode() + { + var allFeeCode = await _repCode.AsQueryable().Filter(null, true).ToListAsync(); + + var cacheFeeCode = allFeeCode.Adapt>(); + await _cache.SetAsync(CommonConst.CACHE_KEY_FEE_CODE, cacheFeeCode); + + return cacheFeeCode; } } } diff --git a/Myshipping.Core/Const/CommonConst.cs b/Myshipping.Core/Const/CommonConst.cs index 44910eed..5050b331 100644 --- a/Myshipping.Core/Const/CommonConst.cs +++ b/Myshipping.Core/Const/CommonConst.cs @@ -231,4 +231,11 @@ public class CommonConst /// public const string SECRET_FEE_REVIEW = "SecretFeeReview"; #endregion + + #region 费用 + /// + /// 费用编码缓存键 + /// + public const string CACHE_KEY_FEE_CODE = "FeeCodeList"; + #endregion } diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index d56d6c47..b8387769 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -797,6 +797,11 @@ 机密费用检阅角色 + + + 费用编码缓存键 + + 订舱台账菜单