@@ -22,6 +22,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Aliyun.OSS" Version="1.0.7" /> | |||||
<PackageReference Include="Tencent.QCloud.Cos.Sdk" Version="5.4.35" /> | <PackageReference Include="Tencent.QCloud.Cos.Sdk" Version="5.4.35" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -0,0 +1,27 @@ | |||||
using BPA.Aliyun.OSS.Options; | |||||
using BPA.SAAS.Manage.Application.System.Dtos; | |||||
using BPA.SAAS.Manage.Application.System.Interface; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.System | |||||
{ | |||||
[ApiDescriptionSettings("SYS", Tag = "获取阿里云参数")] | |||||
public class AliyunOssServices : ITransient, IDynamicApiController | |||||
{ | |||||
IAliyunOssService _aliyunOssService; | |||||
public AliyunOssServices(IAliyunOssService aliyunOssService) | |||||
{ | |||||
_aliyunOssService = aliyunOssService; | |||||
} | |||||
[HttpPost("/api/systemconfig/GeneratePostPolicy"), ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify] | |||||
public async Task<AliyunOssPostPolicyResponse> GeneratePostPolicyAsync(Aliyun0ssGeneratePostPolicyRequest request) | |||||
{ | |||||
return await _aliyunOssService.GeneratePostPolicyAsync(request); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,24 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.ComponentModel; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.System.Dtos | |||||
{ | |||||
public class Aliyun0ssGeneratePostPolicyRequest | |||||
{ | |||||
/// <summary> | |||||
/// 根目录 | |||||
/// </summary> | |||||
[DisplayName("根目录")] | |||||
[Required(ErrorMessage = "[{0}]不能为空")] | |||||
public string Directory { get; set; } | |||||
/// <summary> | |||||
/// 是否构建唯一目录 | |||||
/// </summary> | |||||
public bool BuildUniqueDirectory { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,15 @@ | |||||
using BPA.Aliyun.OSS.Options; | |||||
using BPA.SAAS.Manage.Application.System.Dtos; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.System.Interface | |||||
{ | |||||
public interface IAliyunOssService | |||||
{ | |||||
Task<AliyunOssPostPolicyResponse> GeneratePostPolicyAsync(Aliyun0ssGeneratePostPolicyRequest request); | |||||
} | |||||
} |
@@ -0,0 +1,31 @@ | |||||
using BPA.Aliyun.OSS; | |||||
using BPA.Aliyun.OSS.Options; | |||||
using BPA.SAAS.Manage.Application.System.Dtos; | |||||
using BPA.SAAS.Manage.Application.System.Interface; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.System.Services | |||||
{ | |||||
public class AliyunOssService : IAliyunOssService, ITransient | |||||
{ | |||||
private readonly ISqlSugarClient _db; | |||||
private AliyunOssClient _aliyunOssClient; | |||||
public AliyunOssService(ISqlSugarClient db, AliyunOssClient aliyunOssClient) | |||||
{ | |||||
_db = db; | |||||
_aliyunOssClient = aliyunOssClient; | |||||
} | |||||
public async Task<AliyunOssPostPolicyResponse> GeneratePostPolicyAsync(Aliyun0ssGeneratePostPolicyRequest request) | |||||
{ | |||||
var dir = request.Directory; | |||||
dir = !dir.EndsWith("/") ? dir + "/" : dir; | |||||
var data = await _aliyunOssClient.GeneratePostPolicyAsync(dir); | |||||
return data; | |||||
} | |||||
} | |||||
} |
@@ -7,6 +7,7 @@ | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Aliyun.OSS" Version="1.0.7" /> | |||||
<PackageReference Include="Furion.Pure" Version="4.9.1.20" /> | <PackageReference Include="Furion.Pure" Version="4.9.1.20" /> | ||||
<PackageReference Include="Npoi.Mapper" Version="6.2.1" /> | <PackageReference Include="Npoi.Mapper" Version="6.2.1" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -14,6 +14,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Aliyun.OSS" Version="1.0.7" /> | |||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.8.5" /> | <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.8.5" /> | ||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.8.5" /> | <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.8.5" /> | ||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.67" /> | <PackageReference Include="SqlSugarCore" Version="5.1.4.67" /> | ||||
@@ -16,6 +16,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Aliyun.OSS" Version="1.0.7" /> | |||||
<PackageReference Include="BPA.MQTTClient" Version="1.0.11" /> | <PackageReference Include="BPA.MQTTClient" Version="1.0.11" /> | ||||
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" /> | <PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -1,10 +1,12 @@ | |||||
using BPA.MQTTClient; | |||||
using BPA.Aliyun.OSS; | |||||
using BPA.MQTTClient; | |||||
using BPA.SAAS.Manage.Application.System.Dtos; | using BPA.SAAS.Manage.Application.System.Dtos; | ||||
using BPA.SAAS.Manage.Core; | using BPA.SAAS.Manage.Core; | ||||
using FluentValidation.AspNetCore; | using FluentValidation.AspNetCore; | ||||
using Furion; | using Furion; | ||||
using Microsoft.AspNetCore.Builder; | using Microsoft.AspNetCore.Builder; | ||||
using Microsoft.AspNetCore.Hosting; | using Microsoft.AspNetCore.Hosting; | ||||
using Microsoft.Extensions.Configuration; | |||||
using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||
using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||
using MQTTnet.Client.Connecting; | using MQTTnet.Client.Connecting; | ||||
@@ -70,6 +72,11 @@ namespace BPA.SAAS.Manage.Web.Core | |||||
services.AddControllers() | services.AddControllers() | ||||
.AddInjectWithUnifyResult(); | .AddInjectWithUnifyResult(); | ||||
services.AddMvcFilter<RequestAuditFiltercs>(); | services.AddMvcFilter<RequestAuditFiltercs>(); | ||||
services.AddAliyunOss(op => | |||||
{ | |||||
App.Configuration.Bind("BPA:Aliyun:Oss", op); | |||||
}); | |||||
} | } | ||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | ||||
@@ -78,7 +85,7 @@ namespace BPA.SAAS.Manage.Web.Core | |||||
{ | { | ||||
app.UseDeveloperExceptionPage(); | app.UseDeveloperExceptionPage(); | ||||
} | } | ||||
app.UseHttpsRedirection(); | app.UseHttpsRedirection(); | ||||
app.UseRouting(); | app.UseRouting(); | ||||
@@ -12,6 +12,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Aliyun.OSS" Version="1.0.7" /> | |||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" /> | <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -31,6 +31,20 @@ | |||||
"UserName": "emqx_u_block", | "UserName": "emqx_u_block", | ||||
"Password": "emqx_p_admin8765490789" | "Password": "emqx_p_admin8765490789" | ||||
}, | }, | ||||
"BPA": { | |||||
"Aliyun": { | |||||
"Oss": { | |||||
"AccessKeyId": "LTAI5tGkcsA6HmUL2EyNfYmq", | |||||
"AccessKeySecret": "gPCBqVHqnq17f2YikwdtsjExl1NRVF", | |||||
"Endpoint": "https://oss-cn-chengdu.aliyuncs.com", | |||||
"BucketName": "bpa", //"erphk", | |||||
"PresignedUriExpirationMinutes": 1440, | |||||
"PolicyExpirationMinutes": 1440, | |||||
"ProjectName": "hkerp", | |||||
"ServiceName": "test" | |||||
} | |||||
} | |||||
}, | |||||
"order_url": "http://order", | "order_url": "http://order", | ||||
"wechat_url": "http://wechat" | "wechat_url": "http://wechat" | ||||
} | } |