HuanMengAdmin/admin-server/MiaoYu.Core.Cos/CoreCosStartup.cs
2024-07-22 16:03:12 +08:00

60 lines
1.9 KiB
C#

using HZY.Framework.Core.AspNetCore;
using MiaoYu.Core.Cos.Configs;
using MiaoYu.Core.Cos.Services;
using MiaoYu.Core.Cos.Services.Impl;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MiaoYu.Core.Cos
{
/// <summary>
/// cos
/// </summary>
public class CoreCosStartup : StartupModule<CoreCosStartup>
{
/// <summary>
/// 服务配置
/// </summary>
/// <param name="webApplicationBuilder"></param>
public override void ConfigureServices(WebApplicationBuilder webApplicationBuilder)
{
var tencentConfig = webApplicationBuilder.Configuration.GetSection("TencentCloud").Get<TencentConfig>();
if (tencentConfig == null)
{
tencentConfig = new TencentConfig();
}
if (tencentConfig.CosConfig == null)
{
tencentConfig.CosConfig = new TencentCosConfig() { };
}
if (string.IsNullOrEmpty(tencentConfig.CosConfig.SecretId))
{
tencentConfig.CosConfig.SecretId = tencentConfig.SecretId;
}
if (string.IsNullOrEmpty(tencentConfig.CosConfig.SecretKey))
{
tencentConfig.CosConfig.SecretKey = tencentConfig.SecretKey;
}
//注册一个验证码的服务
webApplicationBuilder.Services.AddSingleton<TencentConfig>(tencentConfig);
//webApplicationBuilder.Services.AddScoped<ICodeCosService, TencentCodeCosService>();
}
/// <summary>
/// 使用服务
/// </summary>
/// <param name="webApplication"></param>
public override void Configure(WebApplication webApplication)
{
}
}
}