From 35811f0be18fd9b43e812a1eb01ce4c8046fbad0 Mon Sep 17 00:00:00 2001 From: JianWeie Date: Mon, 3 Jan 2022 03:11:25 +0800 Subject: [PATCH] =?UTF-8?q?##=201.2.7=EF=BC=882022-01-1=EF=BC=89=20?= =?UTF-8?q?=E9=80=9A=E7=94=A8=E8=B0=83=E6=95=B4=EF=BC=9A=20=E3=80=90?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E3=80=91=E5=90=AF=E7=94=A8SqlSugar.Ioc?= =?UTF-8?q?=E5=8F=8ASqlSugarCore=EF=BC=8C=E5=BC=83=E7=94=A8SqlSugarClient?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E8=AF=81=E7=BA=BF=E7=A8=8B=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E5=8F=8A=E6=8F=90=E9=AB=98=E5=AF=B9=E8=B1=A1=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=AE=B9=E9=94=99=E7=8E=87=E3=80=82=E5=87=8F=E5=B0=91mysql?= =?UTF-8?q?=E4=B8=8B=E5=81=B6=E5=8F=91=E6=80=A7=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?=20=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=90=E5=90=8E=E5=8F=B0=E7=94=9F=E6=88=90=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=A0=81=E3=80=91=E3=80=90=E5=90=8E=E5=8F=B0=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=A2=84=E8=A7=88=E9=A1=B5=E9=9D=A2=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=A0=81=E3=80=91=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E4=BF=AE=E5=A4=8D=E3=80=90=E4=B8=83=E7=89=9B?= =?UTF-8?q?=E4=BA=91=E3=80=91=E4=B8=8A=E4=BC=A0=E6=96=B9=E5=BC=8F=E3=80=82?= =?UTF-8?q?#I4OHP9=20=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DtreeTable=E7=9A=84=E6=8A=98=E5=8F=A0=E5=88=97=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E5=AD=97=E7=AC=A6=E8=BF=87=E9=95=BF=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82=20=E3=80=90=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E3=80=91=E5=BA=94=E4=BC=9A=E5=91=98=E9=9C=80=E6=B1=82=EF=BC=8C?= =?UTF-8?q?=E5=BC=80=E6=BA=90=E7=A4=BE=E5=8C=BA=E7=89=88=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=A2=9E=E5=8A=A0=E4=BD=BF=E7=94=A8=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E5=AF=86=E7=A0=81=E7=99=BB=E5=BD=95=EF=BC=8C=E5=8F=96?= =?UTF-8?q?=E5=9B=9E=E8=B4=A6=E5=8F=B7=E5=AF=86=E7=A0=81=E7=9A=84=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E6=96=87=E6=A1=A3=E3=80=82=E8=AF=A6=E6=83=85=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E3=80=90CoreCms.Net.Uni-App\CoreShop\pages\login?= =?UTF-8?q?=E3=80=91=E4=B8=8B=E6=96=87=E4=BB=B6=E3=80=82#I4O4H4=20?= =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E8=B0=83=E6=95=B4=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E5=95=86=E5=93=81=E3=80=90goods=E3=80=91=E5=9C=A8?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=A0=8F=E7=9B=AE=E9=80=89=E6=8B=A9=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=97=B6=E5=80=99=E6=8E=92=E5=BA=8F=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E8=B0=83=E6=95=B4=E4=B8=BA=E3=80=90sort=20desc,id=20d?= =?UTF-8?q?esc=E3=80=91=E6=8C=89=E7=85=A7=E5=85=88=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=8E=92=E5=BA=8F=EF=BC=8C=E5=90=8E=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E6=8E=92=E5=BA=8F=E3=80=82=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E3=80=90creattime=20desc=E3=80=91=E6=8E=92=E5=BA=8F=E3=80=82#I?= =?UTF-8?q?4NW4F=20=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E8=AE=BE=E8=AE=A1=E4=BD=BF=E7=94=A8=E3=80=90?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=A8=A1=E5=9D=97=E3=80=91=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=B5=AE=E5=8A=A8=E9=81=AE=E6=8C=A1=E5=8F=B3?= =?UTF-8?q?=E4=B8=8B=E8=A7=92=E6=8C=89=E9=92=AE=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82#I4NPZL=20=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=BD=93=E6=9C=AA?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=BC=B9=E5=87=BA=E9=94=99=E8=AF=AF=E9=A1=B9?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=B8=8B=E5=8D=95=E6=97=B6=E5=88=B0=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E8=AE=A2=E5=8D=95=E9=A1=B5=E9=9D=A2=E4=B8=8D=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E3=80=82#I4N4UL=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 0.0.3 会员版/商业版: 【修复】修复下单界面【添加收货地址】按钮宽度及不居中的问题。 【优化】去除接口生成海报不需要的字体,只保留思源标准字体。 【修复】修复弹窗登录报【checkbox未嵌套的问题】,导致授权页有报错。#I4OYPR 【修复】移除【Microsoft.IdentityModel.Tokens】组件,防止更新组件导致对jwt token校验的影响。 【优化】移除【http.interceptor.js】遗留的前端请求拦截器。 --- CoreCms.Net.Core/Config/SqlSugarSetup.cs | 86 +++---- CoreCms.Net.Core/CoreCms.Net.Core.csproj | 1 + .../UnitOfWork/IUnitOfWork.cs | 2 +- CoreCms.Net.Repository/BaseRepository.cs | 2 +- .../Good/CoreCmsGoodsRepository.cs | 4 +- .../UnitOfWork/UnitOfWork.cs | 14 +- .../Shop/CoreCmsPagesServices.cs | 2 +- .../coreshop-copyright/coreshop-copyright.vue | 2 +- .../coreshop-page/coreshop-imgSingle.vue | 2 +- .../CoreShop/pages/placeOrder/index/index.vue | 3 - .../Controllers/Com/ToolsController.cs | 218 ++++-------------- .../wwwroot/static/css/overWrite.css | 12 + .../wwwroot/static/css/overWrite.less | 5 +- .../wwwroot/static/css/overWrite.min.css | 2 +- 14 files changed, 114 insertions(+), 241 deletions(-) diff --git a/CoreCms.Net.Core/Config/SqlSugarSetup.cs b/CoreCms.Net.Core/Config/SqlSugarSetup.cs index 4e45849c..52a2ff5e 100644 --- a/CoreCms.Net.Core/Config/SqlSugarSetup.cs +++ b/CoreCms.Net.Core/Config/SqlSugarSetup.cs @@ -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 /// 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(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(); - // 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(){} + //读写分离等都在这儿设置 + }); } } diff --git a/CoreCms.Net.Core/CoreCms.Net.Core.csproj b/CoreCms.Net.Core/CoreCms.Net.Core.csproj index dfae7f49..a476580e 100644 --- a/CoreCms.Net.Core/CoreCms.Net.Core.csproj +++ b/CoreCms.Net.Core/CoreCms.Net.Core.csproj @@ -25,6 +25,7 @@ + diff --git a/CoreCms.Net.IRepository/UnitOfWork/IUnitOfWork.cs b/CoreCms.Net.IRepository/UnitOfWork/IUnitOfWork.cs index 11cab486..0c2cb40a 100644 --- a/CoreCms.Net.IRepository/UnitOfWork/IUnitOfWork.cs +++ b/CoreCms.Net.IRepository/UnitOfWork/IUnitOfWork.cs @@ -15,7 +15,7 @@ namespace CoreCms.Net.IRepository.UnitOfWork { public interface IUnitOfWork { - SqlSugarClient GetDbClient(); + SqlSugarScope GetDbClient(); void BeginTran(); diff --git a/CoreCms.Net.Repository/BaseRepository.cs b/CoreCms.Net.Repository/BaseRepository.cs index c170af12..1b6bedc2 100644 --- a/CoreCms.Net.Repository/BaseRepository.cs +++ b/CoreCms.Net.Repository/BaseRepository.cs @@ -22,7 +22,7 @@ namespace CoreCms.Net.Repository public abstract class BaseRepository : IBaseRepository where T : class, new() { //private readonly IUnitOfWork _unitOfWork; - private readonly SqlSugarClient _dbBase; + private readonly SqlSugarScope _dbBase; protected BaseRepository(IUnitOfWork unitOfWork) { diff --git a/CoreCms.Net.Repository/Good/CoreCmsGoodsRepository.cs b/CoreCms.Net.Repository/Good/CoreCmsGoodsRepository.cs index 29d26e57..a1d2c72b 100644 --- a/CoreCms.Net.Repository/Good/CoreCmsGoodsRepository.cs +++ b/CoreCms.Net.Repository/Good/CoreCmsGoodsRepository.cs @@ -919,8 +919,8 @@ namespace CoreCms.Net.Repository } else { - var ids = DbClient.Queryable().Where(p => p.isDel == false && p.isMarketable == true) - .Select(p => p.id).ToArray(); + var ids = await DbClient.Queryable().Where(p => p.isDel == false && p.isMarketable == true) + .Select(p => p.id).ToArrayAsync(); var dbIds = new List(); if (ids.Any()) { diff --git a/CoreCms.Net.Repository/UnitOfWork/UnitOfWork.cs b/CoreCms.Net.Repository/UnitOfWork/UnitOfWork.cs index c713cada..d3efd188 100644 --- a/CoreCms.Net.Repository/UnitOfWork/UnitOfWork.cs +++ b/CoreCms.Net.Repository/UnitOfWork/UnitOfWork.cs @@ -14,6 +14,7 @@ using CoreCms.Net.IRepository.UnitOfWork; using CoreCms.Net.Loging; using NLog; using SqlSugar; +using SqlSugar.IOC; namespace CoreCms.Net.Repository.UnitOfWork { @@ -21,19 +22,24 @@ namespace CoreCms.Net.Repository.UnitOfWork { private readonly ISqlSugarClient _sqlSugarClient; - public UnitOfWork(ISqlSugarClient sqlSugarClient) + //public UnitOfWork(ISqlSugarClient sqlSugarClient) + //{ + // _sqlSugarClient = sqlSugarClient; + //} + + public UnitOfWork() { - _sqlSugarClient = sqlSugarClient; + _sqlSugarClient = DbScoped.SugarScope; } /// /// 获取DB,保证唯一性 /// /// - public SqlSugarClient GetDbClient() + public SqlSugarScope GetDbClient() { // 必须要as,后边会用到切换数据库操作 - return _sqlSugarClient as SqlSugarClient; + return _sqlSugarClient as SqlSugarScope; } public void BeginTran() diff --git a/CoreCms.Net.Services/Shop/CoreCmsPagesServices.cs b/CoreCms.Net.Services/Shop/CoreCmsPagesServices.cs index 5b6774e1..fe143487 100644 --- a/CoreCms.Net.Services/Shop/CoreCmsPagesServices.cs +++ b/CoreCms.Net.Services/Shop/CoreCmsPagesServices.cs @@ -421,7 +421,7 @@ namespace CoreCms.Net.Services } limit = limit > 0 ? limit : 10; - var goods = await _goodsServices.QueryListByClauseAsync(where, limit, p => p.createTime, OrderByType.Desc, false); + var goods = await _goodsServices.QueryPageAsync(where, " sort desc,id desc ", 1, limit, true); if (goods != null && goods.Any()) { JArray result = JArray.FromObject(goods); diff --git a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-copyright/coreshop-copyright.vue b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-copyright/coreshop-copyright.vue index aac5d63f..1dfa8b24 100644 --- a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-copyright/coreshop-copyright.vue +++ b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-copyright/coreshop-copyright.vue @@ -4,7 +4,7 @@ © {{shopName}} 品牌运营 - 备案号:{{shopBeiAn}} + 备案号:{{shopBeiAn}} Powered by CoreShop diff --git a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-page/coreshop-imgSingle.vue b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-page/coreshop-imgSingle.vue index c3f18f08..664c74c2 100644 --- a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-page/coreshop-imgSingle.vue +++ b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-page/coreshop-imgSingle.vue @@ -135,7 +135,7 @@