sqlsugar 二级缓存修改

usertest
cjy 4 months ago
parent d6e28e539d
commit da71cfe747

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.Module.Core.Constants
{
/// <summary>
/// SqlSugar缓存常量
/// </summary>
public class SqlSugarCacheConst
{
/// <summary>
/// SqlSugar二级缓存
/// </summary>
public const string SqlSugar = "sys_sqlSugar:";
/// <summary>
/// SqlSugar二级缓存港口信息
/// </summary>
public const string Port = "sys_sqlSugar:Port";
/// <summary>
/// SqlSugar二级缓存 往来单位信息
/// </summary>
public const string InfoClient = "sys_sqlSugar:InfoClient";
}
}

@ -1,4 +1,5 @@
using DS.Module.Core;
using DS.Module.Core.Constants;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
@ -108,7 +109,7 @@ public class CodePortService:ICodePortService
var data = req.Adapt<CodePort>();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
var entity = tenantDb.Insertable(data).RemoveDataCache(SqlSugarCacheConst.Port).ExecuteReturnEntity();
_sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodePort, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
}
@ -118,7 +119,7 @@ public class CodePortService:ICodePortService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).RemoveDataCache(SqlSugarCacheConst.Port).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
_sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodePort, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
@ -162,7 +163,7 @@ public class CodePortService:ICodePortService
return DataResult.Failed("存在已导入的港口信息!",MultiLanguageConst.CodePortImportAlready);
}
tenantDb.Insertable(list).ExecuteCommand();
tenantDb.Insertable(list).RemoveDataCache(SqlSugarCacheConst.Port).ExecuteCommand();
_sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodePort, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("引入成功!",MultiLanguageConst.DataImportSuccess);
}
@ -185,7 +186,7 @@ public class CodePortService:ICodePortService
var list = tenantDb.Queryable<CodePort>().Where(x => req.Ids.Contains(x.Id)).ToList();
if (list.Count > 0)
{
tenantDb.Deleteable(list).ExecuteCommand();
tenantDb.Deleteable(list).RemoveDataCache(SqlSugarCacheConst.Port).ExecuteCommand();
}
_sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodePort, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);

@ -1,4 +1,5 @@
using DS.Module.Core;
using DS.Module.Core.Constants;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Check.Entity;
@ -74,7 +75,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
var entity = TenantDb.InsertNav(data).Include(x => x.InvoiceHeaders).ExecuteReturnEntity();
tag.ClientId = entity.Id;
TenantDb.Insertable(tag).ExecuteCommand();
TenantDb.Insertable(tag).RemoveDataCache(SqlSugarCacheConst.InfoClient).ExecuteCommand();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
@ -85,7 +86,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
info = req.Adapt(info);
tag = req.ClientTag.Adapt(tag);
TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
TenantDb.Updateable(info).RemoveDataCache(SqlSugarCacheConst.InfoClient).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
TenantDb.Updateable(tag).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
//创建或更新发票抬头
@ -185,7 +186,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
//收发货人
await TenantDb.Deleteable<InfoClientShipper>().Where(x => req.Ids.Contains(x.ClientId)).ExecuteCommandAsync();
//删除客户信息
await TenantDb.Deleteable<InfoClient>().Where(x => req.Ids.Contains(x.Id)).ExecuteCommandAsync();
await TenantDb.Deleteable<InfoClient>().RemoveDataCache(SqlSugarCacheConst.InfoClient).Where(x => req.Ids.Contains(x.Id)).ExecuteCommandAsync();
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;

@ -1,4 +1,5 @@
using DS.Module.Core;
using DS.Module.Core.Constants;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.Core.Log;
@ -1071,7 +1072,6 @@ public class ClientCommonService : IClientCommonService
.WhereIF(code == "shipagency", (a, b) => b.IsShipAgency == true)
.WhereIF(code == "enterprise", (a, b) => b.IsEnterprise == true)
.WhereIF(!string.IsNullOrEmpty(queryKey), (a, b) => a.CodeName.Contains(queryKey) || a.ShortName.Contains(queryKey))
.WithCache()
.Select((a, b) => new ClientSelectRes
{
Id = a.Id,
@ -1080,7 +1080,7 @@ public class ClientCommonService : IClientCommonService
EnShortName = a.EnShortName,
BLContent = a.BLContent,
}
).Take(20).ToListAsync();
).Take(20).WithCache(SqlSugarCacheConst.InfoClient).ToListAsync();
return await Task.FromResult(DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess));
}
/// <summary>

@ -23,6 +23,7 @@ using DS.WMS.Core.Info.Dtos;
using NPOI.SS.Formula.Functions;
using DS.WMS.Core.Flow.Dtos;
using Microsoft.Extensions.Logging;
using DS.Module.Core.Constants;
namespace DS.WMS.Core.Sys.Method;
@ -1079,9 +1080,9 @@ public class CommonService : ICommonService
var list = await tenantDb.Queryable<CodePort>()
.Where(x => x.Status == StatusEnum.Enable)
.WhereIF(!string.IsNullOrEmpty(queryKey), x => x.PortName.Contains(queryKey) || x.CnName.Contains(queryKey))
.WithCache()
.Select<CodePortSelectRes>()
.Take(20)
.WithCache(SqlSugarCacheConst.Port)
.ToListAsync();
return await Task.FromResult(DataResult<List<CodePortSelectRes>>.Success("获取数据成功!", list));
}

Loading…
Cancel
Save