费用代码列表查询

optimize
zhangxiaofeng 10 months ago
parent af6616907d
commit 44aac96b08

@ -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
{
@ -105,7 +98,6 @@ namespace Myshipping.Application.Service.Fee.Dto
/// 默认是否开票
/// </summary>
public bool IsInvoice { get; set; }
}
/// <summary>
@ -140,4 +132,9 @@ namespace Myshipping.Application.Service.Fee.Dto
{
}
public class FeeCodeCacheDto : FeeCodeDto
{
public long TenantId { get; set; }
}
}

@ -101,6 +101,8 @@ namespace Myshipping.Application
await _repCode.UpdateAsync(entity);
}
await CacheFeeCode();
return entity.Adapt<FeeCodeSaveDto>();
}
@ -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();
}
/// <summary>
/// 获取费用代码列表
/// </summary>
/// <returns></returns>
[HttpGet("/FeeCode/List")]
public async Task<List<FeeCodeCacheDto>> List()
{
var cacheList = await _cache.GetAsync<List<FeeCodeCacheDto>>(CommonConst.CACHE_KEY_FEE_CODE);
if (cacheList?.Any() == true)
{
List<FeeCodeCacheDto> result = cacheList.Where(f => f.TenantId == UserManager.TENANT_ID).ToList();
return result;
}
else
{
var cacheFeeCode = await CacheFeeCode();
List<FeeCodeCacheDto> result = cacheFeeCode.Where(f => f.TenantId == UserManager.TENANT_ID).ToList();
return result;
}
}
/// <summary>
/// 缓存费用代码列表
/// </summary>
[NonAction]
public async Task<List<FeeCodeCacheDto>> CacheFeeCode()
{
var allFeeCode = await _repCode.AsQueryable().Filter(null, true).ToListAsync();
var cacheFeeCode = allFeeCode.Adapt<List<FeeCodeCacheDto>>();
await _cache.SetAsync(CommonConst.CACHE_KEY_FEE_CODE, cacheFeeCode);
return cacheFeeCode;
}
}
}

@ -231,4 +231,11 @@ public class CommonConst
/// </summary>
public const string SECRET_FEE_REVIEW = "SecretFeeReview";
#endregion
#region 费用
/// <summary>
/// 费用编码缓存键
/// </summary>
public const string CACHE_KEY_FEE_CODE = "FeeCodeList";
#endregion
}

@ -797,6 +797,11 @@
机密费用检阅角色
</summary>
</member>
<member name="F:Myshipping.Core.CommonConst.CACHE_KEY_FEE_CODE">
<summary>
费用编码缓存键
</summary>
</member>
<member name="F:Myshipping.Core.Const.MenuConst.MenuBookingOrder">
<summary>
订舱台账菜单

Loading…
Cancel
Save