Commit 20df19c5 authored by 吴春's avatar 吴春
parents dfb73b51 4935a06b
......@@ -838,6 +838,7 @@ namespace Mall.Common
ossObj["accessKeyId"] = ReadConfigKey("tencentOSS", "accessKeyId");
ossObj["accessKeySecret"] = ReadConfigKey("tencentOSS", "accessKeySecret");
ossObj["domain"] = ReadConfigKey("tencentOSS", "domain");
ossObj["fileStoragePath"] = ReadConfigKey("tencentOSS", "fileStoragePath");
return ossObj;
}
}
......
......@@ -133,10 +133,7 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0} in ({1}) ", nameof(RB_Building_Carrier_Extend.ID), query.SelectIds);
}
//if (query.BuildingCarrierType > 0)
//{
// builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Building_Carrier_Extend.BuildingCarrierType), query.BuildingCarrierType);
//}
if (!string.IsNullOrEmpty(query.CarrierName))
{
builder.AppendFormat(" AND A.{0} LIKE @CarrierName ", nameof(RB_Building_Carrier_Extend.CarrierName));
......
......@@ -8,9 +8,9 @@ namespace Mall.ThirdCore.Oss
/// 创建上传实例
/// </summary>
/// <returns></returns>
public static IOssService GetTencent(string endpoint = null, string accessKeyId = null, string accessKeySecret = null, string bucketName = null)
public static IOssService GetTencent(string endpoint = null, string accessKeyId = null, string accessKeySecret = null, string bucketName = null,string fileStoragePath=null)
{
return TencentOss.Instance(endpoint, accessKeyId, accessKeySecret, bucketName);
return TencentOss.Instance(endpoint, accessKeyId, accessKeySecret, bucketName,fileStoragePath);
}
/// <summary>
......
......@@ -20,6 +20,10 @@ namespace Mall.ThirdCore.Oss
private string accessKeyId = "";
private string accessKeySecret = "";
private string bucketName = "";
/// <summary>
/// 文件存储位置
/// </summary>
private string fileStoragePath = "";
/// <summary>
/// 构造函数
......@@ -28,25 +32,28 @@ namespace Mall.ThirdCore.Oss
/// <param name="accessKeyId"></param>
/// <param name="accessKeySecret"></param>
/// <param name="bucketName"></param>
public TencentOss(string endpoint, string accessKeyId, string accessKeySecret, string bucketName)
/// <param name="fileStoragePath">文件存储位置</param>
public TencentOss(string endpoint, string accessKeyId, string accessKeySecret, string bucketName, string fileStoragePath)
{
this.endpoint = endpoint;
this.accessKeyId = accessKeyId;
this.accessKeySecret = accessKeySecret;
this.bucketName = bucketName;
this.fileStoragePath = fileStoragePath;
}
/// <summary>
/// 创建实例
/// </summary>
/// <returns></returns>
public static TencentOss Instance(string endpoint, string accessKeyId, string accessKeySecret, string bucketName)
public static TencentOss Instance(string endpoint, string accessKeyId, string accessKeySecret, string bucketName,string fileStoragePath)
{
endpoint ??= "ap-chengdu";
accessKeyId ??= "AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd";
accessKeySecret ??= "PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob";
bucketName ??= "viitto-1301420277";
return new TencentOss(endpoint, accessKeyId, accessKeySecret, bucketName);
fileStoragePath ??= "/SaleBefore/Goods/";
return new TencentOss(endpoint, accessKeyId, accessKeySecret, bucketName, fileStoragePath);
}
/// <summary>
......@@ -76,7 +83,7 @@ namespace Mall.ThirdCore.Oss
{
string fileExtention = System.IO.Path.GetExtension(filePath);
string bucket = this.bucketName; //存储桶,格式:BucketName-APPID
string key = @"/YB2024/Goods/"+DateTime.Now.Ticks.ToString()+fileExtention; //对象在存储桶中的位置,即称对象键
string key = fileStoragePath + DateTime.Now.Ticks.ToString() + fileExtention; //对象在存储桶中的位置,即称对象键
PutObjectRequest request = new PutObjectRequest(bucket, key, filePath);
//设置签名有效时长
request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600);
......
......@@ -172,8 +172,9 @@ namespace Mall.WebApi.Controllers.File
{
fileModel.Bucket = Common.Config.TencentOSS.GetStringValue("bucket");
}
string fileStorePath = Common.Config.TencentOSS.GetStringValue("fileStoragePath");
IsDefault = false;
IOssService ossService = OssService.GetTencent(fileModel.Region, fileModel.SecretId, fileModel.SecretKey, fileModel.Bucket);
IOssService ossService = OssService.GetTencent(fileModel.Region, fileModel.SecretId, fileModel.SecretKey, fileModel.Bucket, fileStorePath);
OssResult result = ossService.UploadFile(path_server, null);
try
{
......
......@@ -3717,6 +3717,7 @@ namespace Mall.WebApi.Controllers.TradePavilion
[HttpPost]
public async Task<ApiResult> CheckBuildingCarrierFile()
{
JObject parms = JObject.Parse(RequestParm.msg.ToString());
RB_Building_Carrier_Extend query = new RB_Building_Carrier_Extend()
{
......@@ -3726,13 +3727,17 @@ namespace Mall.WebApi.Controllers.TradePavilion
QEndDate = parms.GetStringValue("QEndDate"),
MetroName = parms.GetStringValue("MetroName"),
MetroNum = parms.GetInt("MetroNum"),
BuildingCarrierType = parms.GetInt("BuildingCarrierType"),
OpeningStatus = parms.GetInt("OpeningStatus", -1),
OpeningStatus = -1,
QShopType = parms.GetInt("QShopType"),
MallBaseId = RequestParm.MallBaseId,
TenantId = RequestParm.TenantId,
};
string OpeningStatusStr = parms.GetStringValue("OpeningStatus");
if (!string.IsNullOrEmpty(OpeningStatusStr))
{
Int32.TryParse(OpeningStatusStr, out int OpeningStatus);
query.OpeningStatus = OpeningStatus;
}
string RandomNum = parms.GetStringValue("RandomNum");
string ExcelEnumIdsStr = parms.GetStringValue("ExcelEnumIds");
List<int> ExcelEnumIds = JsonConvert.DeserializeObject<List<int>>(ExcelEnumIdsStr);
......
......@@ -480,78 +480,7 @@ namespace Mall.WebApi.Controllers.TradePavilion
// }));
//}
///// <summary>
///// 检查【商再通】载体、楼宇文件是否存在
///// </summary>
///// <returns></returns>
//[HttpPost]
//public async Task<ApiResult> CheckBuildingCarrierFile()
//{
// JObject parms = JObject.Parse(RequestParm.msg.ToString());
// RB_Building_Carrier_Extend query = new RB_Building_Carrier_Extend()
// {
// CarrierName = parms.GetStringValue("CarrierName"),
// CategoryId = parms.GetInt("CategoryId"),
// QStartDate = parms.GetStringValue("QStartDate"),
// QEndDate = parms.GetStringValue("QEndDate"),
// MetroName = parms.GetStringValue("MetroName"),
// MetroNum = parms.GetInt("MetroNum"),
// BuildingCarrierType = parms.GetInt("BuildingCarrierType"),
// OpeningStatus = parms.GetInt("OpeningStatus", -1),
// QShopType = parms.GetInt("QShopType"),
// MallBaseId = RequestParm.MallBaseId,
// TenantId = RequestParm.TenantId,
// };
// string RandomNum = parms.GetStringValue("RandomNum");
// string ExcelEnumIdsStr = parms.GetStringValue("ExcelEnumIds");
// List<int> ExcelEnumIds = JsonConvert.DeserializeObject<List<int>>(ExcelEnumIdsStr);
// string hashKey = Common.Config.GetHash(Common.Plugin.JsonHelper.Serialize(query) + ExcelEnumIdsStr + RandomNum);
// string fileName = "载体楼宇" + ".xls";
// string filePath = Path.Combine(Directory.GetCurrentDirectory(), "upfile/temporary");
// if (System.IO.Directory.Exists(filePath) == false)//如果不存在就创建file文件夹
// {
// System.IO.Directory.CreateDirectory(filePath);
// }
// string tempPath = filePath + "\\" + hashKey + "\\";
// //如果不存在就创建file文件夹
// if (!System.IO.Directory.Exists(tempPath))
// {
// System.IO.Directory.CreateDirectory(tempPath);
// }
// string fileUrl = tempPath + fileName;
// string key = "Mall_SD_BUILDINGCARRIER_" + hashKey;
// string redisValue = redisHelper.StringGet(key);
// if (string.IsNullOrEmpty(redisValue))
// {
// redisValue = redisHelper.StringGet(key);
// if (string.IsNullOrEmpty(redisValue))
// {
// redisHelper.StringSet(key, fileName, TimeSpan.FromMinutes(10));
// Task.Run(() =>
// {
// GetBuildingCarrierListToExcel(query, ExcelEnumIds, tempPath, fileUrl);
// });
// }
// }
// return await Task.Run<ApiResult>(() =>
// {
// ApiResult apiResult = new ApiResult()
// {
// resultCode = 0,
// };
// if (System.IO.File.Exists(fileUrl))
// {
// var filePath = "/upfile/temporary/" + hashKey + "/";
// var fileUrl = "/upfile/temporary/" + hashKey + "/" + fileName;
// apiResult.resultCode = 1;
// apiResult.data = new { filePath, fileUrl };
// apiResult.message = key;
// }
// return apiResult;
// });
//}
///// <summary>
///// 生成【商载通】载体、楼宇文件
......
using System;
using System.Collections.Generic;
using System.Linq;
using Mall.Common.API;
using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Mall.Model.Extend.User;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Dnc.Api.Throttle;
using Mall.CacheKey;
using Mall.CacheManager.User;
using Mall.Common;
using Mall.Common.API;
using Mall.Common.Enum;
using Mall.CacheManager.User;
using Mall.CacheKey;
using Mall.Common.Plugin;
using Mall.Common.Enum.MallBase;
using Mall.Common.Plugin;
using Mall.DataHelper.Import;
using Mall.Model.Entity.User;
using Mall.Module.Product;
using Microsoft.AspNetCore.Authorization;
using Mall.Model.Query;
using Mall.Model.Extend.AppletWeChat;
using Mall.Model.Extend.User;
using Mall.Model.Query;
using Mall.Module.Product;
using Mall.Module.User;
using Dnc.Api.Throttle;
using Mall.WebApi.Filter;
using Mall.WebApi.Helper;
using Mall.DataHelper.Import;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNetCore.Mvc.RazorPages;
using DotNetCore.CAP.Dashboard;
using Consul;
using System.Linq;
namespace Mall.WebApi.Controllers.User
{
......
......@@ -114,7 +114,9 @@
"bucket": "viitto-1301420277",
"accessKeyId": "AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd",
"accessKeySecret": "PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob",
"domain": "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com"
"domain": "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com",
//腾讯云文件存储路径
"fileStoragePath": "/SaleBefore/Goods/"
},
//阿里OSS配置
"aliOSS": {
......
......@@ -20,7 +20,8 @@ namespace TestCore
string SecretId = "AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd";
string SecretKey = "PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob";
string Bucket = "viitto-1301420277";
IOssService ossService = OssService.GetTencent(Region, SecretId, SecretKey, Bucket);
string fileStoragePath = string.Format("/{0}Mall/SaleBefore/Goods/", DateTime.Now.ToString("yyyy"));
IOssService ossService = OssService.GetTencent(Region, SecretId, SecretKey, Bucket, fileStoragePath);
OssResult result = ossService.UploadFile(filePath, null);
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment