feat:添加短信

This commit is contained in:
陈淳
2023-03-29 19:30:48 +08:00
parent 5458819ef5
commit 3d94626ff1
21 changed files with 133 additions and 14 deletions

View File

@@ -25,7 +25,7 @@ namespace Yi.Framework.Core.Sqlsugar
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
services.AddTransient(typeof(IRepository<>), typeof(SqlsugarRepository<>));
services.Replace(new ServiceDescriptor(typeof(IUnitOfWorkManager), typeof(SqlsugarUnitOfWorkManager), ServiceLifetime.Singleton));
//services.Replace(new ServiceDescriptor(typeof(IUnitOfWorkManager), typeof(SqlsugarUnitOfWorkManager), ServiceLifetime.Singleton));
services.Replace(new ServiceDescriptor(typeof(IDataFilter), typeof(SqlsugarDataFilter), ServiceLifetime.Scoped));
services.Configure<DbConnOptions>(Appsettings.appConfiguration("DbConnOptions"));

View File

@@ -12,11 +12,13 @@ using Yi.Framework.Data.Entities;
using Yi.Framework.Data.Extensions;
using Yi.Framework.Data.Filters;
using Yi.Framework.Ddd;
using Yi.Framework.Uow;
namespace Yi.Framework.Data
{
[DependsOn(
typeof(YiFrameworkDddModule)) ]
typeof(YiFrameworkDddModule),
typeof(YiFrameworkUowModule)) ]
public class YiFrameworkDataModule : IStartupModule
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)

View File

@@ -13,6 +13,7 @@ namespace Yi.Framework.Ddd
{
[DependsOn(
typeof(YiFrameworkCoreMapsterModule)
)]
public class YiFrameworkDddModule:IStartupModule
{

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AlibabaCloud.SDK.Dysmsapi20170525;
using Tea;
namespace Yi.Framework.Sms.Aliyun
{
public class SmsAliyunManager
{
private static Client CreateClient(string accessKeyId, string accessKeySecret)
{
AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
{
// 必填,您的 AccessKey ID
AccessKeyId = accessKeyId,
// 必填,您的 AccessKey Secret
AccessKeySecret = accessKeySecret,
};
// 访问的域名
config.Endpoint = "dysmsapi.aliyuncs.com";
return new Client(config);
}
public Client AliyunClient { get; set; }
public SmsAliyunManager() {
AliyunClient = CreateClient("accessKeyId", "accessKeySecret");
}
public async Task Send(string phoneNumbers, string code)
{
try
{
AlibabaCloud.SDK.Dysmsapi20170525.Models.SendSmsRequest sendSmsRequest = new AlibabaCloud.SDK.Dysmsapi20170525.Models.SendSmsRequest
{
PhoneNumbers = phoneNumbers,
SignName = "",
TemplateCode = code,
};
var response= await AliyunClient.SendSmsAsync(sendSmsRequest);
}
catch (TeaException error)
{
Console.WriteLine(error.Message);
}
catch (Exception _error)
{
Console.WriteLine(_error.Message);
}
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Sms.Aliyun
{
public class SmsAliyunOptions
{
}
}

View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="2.0.23" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\framework\Yi.Framework.Core\Yi.Framework.Core.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using StartupModules;
namespace Yi.Framework.Sms.Aliyun
{
public class YiFrameworkSmsAliyunModule : IStartupModule
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
}
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
}
}
}

View File

@@ -14,9 +14,9 @@
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
"DbConnOptions": {
"Url": "DataSource=yi-sqlsugar-dev.db",
//"Url": "server=106.52.94.217;port=3306;database=yi-bbs-dev;user id=root;password=Qz52013142020.",
"DbType": "Sqlite",
//"Url": "DataSource=yi-sqlsugar-dev.db",
"Url": "server=106.52.94.217;port=3306;database=yi-bbs-dev;user id=root;password=Qz52013142020.",
"DbType": "Mysql",
"EnabledDbSeed": true,
"EnabledReadWrite": false,
"EnabledCodeFirst": true,

View File

@@ -13,7 +13,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
public class DiscussCreateInputVo
{
public string Title { get; set; }
public string Types { get; set; }
public string? Types { get; set; }
public string? Introduction { get; set; }
public DateTime? CreateTime { get; set; } = DateTime.Now;
public string Content { get; set; }

View File

@@ -15,7 +15,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos
public long Id { get; set; }
public string Title { get; set; }
public string Types { get; set; }
public string? Types { get; set; }
public string? Introduction { get; set; }
public int AgreeNum { get; set; }
public int SeeNum { get; set; }

View File

@@ -10,7 +10,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
public class DiscussUpdateInputVo
{
public string Title { get; set; }
public string Types { get; set; }
public string? Types { get; set; }
public string? Introduction { get; set; }
public int AgreeNum { get; set; }
public int SeeNum { get; set; }

View File

@@ -18,6 +18,7 @@ namespace Yi.BBS.Domain.Forum.Entities
public long Id { get; set; }
public bool IsDeleted { get; set; }
[SugarColumn(Length = 9999)]
public string Content { get; set; }
public string Name { get; set; }

View File

@@ -26,7 +26,7 @@ namespace Yi.BBS.Domain.Forum.Entities
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
public string Title { get; set; }
public string Types { get; set; }
public string? Types { get; set; }
public string? Introduction { get; set; }
public int AgreeNum { get; set; }
public int SeeNum { get; set; }
@@ -34,6 +34,8 @@ namespace Yi.BBS.Domain.Forum.Entities
/// 封面
/// </summary>
public string? Cover { get; set; }
[SugarColumn(Length =9999)]
public string Content { get; set; }
public string? Color { get; set; }

View File

@@ -14,9 +14,9 @@
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
"DbConnOptions": {
"Url": "DataSource=yi-sqlsugar-dev.db",
//"Url": "server=106.52.94.217;port=3306;database=yi-bbs-dev;user id=root;password=Qz52013142020.",
"DbType": "Sqlite",
//"Url": "DataSource=yi-sqlsugar-dev.db",
"Url": "server=106.52.94.217;port=3306;database=yi-bbs-dev;user id=root;password=Qz52013142020.",
"DbType": "Mysql",
"EnabledDbSeed": true,
"EnabledReadWrite": false,
"EnabledCodeFirst": true,

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@@ -65,7 +65,8 @@ namespace Yi.RBAC.Application.Identity
[Autowired]
private IUnitOfWorkManager _unitOfWorkManager { get; set; }
[Autowired]
private IRepository<RoleEntity> _roleRepository { get; set; }
/// <summary>
/// 登录
/// </summary>
@@ -152,7 +153,7 @@ namespace Yi.RBAC.Application.Identity
var entity = await _userRepository.InsertReturnEntityAsync(newUser);
//赋上一个初始角色
var roleRepository = uow.GetRepository<RoleEntity>();
var roleRepository = _roleRepository;
var role = await roleRepository.GetFirstAsync(x => x.RoleName == UserConst.GuestRoleName);
if (role is not null)
{