Browse Source

feat(tencent): 强化腾讯云服务的特性限制.

pull/512/head
cKey 4 years ago
parent
commit
46e2305cb5
  1. 16
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.BlobStoring.Tencent/LINGYUN/Abp/BlobStoring/Tencent/TencentCloudBlobProvider.cs
  2. 3
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN/Abp/Sms/Tencent/TencentCloudSmsSender.cs
  3. 3
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Localization/en.json
  4. 3
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Localization/zh-Hans.json
  5. 34
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN/Abp/Tencent/SettingManagement/TenantCloudSettingController.cs
  6. 5
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN.Abp.Tencent.csproj
  7. 0
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/AbpTencentCloudModule.cs
  8. 0
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/AbpTencentCloudOptions.cs
  9. 0
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/AbstractTencentCloudClientFactory.cs
  10. 50
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Features/TencentCloudFeatureDefinitionProvider.cs
  11. 30
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Features/TencentCloudFeatures.cs
  12. 11
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Localization/Resources/en.json
  13. 11
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Localization/Resources/zh-Hans.json
  14. 0
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Localization/TencentCloudResource.cs
  15. 3
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Settings/TencentCloudSettingDefinitionProvider.cs
  16. 0
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Settings/TencentCloudSettingNames.cs
  17. 0
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/TencentCloudClientCacheItem.cs
  18. 0
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/TencentCloudClientFactory.cs

16
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.BlobStoring.Tencent/LINGYUN/Abp/BlobStoring/Tencent/TencentCloudBlobProvider.cs

@ -2,24 +2,31 @@
using COSXML.Common;
using COSXML.Model.Bucket;
using COSXML.Model.Object;
using LINGYUN.Abp.Tencent.Features;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.BlobStoring;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Features;
namespace LINGYUN.Abp.BlobStoring.Tencent;
[RequiresFeature(TencentCloudFeatures.BlobStoring.Enable)]
public class TencentCloudBlobProvider : BlobProviderBase, ITransientDependency
{
protected IFeatureChecker FeatureChecker { get; }
protected ICosClientFactory CosClientFactory { get; }
protected ITencentBlobNameCalculator TencentBlobNameCalculator { get; }
public TencentCloudBlobProvider(
IFeatureChecker featureChecker,
ICosClientFactory cosClientFactory,
ITencentBlobNameCalculator tencentBlobNameCalculator)
{
FeatureChecker = featureChecker;
CosClientFactory = cosClientFactory;
TencentBlobNameCalculator = tencentBlobNameCalculator;
}
@ -68,6 +75,15 @@ public class TencentCloudBlobProvider : BlobProviderBase, ITransientDependency
public override async Task SaveAsync(BlobProviderSaveArgs args)
{
var maxStreamSizeString = await FeatureChecker.GetOrNullAsync(TencentCloudFeatures.BlobStoring.MaximumStreamSize);
if (!"0".Equals(maxStreamSizeString) ||
(int.TryParse(maxStreamSizeString, out var maxStreamSize)
&& (maxStreamSize <= 0
|| maxStreamSize < args.BlobStream.Length / 1024 / 1024)))
{
throw new BusinessException("TencentCloud:10101");
}
var ossClient = await GetOssClientAsync(args);
var blobName = TencentBlobNameCalculator.Calculate(args);
var configuration = args.Configuration.GetTencentConfiguration();

3
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN/Abp/Sms/Tencent/TencentCloudSmsSender.cs

@ -1,4 +1,5 @@
using LINGYUN.Abp.Tencent;
using LINGYUN.Abp.Tencent.Features;
using LINGYUN.Abp.Tencent.Settings;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
@ -10,6 +11,7 @@ using TencentCloud.Sms.V20210111;
using TencentCloud.Sms.V20210111.Models;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Features;
using Volo.Abp.Json;
using Volo.Abp.Settings;
using Volo.Abp.Sms;
@ -39,6 +41,7 @@ namespace LINGYUN.Abp.Sms.Tencent
Logger = NullLogger<TencentCloudSmsSender>.Instance;
}
[RequiresFeature(TencentCloudFeatures.Sms.Enable)]
public virtual async Task SendAsync(SmsMessage smsMessage)
{
var appId = await SettingProvider.GetOrNullAsync(TencentCloudSettingNames.Sms.AppId);

3
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Localization/en.json

@ -1,6 +1,9 @@
{
"culture": "en",
"texts": {
"Features:TencentQQ": "QQ Connect",
"Features:TencentQQEnable": "Enable QQ Connect",
"Features:TencentQQEnable.Desc": "Enable to support QQ interconnection fast login.",
"DisplayName:TenantCloud.QQConnect": "QQ Connect",
"Description:TenantCloud.QQConnect": "Access QQ Internet open platform",
"DisplayName:QQConnect.AppId": "AppId",

3
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Localization/zh-Hans.json

@ -1,6 +1,9 @@
{
"culture": "zh-Hans",
"texts": {
"Features:TencentQQ": "QQ互联",
"Features:TencentQQEnable": "启用QQ互联",
"Features:TencentQQEnable.Desc": "启用以支持QQ互联快速登录.",
"DisplayName:TenantCloud.QQConnect": "QQ互联",
"Description:TenantCloud.QQConnect": "接入QQ互联开放平台",
"DisplayName:QQConnect.AppId": "应用的唯一标识",

34
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN/Abp/Tencent/SettingManagement/TenantCloudSettingController.cs

@ -0,0 +1,34 @@
using LINGYUN.Abp.SettingManagement;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
namespace LINGYUN.Abp.Tencent.SettingManagement;
[RemoteService(Name = AbpSettingManagementRemoteServiceConsts.RemoteServiceName)]
[Area("settingManagement")]
[Route("api/setting-management/tencent-cloud")]
public class TenantCloudSettingController : AbpControllerBase, ITenantCloudSettingAppService
{
protected ITenantCloudSettingAppService Service { get; }
public TenantCloudSettingController(ITenantCloudSettingAppService service)
{
Service = service;
}
[HttpGet]
[Route("by-current-tenant")]
public Task<SettingGroupResult> GetAllForCurrentTenantAsync()
{
return Service.GetAllForCurrentTenantAsync();
}
[HttpGet]
[Route("by-global")]
public Task<SettingGroupResult> GetAllForGlobalAsync()
{
return Service.GetAllForGlobalAsync();
}
}

5
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN.Abp.Tencent.csproj

@ -10,14 +10,15 @@
</PropertyGroup>
<ItemGroup>
<None Remove="LINYUN\Abp\Tencent\Localization\Resources\*.json" />
<None Remove="LINGYUN\Abp\Tencent\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="LINYUN\Abp\Tencent\Localization\Resources\*.json" />
<EmbeddedResource Include="LINGYUN\Abp\Tencent\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Features" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Caching" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Localization" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Json" Version="$(VoloAbpPackageVersion)" />

0
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/AbpTencentCloudModule.cs → aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/AbpTencentCloudModule.cs

0
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/AbpTencentCloudOptions.cs → aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/AbpTencentCloudOptions.cs

0
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/AbstractTencentCloudClientFactory.cs → aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/AbstractTencentCloudClientFactory.cs

50
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Features/TencentCloudFeatureDefinitionProvider.cs

@ -0,0 +1,50 @@
using LINGYUN.Abp.Tencent.Localization;
using Volo.Abp.Features;
using Volo.Abp.Localization;
using Volo.Abp.Validation.StringValues;
namespace LINGYUN.Abp.Tencent.Features
{
public class TencentCloudFeatureDefinitionProvider : FeatureDefinitionProvider
{
public override void Define(IFeatureDefinitionContext context)
{
var group = context.AddGroup(TencentCloudFeatures.GroupName, L("Features:TencentCloud"));
var sms = group.AddFeature(
name: TencentCloudFeatures.Sms.GroupName,
displayName: L("Features:TencentSms"),
description: L("Features:TencentSms"));
sms.CreateChild(
name: TencentCloudFeatures.Sms.Enable,
defaultValue: true.ToString(),
displayName: L("Features:TencentSmsEnable"),
description: L("Features:TencentSmsEnable.Desc"),
valueType: new ToggleStringValueType(new BooleanValueValidator()));
var blobStoring = group.AddFeature(
name: TencentCloudFeatures.BlobStoring.GroupName,
displayName: L("Features:TencentBlobStoring"),
description: L("Features:TencentBlobStoring"));
blobStoring.CreateChild(
name: TencentCloudFeatures.BlobStoring.Enable,
defaultValue: true.ToString(),
displayName: L("Features:TencentBlobStoringEnable"),
description: L("Features:TencentBlobStoringEnable.Desc"),
valueType: new ToggleStringValueType(new BooleanValueValidator()));
blobStoring.CreateChild(
name: TencentCloudFeatures.BlobStoring.MaximumStreamSize,
defaultValue: "0",
displayName: L("Features:TencentBlobStoringMaximumStreamSize"),
description: L("Features:TencentBlobStoringMaximumStreamSize.Desc"),
valueType: new FreeTextStringValueType(new NumericValueValidator(0)));
}
protected LocalizableString L(string name)
{
return LocalizableString.Create<TencentCloudResource>(name);
}
}
}

30
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Features/TencentCloudFeatures.cs

@ -0,0 +1,30 @@
namespace LINGYUN.Abp.Tencent.Features
{
public static class TencentCloudFeatures
{
public const string GroupName = "Abp.TencentCloud";
public static class Sms
{
public const string GroupName = TencentCloudFeatures.GroupName + ".Sms";
/// <summary>
/// 启用短信
/// </summary>
public const string Enable = GroupName + ".Enable";
}
public static class BlobStoring
{
public const string GroupName = TencentCloudFeatures.GroupName + ".BlobStoring";
/// <summary>
/// 启用对象存储
/// </summary>
public const string Enable = GroupName + ".Enable";
/// <summary>
/// 最大流大小限制, 小于等于0无效, 单位(MB)
/// 默认: 0
/// </summary>
public const string MaximumStreamSize = GroupName + ".MaximumStreamSize";
}
}
}

11
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Localization/Resources/en.json → aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Localization/Resources/en.json

@ -1,6 +1,17 @@
{
"culture": "en",
"texts": {
"Permission:TencentCloud": "Tencent Cloud",
"Permission:TencentCloud.Settings": "Settings",
"Features:TencentCloud": "Tencent Cloud",
"Features:TencentSms": "Sms",
"Features:TencentSmsEnable": "Enable",
"Features:TencentSmsEnable.Desc": "Enabled to support Tencent cloud SMS capabilities.",
"Features:TencentBlobStoring": "Blob Storing",
"Features:TencentBlobStoringEnable": "Enable",
"Features:TencentBlobStoringEnable.Desc": "Enable to support Tencent cloud object storage capability.",
"Features:TencentBlobStoringMaximumStreamSize": "Maximum Stream Size",
"Features:TencentBlobStoringMaximumStreamSize.Desc": "Size(MB) limit for a single uploaded file stream,0 or less.",
"DisplayName:TenantCloud": "Tenant Cloud",
"DisplayName:TenantCloud.BasicSetting": "Basic Setting",
"Description:TenantCloud.BasicSetting": "Tencent cloud basic information configuration",

11
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Localization/Resources/zh-Hans.json → aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Localization/Resources/zh-Hans.json

@ -1,6 +1,17 @@
{
"culture": "zh-Hans",
"texts": {
"Permission:TencentCloud": "腾讯云服务",
"Permission:TencentCloud.Settings": "配置腾讯云",
"Features:TencentCloud": "腾讯云服务",
"Features:TencentSms": "腾讯云短信",
"Features:TencentSmsEnable": "启用云短信",
"Features:TencentSmsEnable.Desc": "启用以支持腾讯云短信能力.",
"Features:TencentBlobStoring": "腾讯云存储",
"Features:TencentBlobStoringEnable": "启用云存储",
"Features:TencentBlobStoringEnable.Desc": "启用以支持腾讯云对象存储能力.",
"Features:TencentBlobStoringMaximumStreamSize": "最大存储流大小",
"Features:TencentBlobStoringMaximumStreamSize.Desc": "单次上传文件流大小限制,0或低于0不限制,单位(MB).",
"DisplayName:TenantCloud": "腾讯云服务",
"DisplayName:TenantCloud.BasicSetting": "基础配置",
"Description:TenantCloud.BasicSetting": "腾讯云基础信息配置",

0
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Localization/TencentCloudResource.cs → aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Localization/TencentCloudResource.cs

3
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Settings/TencentCloudSettingDefinitionProvider.cs → aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Settings/TencentCloudSettingDefinitionProvider.cs

@ -1,9 +1,8 @@
using LINGYUN.Abp.Tencent.Localization;
using LINGYUN.Abp.Tencent.Settings;
using Volo.Abp.Localization;
using Volo.Abp.Settings;
namespace LINYUN.Abp.Tencent.Settings;
namespace LINGYUN.Abp.Tencent.Settings;
public class TencentCloudSettingDefinitionProvider : SettingDefinitionProvider
{

0
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Settings/TencentCloudSettingNames.cs → aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/Settings/TencentCloudSettingNames.cs

0
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/TencentCloudClientCacheItem.cs → aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/TencentCloudClientCacheItem.cs

0
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/TencentCloudClientFactory.cs → aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/TencentCloudClientFactory.cs

Loading…
Cancel
Save