diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlSugarSetup.cs b/ds-wms-service/DS.Module.SqlSugar/SqlSugarSetup.cs index dfb91138..97bbf289 100644 --- a/ds-wms-service/DS.Module.SqlSugar/SqlSugarSetup.cs +++ b/ds-wms-service/DS.Module.SqlSugar/SqlSugarSetup.cs @@ -53,8 +53,9 @@ public static class SqlSugarSetup { dbList.Add(item); } - - var connectConfigList = SqlsugarHelper.ReturnConnectionConfig(dbList); + var _serviceProvider = services.GetService(); + ICacheService myCache = new SqlSugarCsRedisCache(_serviceProvider); + var connectConfigList = SqlsugarHelper.ReturnConnectionConfig(dbList, myCache); foreach (var item in dbList) { diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs b/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs index 99505751..49724342 100644 --- a/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs +++ b/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs @@ -1,4 +1,5 @@ -using DS.Module.Core; +using Amazon.Runtime.Internal.Util; +using DS.Module.Core; using DS.Module.Core.Data; using DS.Module.Core.Extensions; using DS.Module.UserModule; @@ -113,7 +114,7 @@ namespace DS.Module.SqlSugar #region 加载配置文件 + ReturnConnectionConfig - public static List ReturnConnectionConfig(List dbList) + public static List ReturnConnectionConfig(List dbList,ICacheService cache) { var connectConfigList = new List(); @@ -140,6 +141,7 @@ namespace DS.Module.SqlSugar // 自定义特性 ConfigureExternalServices = new ConfigureExternalServices() { + DataInfoCacheService = cache } }); } diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs b/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs index 12437571..07794e21 100644 --- a/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs +++ b/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; using SqlSugar; +using System; namespace DS.Module.SqlSugar; @@ -55,8 +56,9 @@ public static class SqlsugarInstall { dbList.Add(item); } - - var connectConfigList = SqlsugarHelper.ReturnConnectionConfig(dbList); + var _serviceProvider =services.GetService(); + ICacheService myCache = new SqlSugarCsRedisCache(_serviceProvider); + var connectConfigList = SqlsugarHelper.ReturnConnectionConfig(dbList, myCache); //foreach (var item in dbList) //{ @@ -106,6 +108,8 @@ public static class SqlsugarInstall foreach (var c in connectConfigList) { var dbProvider = db.GetConnectionScope((string)c.ConfigId); + + // var user = services.GetService(); //单例参数配置,所有上下文生效 dbProvider.Ado.CommandTimeOut = 30; diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs index a5ad8e36..da5dae82 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs @@ -86,8 +86,8 @@ public class ClientCommonService : IClientCommonService var data = await db.Queryable() .Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && ids.Contains(a.Id)) .Select() - .WithCache(SqlSugarCacheConst.User) .Take(20) + .WithCache(SqlSugarCacheConst.User) .ToListAsync(); return await Task.FromResult(DataResult>.Success(data)); } @@ -115,8 +115,9 @@ public class ClientCommonService : IClientCommonService Label = a.PinYinCode, Value = a.Id, }) + .Take(20) .WithCache(SqlSugarCacheConst.User) - .Take(20).ToListAsync(); + .ToListAsync(); return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess); } /// @@ -984,8 +985,8 @@ public class ClientCommonService : IClientCommonService var list = db.Queryable().Where(x => x.Status == StatusEnum.Enable.ToEnumInt() && x.IsSale == true) .WhereIF(!string.IsNullOrEmpty(queryKey), a => a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey)) .Select() - .WithCache(SqlSugarCacheConst.User) .Take(20) + .WithCache(SqlSugarCacheConst.User) .ToList(); if (list.Count > 0) { @@ -1629,8 +1630,8 @@ public class ClientCommonService : IClientCommonService .Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsOperator == true) .WhereIF(!string.IsNullOrEmpty(queryKey), a => a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey)) .Select() - .WithCache(SqlSugarCacheConst.User) .Take(20) + .WithCache(SqlSugarCacheConst.User) .ToList(); return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess); } @@ -1645,8 +1646,8 @@ public class ClientCommonService : IClientCommonService .Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsVouchingClerk == true) .WhereIF(!string.IsNullOrEmpty(queryKey), a => a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey)) .Select() - .WithCache(SqlSugarCacheConst.User) .Take(20) + .WithCache(SqlSugarCacheConst.User) .ToList(); return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess); } @@ -1660,8 +1661,8 @@ public class ClientCommonService : IClientCommonService .Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsSale == true) .WhereIF(!string.IsNullOrEmpty(queryKey), a => a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey)) .Select() - .WithCache(SqlSugarCacheConst.User) .Take(20) + .WithCache(SqlSugarCacheConst.User) .ToList(); return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess); } @@ -1676,8 +1677,8 @@ public class ClientCommonService : IClientCommonService .Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsCustom == true) .WhereIF(!string.IsNullOrEmpty(queryKey), a => a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey)) .Select() - .WithCache(SqlSugarCacheConst.User) .Take(20) + .WithCache(SqlSugarCacheConst.User) .ToList(); return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess); } @@ -1692,8 +1693,8 @@ public class ClientCommonService : IClientCommonService .Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsFinancialStaff == true) .WhereIF(!string.IsNullOrEmpty(queryKey), a => a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey)) .Select() - .WithCache(SqlSugarCacheConst.User) .Take(20) + .WithCache(SqlSugarCacheConst.User) .ToList(); return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess); } @@ -1708,8 +1709,8 @@ public class ClientCommonService : IClientCommonService .Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsCustomerService == true) .WhereIF(!string.IsNullOrEmpty(queryKey), a => a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey)) .Select() - .WithCache(SqlSugarCacheConst.User) .Take(20) + .WithCache(SqlSugarCacheConst.User) .ToList(); return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess); } @@ -1724,8 +1725,8 @@ public class ClientCommonService : IClientCommonService .Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsDriver == true) .WhereIF(!string.IsNullOrEmpty(queryKey), a => a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey)) .Select() - .WithCache(SqlSugarCacheConst.User) .Take(20) + .WithCache(SqlSugarCacheConst.User) .ToList(); return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess); } @@ -1739,8 +1740,8 @@ public class ClientCommonService : IClientCommonService .Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsDispatcher == true) .WhereIF(!string.IsNullOrEmpty(queryKey), a => a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey)) .Select() - .WithCache(SqlSugarCacheConst.User) .Take(20) + .WithCache(SqlSugarCacheConst.User) .ToList(); return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess); } diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs index f62a3763..769857a6 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs @@ -935,6 +935,7 @@ public class CommonService : ICommonService Label = a.UserName, Value = a.Id, }) + .Take(20) .WithCache(SqlSugarCacheConst.User).ToList(); return DataResult>.Success("获取数据成功!", list); } diff --git a/ds-wms-service/DS.WMS.MainApi/Program.cs b/ds-wms-service/DS.WMS.MainApi/Program.cs index c4d6d31f..9a0ecb5e 100644 --- a/ds-wms-service/DS.WMS.MainApi/Program.cs +++ b/ds-wms-service/DS.WMS.MainApi/Program.cs @@ -37,6 +37,7 @@ builder.Host builder.Services.AddAppWebInstal(); builder.Services.AddCorsInstall(); builder.Services.AddUserModuleInstall(); //用户服务 +builder.Services.AddRedisModuleInstall();//redis builder.Services.AddSqlSugarInstall(); builder.Services.AddSwaggerInstall(); builder.Services.AddJwtInstall(); @@ -44,7 +45,6 @@ builder.Services.AddSaasDbInstall();//分库服务 builder.Services.AddMultiLanguageInstall();//多语言服务 builder.Services.AddExcelModuleInstall();//Excel服务 builder.Services.AddPrintModuleInstall();//Print服务 -builder.Services.AddRedisModuleInstall();//redis // builder.Services.AddEndpointsApiExplorer(); // builder.Services.AddSwaggerGen(); diff --git a/ds-wms-service/DS.WMS.OpApi/appsettings.json b/ds-wms-service/DS.WMS.OpApi/appsettings.json index aecdaa18..9982e71a 100644 --- a/ds-wms-service/DS.WMS.OpApi/appsettings.json +++ b/ds-wms-service/DS.WMS.OpApi/appsettings.json @@ -95,9 +95,9 @@ "UserSecret": "123456", "Environment": "TEST" }, - "RedisInfo": { - "RedisConfig": "rm-m5e06xxqpa68a68ry5o.mysql.rds.aliyuncs.com:36379,password=,defaultDatabase=15" - }, + "RedisInfo": { + "RedisConfig": "127.0.0.1:6379,password=,defaultDatabase=15" + }, "BCCompare": { "Url": "http://localhost:5110/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentCompare" },