mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:43:26 +08:00
## 1.2.7(2022-01-1)
通用调整: 【调整】启用SqlSugar.Ioc及SqlSugarCore,弃用SqlSugarClient,保证线程安全及提高对象代码容错率。减少mysql下偶发性问题。 【优化】优化【后台生成小程序码】【后台生成预览页面设计小程序码】代码,并修复【七牛云】上传方式。#I4OHP9 【优化】修复treeTable的折叠列字符字符过长导致内容显示不全的问题。 【调整】应会员需求,开源社区版前端代码增加使用账号密码登录,取回账号密码的示例文档。详情预览【CoreCms.Net.Uni-App\CoreShop\pages\login】下文件。#I4O4H4 【优化】调整首页商品【goods】在根据栏目选择商品时候排序问题,调整为【sort desc,id desc】按照先自定义排序,后数据序列排序。取消【creattime desc】排序。#I4NW4F 【修复】修复首页设计使用【图片模块】导致图片浮动遮挡右下角按钮的问题。#I4NPZL 【优化】调整小程序消息通知设置,当未设置消息提醒时,不弹出错误项提示功能,保证订单下单时到支付订单页面不报错误提示。#I4N4UL。 ## 0.0.3 会员版/商业版: 【修复】修复下单界面【添加收货地址】按钮宽度及不居中的问题。 【优化】去除接口生成海报不需要的字体,只保留思源标准字体。 【修复】修复弹窗登录报【checkbox未嵌套的问题】,导致授权页有报错。#I4OYPR 【修复】移除【Microsoft.IdentityModel.Tokens】组件,防止更新组件导致对jwt token校验的影响。 【优化】移除【http.interceptor.js】遗留的前端请求拦截器。
This commit is contained in:
@@ -17,6 +17,7 @@ using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Loging;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SqlSugar;
|
||||
using SqlSugar.IOC;
|
||||
|
||||
namespace CoreCms.Net.Core.Config
|
||||
{
|
||||
@@ -25,70 +26,49 @@ namespace CoreCms.Net.Core.Config
|
||||
/// </summary>
|
||||
public static class SqlSugarSetup
|
||||
{
|
||||
|
||||
public static void AddSqlSugarSetup(this IServiceCollection services)
|
||||
{
|
||||
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||
string connectionString = AppSettingsConstVars.DbSqlConnection;
|
||||
string dbTypeString = AppSettingsConstVars.DbDbType;
|
||||
|
||||
//获取数据类型
|
||||
var dbType = dbTypeString == DbType.MySql.ToString() ? DbType.MySql : DbType.SqlServer;
|
||||
//判断是否开启redis设置二级缓存方式
|
||||
ICacheService myCache = AppSettingsConstVars.RedisUseCache
|
||||
? (ICacheService)new SqlSugarRedisCache()
|
||||
: new SqlSugarMemoryCache();
|
||||
|
||||
var connectionConfig = new ConnectionConfig()
|
||||
//注入 ORM
|
||||
SugarIocServices.AddSqlSugar(new IocConfig()
|
||||
{
|
||||
ConnectionString = connectionString, //必填
|
||||
DbType = dbType, //必填
|
||||
IsAutoCloseConnection = false,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
//数据库连接
|
||||
ConnectionString = AppSettingsConstVars.DbSqlConnection,
|
||||
//判断数据库类型
|
||||
DbType = AppSettingsConstVars.DbDbType == IocDbType.MySql.ToString() ? IocDbType.MySql : IocDbType.SqlServer,
|
||||
//是否开启自动关闭数据库连接-//不设成true要手动close
|
||||
IsAutoCloseConnection = true,
|
||||
});
|
||||
|
||||
ConfigureExternalServices = new ConfigureExternalServices()
|
||||
//设置参数
|
||||
services.ConfigurationSugar(db =>
|
||||
{
|
||||
db.CurrentConnectionConfig.InitKeyType = InitKeyType.Attribute;
|
||||
db.CurrentConnectionConfig.ConfigureExternalServices = new ConfigureExternalServices()
|
||||
{
|
||||
DataInfoCacheService = myCache
|
||||
},
|
||||
};
|
||||
//判断是否开启redis设置二级缓存方式
|
||||
DataInfoCacheService = AppSettingsConstVars.RedisUseCache ? (ICacheService)new SqlSugarRedisCache() : new SqlSugarMemoryCache()
|
||||
};
|
||||
|
||||
//执行SQL 错误事件,可监控sql(暂时屏蔽,需要可开启)
|
||||
//db.Aop.OnLogExecuting = (sql, p) =>
|
||||
//{
|
||||
// NLogUtil.WriteFileLog(NLog.LogLevel.Error, LogType.Other, "SqlSugar执行SQL错误事件打印Sql", sql);
|
||||
//};
|
||||
|
||||
services.AddScoped<ISqlSugarClient>(o =>
|
||||
//执行SQL 错误事件
|
||||
db.Aop.OnError = (exp) =>
|
||||
{
|
||||
NLogUtil.WriteFileLog(NLog.LogLevel.Error, LogType.Other, "SqlSugar", "执行SQL错误事件", exp);
|
||||
};
|
||||
|
||||
var db = new SqlSugarClient(connectionConfig); //默认SystemTable
|
||||
|
||||
//日志处理
|
||||
////SQL执行前 可以修改SQL
|
||||
//db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
//{
|
||||
// //获取sql
|
||||
// Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||
// Console.WriteLine();
|
||||
|
||||
// //通过TempItems这个变量来算出这个SQL执行时间(1)
|
||||
// if (db.TempItems == null) db.TempItems = new Dictionary<string, object>();
|
||||
// db.TempItems.Add("logTime", DateTime.Now);
|
||||
// //通过TempItems这个变量来算出这个SQL执行时间(2)
|
||||
// var startingTime = db.TempItems["logTime"];
|
||||
// db.TempItems.Remove("time");
|
||||
// var completedTime = DateTime.Now;
|
||||
|
||||
|
||||
//};
|
||||
//db.Aop.OnLogExecuted = (sql, pars) => //SQL执行完事件
|
||||
//{
|
||||
|
||||
//};
|
||||
//db.Aop.OnLogExecuting = (sql, pars) => //SQL执行前事件
|
||||
//{
|
||||
|
||||
//};
|
||||
db.Aop.OnError = (exp) =>//执行SQL 错误事件
|
||||
{
|
||||
NLogUtil.WriteFileLog(NLog.LogLevel.Error, LogType.Other, "SqlSugar", "执行SQL错误事件", exp);
|
||||
};
|
||||
return db;
|
||||
});
|
||||
//设置更多连接参数
|
||||
//db.CurrentConnectionConfig.XXXX=XXXX
|
||||
//db.CurrentConnectionConfig.MoreSetting=new MoreSetting(){}
|
||||
//读写分离等都在这儿设置
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.2.3" />
|
||||
<PackageReference Include="Qc.YilianyunSdk" Version="1.0.7" />
|
||||
<PackageReference Include="SqlSugar.IOC" Version="1.7.0" />
|
||||
<PackageReference Include="sqlSugarCore" Version="5.0.5.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user