From 8736d4c74c3a67effb1e20132d9a7f5a615c5d36 Mon Sep 17 00:00:00 2001 From: JianWeie Date: Mon, 16 Aug 2021 16:16:20 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E3=80=90=E5=90=8E=E7=AB=AF=E3=80=91?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0=E4=B8=8A=E4=BC=A0=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=B8=8D=E5=90=8C=E5=AF=BC=E8=87=B4=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98=E5=B7=AE=E5=BC=82?= =?UTF-8?q?=E5=8C=96=E9=97=AE=E9=A2=98=E3=80=82=20#I45QKZ=202=E3=80=81?= =?UTF-8?q?=E3=80=90=E5=90=8E=E7=AB=AF=E3=80=91=E4=BF=AE=E5=A4=8D=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=AF=8F=E6=9C=881=E5=8F=B7=E4=B8=BA=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=97=B6=E9=97=B4=E6=97=B6=E5=88=86=E7=A7=92=E4=B8=8D?= =?UTF-8?q?=E4=B8=BA0=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CoreCmsDistributionOrderRepository.cs | 3 ++ .../User/CoreCmsUserRepository.cs | 1 + .../CoreCmsDistributionServices.cs | 1 + .../Order/CoreCmsOrderServices.cs | 1 + .../Shop/CoreCmsSettingServices.cs | 3 ++ CoreCms.Net.Utility/Helper/UpLoadHelper.cs | 49 +++++++++++++++++++ .../Controllers/AgentController.cs | 2 + 7 files changed, 60 insertions(+) create mode 100644 CoreCms.Net.Utility/Helper/UpLoadHelper.cs diff --git a/CoreCms.Net.Repository/Distribution/CoreCmsDistributionOrderRepository.cs b/CoreCms.Net.Repository/Distribution/CoreCmsDistributionOrderRepository.cs index 55c2d59..e0f5abb 100644 --- a/CoreCms.Net.Repository/Distribution/CoreCmsDistributionOrderRepository.cs +++ b/CoreCms.Net.Repository/Distribution/CoreCmsDistributionOrderRepository.cs @@ -229,6 +229,8 @@ namespace CoreCms.Net.Repository DateTime dt = DateTime.Now; //本月第一天时间 DateTime dtFirst = dt.AddDays(1 - (dt.Day)); + dtFirst = new DateTime(dtFirst.Year, dtFirst.Month, dtFirst.Day, 0, 0, 0); + //获得某年某月的天数 int dayCount = DateTime.DaysInMonth(dt.Date.Year, dt.Date.Month); //本月最后一天时间 @@ -306,6 +308,7 @@ namespace CoreCms.Net.Repository DateTime dt = DateTime.Now; //本月第一天时间 DateTime dtFirst = dt.AddDays(1 - (dt.Day)); + dtFirst = new DateTime(dtFirst.Year, dtFirst.Month, dtFirst.Day, 0, 0, 0); //获得某年某月的天数 int year = dt.Date.Year; int month = dt.Date.Month; diff --git a/CoreCms.Net.Repository/User/CoreCmsUserRepository.cs b/CoreCms.Net.Repository/User/CoreCmsUserRepository.cs index ab6ee2e..89c5f4b 100644 --- a/CoreCms.Net.Repository/User/CoreCmsUserRepository.cs +++ b/CoreCms.Net.Repository/User/CoreCmsUserRepository.cs @@ -51,6 +51,7 @@ namespace CoreCms.Net.Repository DateTime dt = DateTime.Now; //本月第一天时间 DateTime dtFirst = dt.AddDays(1 - (dt.Day)); + dtFirst = new DateTime(dtFirst.Year, dtFirst.Month, dtFirst.Day, 0, 0, 0); //获得某年某月的天数 int year = dt.Date.Year; int month = dt.Date.Month; diff --git a/CoreCms.Net.Services/Distribution/CoreCmsDistributionServices.cs b/CoreCms.Net.Services/Distribution/CoreCmsDistributionServices.cs index 55652e6..a2acebc 100644 --- a/CoreCms.Net.Services/Distribution/CoreCmsDistributionServices.cs +++ b/CoreCms.Net.Services/Distribution/CoreCmsDistributionServices.cs @@ -92,6 +92,7 @@ namespace CoreCms.Net.Services var dt = DateTime.Now; //本月第一天时间 DateTime dtFirst = dt.AddDays(1 - (dt.Day)); + dtFirst = new DateTime(dtFirst.Year, dtFirst.Month, dtFirst.Day, 0, 0, 0); //获得某年某月的天数 int year = dt.Year; int month = dt.Month; diff --git a/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs b/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs index b19315f..81806c6 100644 --- a/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs +++ b/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs @@ -1170,6 +1170,7 @@ namespace CoreCms.Net.Services { //本月第一天时间 DateTime dtFirst = dt.AddDays(1 - (dt.Day)); + dtFirst = new DateTime(dtFirst.Year, dtFirst.Month, dtFirst.Day, 0, 0, 0); //获得某年某月的天数 int dayCount = DateTime.DaysInMonth(dt.Date.Year, dt.Date.Month); //本月最后一天时间 diff --git a/CoreCms.Net.Services/Shop/CoreCmsSettingServices.cs b/CoreCms.Net.Services/Shop/CoreCmsSettingServices.cs index 5dcd21c..d787469 100644 --- a/CoreCms.Net.Services/Shop/CoreCmsSettingServices.cs +++ b/CoreCms.Net.Services/Shop/CoreCmsSettingServices.cs @@ -191,6 +191,9 @@ namespace CoreCms.Net.Services filesStorageOptions.BucketName = GetValue(SystemSettingConstVars.FilesStorageAliYunBucketName, configs, settings); filesStorageOptions.Endpoint = GetValue(SystemSettingConstVars.FilesStorageAliYunEndpoint, configs, settings); + //格式化存储文件夹路径 + filesStorageOptions.Path = UpLoadHelper.PathFormat(filesStorageOptions.StorageType, filesStorageOptions.Path); + return filesStorageOptions; } diff --git a/CoreCms.Net.Utility/Helper/UpLoadHelper.cs b/CoreCms.Net.Utility/Helper/UpLoadHelper.cs new file mode 100644 index 0000000..41b36f9 --- /dev/null +++ b/CoreCms.Net.Utility/Helper/UpLoadHelper.cs @@ -0,0 +1,49 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2021/8/16 12:44:16 + * Description: 暂无 + ***********************************************************************/ + + +using CoreCms.Net.Configuration; + +namespace CoreCms.Net.Utility.Helper +{ + /// + /// 上传帮助类 + /// + public static class UpLoadHelper + { + /// + /// 上传路径格式化操作,防止不同类型下上传路径写入失败问题。 + /// + /// 上传类型 + /// 原始路径 + /// + public static string PathFormat(string storageType, string oldFilePath) + { + string newPath; + switch (storageType) + { + case "LocalStorage": + newPath = oldFilePath.StartsWith("/") ? oldFilePath : "/" + oldFilePath; + break; + case "AliYunOSS": + newPath = oldFilePath.StartsWith("/") ? oldFilePath.Substring(1) : oldFilePath; + break; + case "QCloudOSS": + newPath = oldFilePath.StartsWith("/") ? oldFilePath.Substring(1) : oldFilePath; + break; + default: + newPath = "/upload/"; + break; + } + newPath = newPath.EndsWith("/") ? newPath : newPath + "/"; + return newPath; + } + } +} diff --git a/CoreCms.Net.Web.WebApi/Controllers/AgentController.cs b/CoreCms.Net.Web.WebApi/Controllers/AgentController.cs index 1f2c251..c67e798 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/AgentController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/AgentController.cs @@ -265,6 +265,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers DateTime dt = DateTime.Now; //本月第一天时间 DateTime dtFirst = dt.AddDays(1 - (dt.Day)); + dtFirst = new DateTime(dtFirst.Year, dtFirst.Month, dtFirst.Day, 0, 0, 0); //获得某年某月的天数 int year = dt.Date.Year; int month = dt.Date.Month; @@ -304,6 +305,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers DateTime dt = DateTime.Now; //本月第一天时间 DateTime dtFirst = dt.AddDays(1 - (dt.Day)); + dtFirst = new DateTime(dtFirst.Year, dtFirst.Month, dtFirst.Day, 0, 0, 0); //获得某年某月的天数 int dayCount = DateTime.DaysInMonth(dt.Date.Year, dt.Date.Month); //本月最后一天时间