mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 14:53: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>
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace CoreCms.Net.IRepository.UnitOfWork
|
||||
{
|
||||
public interface IUnitOfWork
|
||||
{
|
||||
SqlSugarClient GetDbClient();
|
||||
SqlSugarScope GetDbClient();
|
||||
|
||||
void BeginTran();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace CoreCms.Net.Repository
|
||||
public abstract class BaseRepository<T> : IBaseRepository<T> where T : class, new()
|
||||
{
|
||||
//private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly SqlSugarClient _dbBase;
|
||||
private readonly SqlSugarScope _dbBase;
|
||||
|
||||
protected BaseRepository(IUnitOfWork unitOfWork)
|
||||
{
|
||||
|
||||
@@ -919,8 +919,8 @@ namespace CoreCms.Net.Repository
|
||||
}
|
||||
else
|
||||
{
|
||||
var ids = DbClient.Queryable<CoreCmsGoods>().Where(p => p.isDel == false && p.isMarketable == true)
|
||||
.Select(p => p.id).ToArray();
|
||||
var ids = await DbClient.Queryable<CoreCmsGoods>().Where(p => p.isDel == false && p.isMarketable == true)
|
||||
.Select(p => p.id).ToArrayAsync();
|
||||
var dbIds = new List<int>();
|
||||
if (ids.Any())
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取DB,保证唯一性
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SqlSugarClient GetDbClient()
|
||||
public SqlSugarScope GetDbClient()
|
||||
{
|
||||
// 必须要as,后边会用到切换数据库操作
|
||||
return _sqlSugarClient as SqlSugarClient;
|
||||
return _sqlSugarClient as SqlSugarScope;
|
||||
}
|
||||
|
||||
public void BeginTran()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
© {{shopName}} 品牌运营
|
||||
</view>
|
||||
<view class="coreshop-font-xs" v-if="shopBeiAn">
|
||||
<view v-if="shopBeiAn">备案号:{{shopBeiAn}}</view>
|
||||
<view>备案号:{{shopBeiAn}}</view>
|
||||
</view>
|
||||
<view class="coreshop-font-xs">
|
||||
Powered by CoreShop
|
||||
|
||||
@@ -135,7 +135,7 @@
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.coreshop-imgsingle { overflow: hidden; position: relative;
|
||||
.ad-img { width: 100%; float: left; position: relative; z-index: 667; }
|
||||
.ad-img { width: 100%; float: left; }
|
||||
.ad-img:last-child { margin-bottom: 0; }
|
||||
.imgup-btn { position: absolute; z-index: 668; bottom: 40px; left: 20px;
|
||||
.coreshop-btn { line-height: 2; font-size: 14px; padding: 0 25px; border-radius: 25px; }
|
||||
|
||||
@@ -695,11 +695,8 @@
|
||||
success(ress) {
|
||||
if (res.errMsg == "requestSubscribeMessage:ok") {
|
||||
console.log(ress);
|
||||
} else {
|
||||
|
||||
}
|
||||
}, fail(ress) {
|
||||
_this.$u.toast(ress.errMsg);
|
||||
console.log(ress);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -591,7 +591,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
|
||||
var _filesStorageOptions = await _coreCmsSettingServices.GetFilesStorageOptions();
|
||||
var filesStorageOptions = await _coreCmsSettingServices.GetFilesStorageOptions();
|
||||
|
||||
|
||||
var formModel = await _coreCmsFormServices.QueryByIdAsync(entity.id);
|
||||
@@ -615,100 +615,37 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
var memStream = new MemoryStream(response.RawBytes);
|
||||
|
||||
var newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + ".jpg";
|
||||
var today = DateTime.Now.ToString("yyyyMMdd");
|
||||
|
||||
if (_filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.LocalStorage.ToString())
|
||||
string url = string.Empty;
|
||||
if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.LocalStorage.ToString())
|
||||
{
|
||||
var saveUrl = "/Upload/QrCode/" + today + "/";
|
||||
var dirPath = _webHostEnvironment.WebRootPath + saveUrl;
|
||||
string bucketBindDomain = AppSettingsConstVars.AppConfigAppUrl;
|
||||
url = _toolsServices.UpLoadBase64ForLocalStorage(filesStorageOptions, memStream);
|
||||
|
||||
if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);
|
||||
var filePath = dirPath + newFileName;
|
||||
var fileUrl = saveUrl + newFileName;
|
||||
|
||||
//储存图片
|
||||
System.IO.File.Delete(filePath);
|
||||
await using (var fs = new FileStream(filePath, FileMode.CreateNew))
|
||||
{
|
||||
await memStream.CopyToAsync(fs).ConfigureAwait(false);
|
||||
await fs.FlushAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "上传成功!";
|
||||
jm.data = new
|
||||
{
|
||||
fileUrl,
|
||||
src = bucketBindDomain + fileUrl
|
||||
};
|
||||
}
|
||||
else if (_filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.AliYunOSS.ToString())
|
||||
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.AliYunOSS.ToString())
|
||||
{
|
||||
//上传到阿里云
|
||||
|
||||
// 设置当前流的位置为流的开始
|
||||
memStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
await using var fileStream = memStream;
|
||||
|
||||
var md5 = OssUtils.ComputeContentMd5(fileStream, memStream.Length);
|
||||
|
||||
var filePath = "Upload/QrCode/" + today + "/" + newFileName; //云文件保存路径
|
||||
//初始化阿里云配置--外网Endpoint、访问ID、访问password
|
||||
var aliyun = new OssClient(_filesStorageOptions.Endpoint, _filesStorageOptions.AccessKeyId, _filesStorageOptions.AccessKeySecret);
|
||||
//将文件md5值赋值给meat头信息,服务器验证文件MD5
|
||||
var objectMeta = new ObjectMetadata
|
||||
{
|
||||
ContentMd5 = md5
|
||||
};
|
||||
//文件上传--空间名、文件保存路径、文件流、meta头信息(文件md5) //返回meta头信息(文件md5)
|
||||
aliyun.PutObject(_filesStorageOptions.BucketName, filePath, fileStream, objectMeta);
|
||||
//返回给UEditor的插入编辑器的图片的src
|
||||
jm.code = 0;
|
||||
jm.msg = "上传成功";
|
||||
jm.data = new
|
||||
{
|
||||
fileUrl = _filesStorageOptions.BucketBindUrl + filePath,
|
||||
src = _filesStorageOptions.BucketBindUrl + filePath
|
||||
};
|
||||
url = await _toolsServices.UpLoadBase64ForAliYunOSS(filesStorageOptions, memStream);
|
||||
}
|
||||
else if (_filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.QCloudOSS.ToString())
|
||||
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.QCloudOSS.ToString())
|
||||
{
|
||||
//上传到腾讯云OSS
|
||||
//初始化 CosXmlConfig
|
||||
string appid = _filesStorageOptions.AccountId;//设置腾讯云账户的账户标识 APPID
|
||||
string region = _filesStorageOptions.CosRegion; //设置一个默认的存储桶地域
|
||||
CosXmlConfig config = new CosXmlConfig.Builder()
|
||||
//.SetAppid(appid)
|
||||
.IsHttps(true) //设置默认 HTTPS 请求
|
||||
.SetRegion(region) //设置一个默认的存储桶地域
|
||||
.SetDebugLog(true) //显示日志
|
||||
.Build(); //创建 CosXmlConfig 对象
|
||||
|
||||
long durationSecond = 600; //每次请求签名有效时长,单位为秒
|
||||
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(
|
||||
_filesStorageOptions.AccessKeyId, _filesStorageOptions.AccessKeySecret, durationSecond);
|
||||
|
||||
|
||||
var cosXml = new CosXmlServer(config, qCloudCredentialProvider);
|
||||
|
||||
byte[] bytes = memStream.ToArray();
|
||||
|
||||
var filePath = "Upload/QrCode/" + today + "/" + newFileName; //云文件保存路径
|
||||
COSXML.Model.Object.PutObjectRequest putObjectRequest = new COSXML.Model.Object.PutObjectRequest(_filesStorageOptions.TencentBucketName, filePath, bytes);
|
||||
|
||||
cosXml.PutObject(putObjectRequest);
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "上传成功";
|
||||
jm.data = new
|
||||
{
|
||||
fileUrl = _filesStorageOptions.BucketBindUrl + filePath,
|
||||
src = _filesStorageOptions.BucketBindUrl + filePath
|
||||
};
|
||||
url = _toolsServices.UpLoadBase64ForQCloudOSS(filesStorageOptions, response.RawBytes);
|
||||
}
|
||||
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.QiNiuKoDo.ToString())
|
||||
{
|
||||
//上传到七牛云kodo
|
||||
url = _toolsServices.UpLoadBase64ForQiNiuKoDo(filesStorageOptions, response.RawBytes);
|
||||
}
|
||||
|
||||
var bl = !string.IsNullOrEmpty(url);
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? "上传成功!" : "上传失败";
|
||||
jm.data = new
|
||||
{
|
||||
fileUrl = url,
|
||||
src = url
|
||||
};
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -737,7 +674,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
|
||||
var _filesStorageOptions = await _coreCmsSettingServices.GetFilesStorageOptions();
|
||||
var filesStorageOptions = await _coreCmsSettingServices.GetFilesStorageOptions();
|
||||
|
||||
|
||||
var pageModel = await _pagesServices.QueryByClauseAsync(p => p.code == entity.id);
|
||||
@@ -761,100 +698,37 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
var memStream = new MemoryStream(response.RawBytes);
|
||||
|
||||
var newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + ".jpg";
|
||||
var today = DateTime.Now.ToString("yyyyMMdd");
|
||||
|
||||
if (_filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.LocalStorage.ToString())
|
||||
string url = string.Empty;
|
||||
if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.LocalStorage.ToString())
|
||||
{
|
||||
var saveUrl = "/Upload/QrCode/" + today + "/";
|
||||
var dirPath = _webHostEnvironment.WebRootPath + saveUrl;
|
||||
string bucketBindDomain = AppSettingsConstVars.AppConfigAppUrl;
|
||||
url = _toolsServices.UpLoadBase64ForLocalStorage(filesStorageOptions, memStream);
|
||||
|
||||
if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);
|
||||
var filePath = dirPath + newFileName;
|
||||
var fileUrl = saveUrl + newFileName;
|
||||
|
||||
//储存图片
|
||||
System.IO.File.Delete(filePath);
|
||||
await using (var fs = new FileStream(filePath, FileMode.CreateNew))
|
||||
{
|
||||
await memStream.CopyToAsync(fs).ConfigureAwait(false);
|
||||
await fs.FlushAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "上传成功!";
|
||||
jm.data = new
|
||||
{
|
||||
fileUrl,
|
||||
src = bucketBindDomain + fileUrl
|
||||
};
|
||||
}
|
||||
else if (_filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.AliYunOSS.ToString())
|
||||
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.AliYunOSS.ToString())
|
||||
{
|
||||
//上传到阿里云
|
||||
|
||||
// 设置当前流的位置为流的开始
|
||||
memStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
await using var fileStream = memStream;
|
||||
|
||||
var md5 = OssUtils.ComputeContentMd5(fileStream, memStream.Length);
|
||||
|
||||
var filePath = "Upload/QrCode/" + today + "/" + newFileName; //云文件保存路径
|
||||
//初始化阿里云配置--外网Endpoint、访问ID、访问password
|
||||
var aliyun = new OssClient(_filesStorageOptions.Endpoint, _filesStorageOptions.AccessKeyId, _filesStorageOptions.AccessKeySecret);
|
||||
//将文件md5值赋值给meat头信息,服务器验证文件MD5
|
||||
var objectMeta = new ObjectMetadata
|
||||
{
|
||||
ContentMd5 = md5
|
||||
};
|
||||
//文件上传--空间名、文件保存路径、文件流、meta头信息(文件md5) //返回meta头信息(文件md5)
|
||||
aliyun.PutObject(_filesStorageOptions.BucketName, filePath, fileStream, objectMeta);
|
||||
//返回给UEditor的插入编辑器的图片的src
|
||||
jm.code = 0;
|
||||
jm.msg = "上传成功";
|
||||
jm.data = new
|
||||
{
|
||||
fileUrl = _filesStorageOptions.BucketBindUrl + filePath,
|
||||
src = _filesStorageOptions.BucketBindUrl + filePath
|
||||
};
|
||||
url = await _toolsServices.UpLoadBase64ForAliYunOSS(filesStorageOptions, memStream);
|
||||
}
|
||||
else if (_filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.QCloudOSS.ToString())
|
||||
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.QCloudOSS.ToString())
|
||||
{
|
||||
//上传到腾讯云OSS
|
||||
//初始化 CosXmlConfig
|
||||
string appid = _filesStorageOptions.AccountId;//设置腾讯云账户的账户标识 APPID
|
||||
string region = _filesStorageOptions.CosRegion; //设置一个默认的存储桶地域
|
||||
CosXmlConfig config = new CosXmlConfig.Builder()
|
||||
//.SetAppid(appid)
|
||||
.IsHttps(true) //设置默认 HTTPS 请求
|
||||
.SetRegion(region) //设置一个默认的存储桶地域
|
||||
.SetDebugLog(true) //显示日志
|
||||
.Build(); //创建 CosXmlConfig 对象
|
||||
|
||||
long durationSecond = 600; //每次请求签名有效时长,单位为秒
|
||||
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(
|
||||
_filesStorageOptions.AccessKeyId, _filesStorageOptions.AccessKeySecret, durationSecond);
|
||||
|
||||
|
||||
var cosXml = new CosXmlServer(config, qCloudCredentialProvider);
|
||||
|
||||
byte[] bytes = memStream.ToArray();
|
||||
|
||||
var filePath = "Upload/QrCode/" + today + "/" + newFileName; //云文件保存路径
|
||||
COSXML.Model.Object.PutObjectRequest putObjectRequest = new COSXML.Model.Object.PutObjectRequest(_filesStorageOptions.TencentBucketName, filePath, bytes);
|
||||
|
||||
cosXml.PutObject(putObjectRequest);
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "上传成功";
|
||||
jm.data = new
|
||||
{
|
||||
fileUrl = _filesStorageOptions.BucketBindUrl + filePath,
|
||||
src = _filesStorageOptions.BucketBindUrl + filePath
|
||||
};
|
||||
url = _toolsServices.UpLoadBase64ForQCloudOSS(filesStorageOptions, response.RawBytes);
|
||||
}
|
||||
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.QiNiuKoDo.ToString())
|
||||
{
|
||||
//上传到七牛云kodo
|
||||
url = _toolsServices.UpLoadBase64ForQiNiuKoDo(filesStorageOptions, response.RawBytes);
|
||||
}
|
||||
|
||||
var bl = !string.IsNullOrEmpty(url);
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? "上传成功!" : "上传失败";
|
||||
jm.data = new
|
||||
{
|
||||
fileUrl = url,
|
||||
src = url
|
||||
};
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1052,4 +1052,16 @@ xm-select .xm-body .xm-option.hide-icon.selected {
|
||||
.layadmin-side-shrink .layui-layout-admin .layui-logo {
|
||||
width: 60px;
|
||||
background-image: url(../images/common/logoMin.png);
|
||||
}
|
||||
.ew-tree-table .ew-tree-pack {
|
||||
cursor: pointer;
|
||||
line-height: 16px;
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.ew-tree-table .ew-tree-pack > span {
|
||||
height: 16px;
|
||||
line-height: 16px;
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
}
|
||||
@@ -358,4 +358,7 @@ xm-select .xm-label .xm-label-block, xm-select .xm-body .xm-option.hide-icon.sel
|
||||
.longLogo { height: 50px; width: 220px; display: none; }
|
||||
}
|
||||
|
||||
.layadmin-side-shrink .layui-layout-admin .layui-logo { width: 60px; background-image: url(../images/common/logoMin.png); }
|
||||
.layadmin-side-shrink .layui-layout-admin .layui-logo { width: 60px; background-image: url(../images/common/logoMin.png); }
|
||||
|
||||
.ew-tree-table .ew-tree-pack { cursor: pointer; line-height: 16px; display: inline; vertical-align: middle; }
|
||||
.ew-tree-table .ew-tree-pack > span { height: 16px; line-height: 16px; display: inline; vertical-align: middle; }
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user