修改驼峰自定义
continuous-integration/drone/push Build is running Details

IRC_NewDev
hang 2024-09-03 15:51:51 +08:00
parent 1072049741
commit dfba116268
9 changed files with 213 additions and 150 deletions

View File

@ -304,8 +304,8 @@ namespace IRaCIS.Api.Controllers
var client = new Client(new AlibabaCloud.OpenApiClient.Models.Config()
{
AccessKeyId = ossOptions.accessKeyId,
AccessKeySecret = ossOptions.accessKeySecret,
AccessKeyId = ossOptions.AccessKeyId,
AccessKeySecret = ossOptions.AccessKeySecret,
//AccessKeyId = "LTAI5tJV76pYX5yPg1N9QVE8",
//AccessKeySecret = "roRNLa9YG1of4pYruJGCNKBXEWTAWa",
@ -316,25 +316,25 @@ namespace IRaCIS.Api.Controllers
// 将<YOUR_ROLE_SESSION_NAME>设置为自定义的会话名称例如oss-role-session。
assumeRoleRequest.RoleSessionName = $"session-name-{NewId.NextGuid()}";
// 将<YOUR_ROLE_ARN>替换为拥有上传文件到指定OSS Bucket权限的RAM角色的ARN。
assumeRoleRequest.RoleArn = ossOptions.roleArn;
assumeRoleRequest.RoleArn = ossOptions.RoleArn;
//assumeRoleRequest.RoleArn = "acs:ram::1899121822495495:role/webdirect";
assumeRoleRequest.DurationSeconds = ossOptions.durationSeconds;
assumeRoleRequest.DurationSeconds = ossOptions.DurationSeconds;
var runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
var response = client.AssumeRoleWithOptions(assumeRoleRequest, runtime);
var credentials = response.Body.Credentials;
var tempToken = new AliyunOSSTempToken()
{
accessKeyId = credentials.AccessKeyId,
accessKeySecret = credentials.AccessKeySecret,
expiration = credentials.Expiration,
securityToken = credentials.SecurityToken,
AccessKeyId = credentials.AccessKeyId,
AccessKeySecret = credentials.AccessKeySecret,
Expiration = credentials.Expiration,
SecurityToken = credentials.SecurityToken,
region = ossOptions.region,
bucketName = ossOptions.bucketName,
endPoint = ossOptions.endPoint,
viewEndpoint = ossOptions.viewEndpoint,
Region = ossOptions.Region,
BucketName = ossOptions.BucketName,
EndPoint = ossOptions.EndPoint,
ViewEndpoint = ossOptions.ViewEndpoint,
};

View File

@ -1,55 +1,35 @@
using IRaCIS.Core.Domain.Share;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Globalization;
using System.Threading.Tasks;
using System.Reflection;
namespace IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson
namespace IRaCIS.Core.API
{
public class CustomJsonResult : JsonResult
{
public CustomJsonResult(object value) : base(value) { }
public override void ExecuteResult(ActionContext context)
{
var converter = context.HttpContext.RequestServices.GetService<JSONTimeZoneConverter>();
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
string dateFormat;
//public class CustomContractResolver : DefaultContractResolver
//{
// protected override JsonContract CreateContract(Type objectType)
// {
// var contract = base.CreateContract(objectType);
if (!isEn_US)
{
// Chinese date format
dateFormat = "yyyy-MM-dd HH:mm:ss";
}
else
{
// Default or English date format
dateFormat = "MM/dd/yyyy HH:mm:ss";
}
// // 检查类是否有 LowercaseJsonAttribute 标记
// if (objectType.GetCustomAttribute<LowerCamelCaseJsonAttribute>() != null)
// {
// contract.NamingStrategy = new IRCCamelCaseNamingStrategy();
// }
var serializerSettings = new JsonSerializerSettings
{
DateFormatString = dateFormat,
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
ContractResolver = new NullToEmptyStringResolver(),
DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind,
// return contract;
// }
//}
};
serializerSettings.Converters.Add(converter);
var json = JsonConvert.SerializeObject(Value, serializerSettings);
context.HttpContext.Response.ContentType = "application/json";
context.HttpContext.Response.WriteAsync(json);
}
}
#region 废弃
public class MyDateTimeConverter : JsonConverter<DateTime>
{
public override DateTime ReadJson(JsonReader reader, Type objectType, DateTime existingValue, bool hasExistingValue, JsonSerializer serializer)
@ -115,11 +95,5 @@ namespace IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson
}
}
#endregion
}

View File

@ -9,6 +9,8 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Globalization;
using System.Text.Json;
using Newtonsoft.Json.Serialization;
namespace IRaCIS.Core.API
{
@ -20,12 +22,20 @@ namespace IRaCIS.Core.API
services.AddHttpContextAccessor();
services.AddScoped<JSONTimeZoneConverter>();
services.AddScoped<ObjectStorePathConvert>();
services.AddScoped<IOSSService,OSSService>();
services.AddScoped<IOSSService, OSSService>();
builder.AddNewtonsoftJson(options =>
{
//大驼峰
//options.SerializerSettings.ContractResolver = new DefaultContractResolver();
//小驼峰
//options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
// 忽略循环引用
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;

View File

@ -1,8 +1,10 @@
using Newtonsoft.Json;
using IRaCIS.Core.Infrastructure.NewtonsoftJson;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace IRaCIS.Core.API
{
@ -30,8 +32,20 @@ namespace IRaCIS.Core.API
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
// 检查类是否有 LowerCamelCaseJsonAttribute 标记 有的话,属性名小写
if (type.GetCustomAttribute<LowerCamelCaseJsonAttribute>() != null)
{
base.NamingStrategy= new LowerCamelCaseNamingStrategy();
}
else
{
base.NamingStrategy = null;
}
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
var list= type.GetProperties()
.Select(p =>
{

View File

@ -16,33 +16,33 @@
"ObjectStoreUse": "AliyunOSS",
"AliyunOSS": {
"regionId": "cn-shanghai",
"internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
"endPoint": "https://oss-cn-shanghai.aliyuncs.com",
"accessKeyId": "LTAI5tJV76pYX5yPg1N9QVE8",
"accessKeySecret": "roRNLa9YG1of4pYruJGCNKBXEWTAWa",
"bucketName": "zy-irc-test-store",
"roleArn": "acs:ram::1899121822495495:role/webdirect",
"viewEndpoint": "https://zy-irc-test-store.oss-cn-shanghai.aliyuncs.com",
"region": "oss-cn-shanghai",
"durationSeconds": 7200
"RegionId": "cn-shanghai",
"InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
"EndPoint": "https://oss-cn-shanghai.aliyuncs.com",
"AccessKeyId": "LTAI5tJV76pYX5yPg1N9QVE8",
"AccessKeySecret": "roRNLa9YG1of4pYruJGCNKBXEWTAWa",
"BucketName": "zy-irc-test-store",
"RoleArn": "acs:ram::1899121822495495:role/webdirect",
"ViewEndpoint": "https://zy-irc-test-store.oss-cn-shanghai.aliyuncs.com",
"Region": "oss-cn-shanghai",
"DurationSeconds": 7200
},
"MinIO": {
"endPoint": "hir-oss.test.extimaging.com",
"port": "443",
"useSSL": true,
"accessKey": "fbStsVYCIPKHQneeqMwD",
"secretKey": "TzgvyA3zGXMUnpilJNUlyMYHfosl1hBMl6lxPmjy",
"bucketName": "irc-test",
"viewEndpoint": "https://hir-oss.test.extimaging.com/irc-test"
"EndPoint": "hir-oss.test.extimaging.com",
"Port": "443",
"UseSSL": true,
"AccessKey": "fbStsVYCIPKHQneeqMwD",
"SecretKey": "TzgvyA3zGXMUnpilJNUlyMYHfosl1hBMl6lxPmjy",
"BucketName": "irc-test",
"ViewEndpoint": "https://hir-oss.test.extimaging.com/irc-test"
},
"AWS": {
"endPoint": "s3.us-east-1.amazonaws.com",
"useSSL": true,
"accessKey": "AKIAZQ3DRSOHFPJJ6FEU",
"secretKey": "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",
"bucketName": "ei-irc-test-store",
"viewEndpoint": "https://ei-irc-test-store.s3.amazonaws.com/"
"EndPoint": "s3.us-east-1.amazonaws.com",
"UseSSL": true,
"AccessKey": "AKIAZQ3DRSOHFPJJ6FEU",
"SecretKey": "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",
"BucketName": "ei-irc-test-store",
"ViewEndpoint": "https://ei-irc-test-store.s3.amazonaws.com/"
}
},

View File

@ -19,43 +19,46 @@ using Minio.ApiEndpoints;
using System.Reactive.Linq;
using IRaCIS.Core.Domain.Share;
using static MassTransit.ValidationResultExtensions;
using IRaCIS.Core.Infrastructure.NewtonsoftJson;
namespace IRaCIS.Core.Application.Helper
{
[LowerCamelCaseJson]
public class MinIOOptions : AWSOptions
{
public int port { get; set; }
public int Port { get; set; }
}
[LowerCamelCaseJson]
public class AWSOptions
{
public string endPoint { get; set; }
public bool useSSL { get; set; }
public string accessKey { get; set; }
public string secretKey { get; set; }
public string bucketName { get; set; }
public string viewEndpoint { get; set; }
public string EndPoint { get; set; }
public bool UseSSL { get; set; }
public string AccessKey { get; set; }
public string SecretKey { get; set; }
public string BucketName { get; set; }
public string ViewEndpoint { get; set; }
}
public class AliyunOSSOptions
{
public string regionId { get; set; }
public string accessKeyId { get; set; }
public string accessKeySecret { get; set; }
public string RegionId { get; set; }
public string AccessKeyId { get; set; }
public string AccessKeySecret { get; set; }
public string internalEndpoint { get; set; }
public string InternalEndpoint { get; set; }
public string endPoint { get; set; }
public string bucketName { get; set; }
public string EndPoint { get; set; }
public string BucketName { get; set; }
public string roleArn { get; set; }
public string RoleArn { get; set; }
public string region { get; set; }
public string Region { get; set; }
public string viewEndpoint { get; set; }
public string ViewEndpoint { get; set; }
public int durationSeconds { get; set; }
public int DurationSeconds { get; set; }
@ -87,17 +90,27 @@ namespace IRaCIS.Core.Application.Helper
}
[LowerCamelCaseJson]
public class AliyunOSSTempToken
{
public string accessKeyId { get; set; }
public string accessKeySecret { get; set; }
public string securityToken { get; set; }
public string expiration { get; set; }
public string AccessKeyId { get; set; }
public string AccessKeySecret { get; set; }
public string EndPoint { get; set; }
public string BucketName { get; set; }
public string Region { get; set; }
public string ViewEndpoint { get; set; }
public string SecurityToken { get; set; }
public string Expiration { get; set; }
public string region { get; set; }
public string bucketName { get; set; }
public string endPoint { get; set; }
public string viewEndpoint { get; set; }
}
@ -163,12 +176,12 @@ namespace IRaCIS.Core.Application.Helper
{
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret);
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, aliConfig.AccessKeyId, aliConfig.AccessKeySecret);
// 上传文件
var result = _ossClient.PutObject(aliConfig.bucketName, ossRelativePath, memoryStream);
var result = _ossClient.PutObject(aliConfig.BucketName, ossRelativePath, memoryStream);
}
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
@ -176,12 +189,12 @@ namespace IRaCIS.Core.Application.Helper
var minIOConfig = ObjectStoreServiceOptions.MinIO;
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}")
.WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
.Build();
var putObjectArgs = new PutObjectArgs()
.WithBucket(minIOConfig.bucketName)
.WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithStreamData(memoryStream)
.WithObjectSize(memoryStream.Length);
@ -193,12 +206,12 @@ namespace IRaCIS.Core.Application.Helper
var minIOConfig = ObjectStoreServiceOptions.AWS;
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}")
.WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
.Build();
var putObjectArgs = new PutObjectArgs()
.WithBucket(minIOConfig.bucketName)
.WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithStreamData(memoryStream)
.WithObjectSize(memoryStream.Length);
@ -247,10 +260,10 @@ namespace IRaCIS.Core.Application.Helper
{
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret);
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, aliConfig.AccessKeyId, aliConfig.AccessKeySecret);
// 上传文件
var result = _ossClient.PutObject(aliConfig.bucketName, ossRelativePath, localFilePath);
var result = _ossClient.PutObject(aliConfig.BucketName, ossRelativePath, localFilePath);
}
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
@ -258,12 +271,12 @@ namespace IRaCIS.Core.Application.Helper
var minIOConfig = ObjectStoreServiceOptions.MinIO;
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}")
.WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
.Build();
var putObjectArgs = new PutObjectArgs()
.WithBucket(minIOConfig.bucketName)
.WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithFileName(localFilePath);
@ -274,12 +287,12 @@ namespace IRaCIS.Core.Application.Helper
var minIOConfig = ObjectStoreServiceOptions.AWS;
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}")
.WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
.Build();
var putObjectArgs = new PutObjectArgs()
.WithBucket(minIOConfig.bucketName)
.WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithFileName(localFilePath);
@ -306,10 +319,10 @@ namespace IRaCIS.Core.Application.Helper
{
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret);
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, aliConfig.AccessKeyId, aliConfig.AccessKeySecret);
// 上传文件
var result = _ossClient.GetObject(aliConfig.bucketName, ossRelativePath);
var result = _ossClient.GetObject(aliConfig.BucketName, ossRelativePath);
// 将下载的文件流保存到本地文件
using (var fs = File.OpenWrite(localFilePath))
@ -323,12 +336,12 @@ namespace IRaCIS.Core.Application.Helper
{
var minIOConfig = ObjectStoreServiceOptions.MinIO;
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}")
.WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
.Build();
var getObjectArgs = new GetObjectArgs()
.WithBucket(minIOConfig.bucketName)
.WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithFile(localFilePath);
@ -339,12 +352,12 @@ namespace IRaCIS.Core.Application.Helper
{
var minIOConfig = ObjectStoreServiceOptions.AWS;
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}")
.WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
.Build();
var getObjectArgs = new GetObjectArgs()
.WithBucket(minIOConfig.bucketName)
.WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithFile(localFilePath);
@ -378,10 +391,10 @@ namespace IRaCIS.Core.Application.Helper
{
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret);
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, aliConfig.AccessKeyId, aliConfig.AccessKeySecret);
// 生成签名URL。
var req = new GeneratePresignedUriRequest(aliConfig.bucketName, ossRelativePath, SignHttpMethod.Get)
var req = new GeneratePresignedUriRequest(aliConfig.BucketName, ossRelativePath, SignHttpMethod.Get)
{
// 设置签名URL过期时间默认值为3600秒。
Expiration = DateTime.Now.AddHours(1),
@ -395,13 +408,13 @@ namespace IRaCIS.Core.Application.Helper
{
var minIOConfig = ObjectStoreServiceOptions.MinIO;
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}")
.WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
.Build();
var args = new PresignedGetObjectArgs()
.WithBucket(minIOConfig.bucketName)
.WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithExpiry(3600)
/*.WithHeaders(reqParams)*/;
@ -420,12 +433,12 @@ namespace IRaCIS.Core.Application.Helper
{
var minIOConfig = ObjectStoreServiceOptions.AWS;
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}")
.WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
.Build();
var args = new PresignedGetObjectArgs()
.WithBucket(minIOConfig.bucketName)
.WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithExpiry(3600);
@ -462,7 +475,7 @@ namespace IRaCIS.Core.Application.Helper
{
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret);
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, aliConfig.AccessKeyId, aliConfig.AccessKeySecret);
try
@ -472,7 +485,7 @@ namespace IRaCIS.Core.Application.Helper
do
{
// 使用 prefix 模拟目录结构,设置 MaxKeys 和 NextMarker
objectListing = _ossClient.ListObjects(new ListObjectsRequest(aliConfig.bucketName)
objectListing = _ossClient.ListObjects(new ListObjectsRequest(aliConfig.BucketName)
{
Prefix = prefix,
MaxKeys = 1000,
@ -484,7 +497,7 @@ namespace IRaCIS.Core.Application.Helper
// 删除获取到的文件
if (keys.Count > 0)
{
_ossClient.DeleteObjects(new DeleteObjectsRequest(aliConfig.bucketName, keys, false));
_ossClient.DeleteObjects(new DeleteObjectsRequest(aliConfig.BucketName, keys, false));
}
// 设置 NextMarker 以获取下一页的数据
@ -504,12 +517,12 @@ namespace IRaCIS.Core.Application.Helper
var minIOConfig = ObjectStoreServiceOptions.MinIO;
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}")
.WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
.Build();
var listArgs = new ListObjectsArgs().WithBucket(minIOConfig.bucketName).WithPrefix(prefix).WithRecursive(true);
var listArgs = new ListObjectsArgs().WithBucket(minIOConfig.BucketName).WithPrefix(prefix).WithRecursive(true);
@ -518,7 +531,7 @@ namespace IRaCIS.Core.Application.Helper
if (objects.Count > 0)
{
var objArgs = new RemoveObjectsArgs()
.WithBucket(minIOConfig.bucketName)
.WithBucket(minIOConfig.BucketName)
.WithObjects(objects);
// 删除对象

View File

@ -9,6 +9,7 @@ using IRaCIS.Core.Application.Service;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure;
using IRaCIS.Core.Infrastructure.NewtonsoftJson;
using MassTransit;
using Medallion.Threading;
using Microsoft.AspNetCore.Authorization;
@ -104,6 +105,25 @@ namespace IRaCIS.Application.Services
return ResponseOutput.Ok();
}
[LowerCamelCaseJson]
public class TestModel
{
public Guid TestId { get; set; }
public string TestName { get; set; }
}
public class TestModel2
{
public Guid TestId { get; set; }
}
public IResponseOutput TestJson()
{
return ResponseOutput.Ok(new TestModel(), new TestModel2());
}
public string TestHoliday(DateTime startdate,DateTime endDate)
{
@ -522,7 +542,7 @@ namespace IRaCIS.Application.Services
{
var aliConfig = oSSService.ObjectStoreServiceOptions.AliyunOSS;
var _ossClient = new OssClient(aliConfig.endPoint, aliConfig.accessKeyId, aliConfig.accessKeySecret);
var _ossClient = new OssClient(aliConfig.EndPoint, aliConfig.AccessKeyId, aliConfig.AccessKeySecret);
var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment);
@ -539,7 +559,7 @@ namespace IRaCIS.Application.Services
do
{
// 使用 prefix 模拟目录结构,设置 MaxKeys 和 NextMarker
var objectListing = _ossClient.ListObjects(new ListObjectsRequest(aliConfig.bucketName)
var objectListing = _ossClient.ListObjects(new ListObjectsRequest(aliConfig.BucketName)
{
Prefix = relativePath,
MaxKeys = 1000,

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.Infrastructure.NewtonsoftJson
{
[AttributeUsage(AttributeTargets.Class)]
public class LowerCamelCaseJsonAttribute : Attribute
{
}
}

View File

@ -0,0 +1,18 @@
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.Infrastructure.NewtonsoftJson
{
public class LowerCamelCaseNamingStrategy : NamingStrategy
{
protected override string ResolvePropertyName(string name)
{
// 将属性名的首字母转换为小写
return char.ToLower(name[0]) + name.Substring(1);
}
}
}