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

Binary file not shown.

View File

@@ -103,6 +103,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.MultiTenancy",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.DictionaryManager", "src\module\Yi.Framework.DictionaryManager\Yi.Framework.DictionaryManager.csproj", "{8941B30D-698B-477A-8737-43E7B4A8695A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.Sms.Aliyun", "src\module\Yi.Framework.Sms.Aliyun\Yi.Framework.Sms.Aliyun.csproj", "{063178CF-C5B9-463C-A8A4-F32B743818E2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -269,6 +271,10 @@ Global
{8941B30D-698B-477A-8737-43E7B4A8695A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8941B30D-698B-477A-8737-43E7B4A8695A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8941B30D-698B-477A-8737-43E7B4A8695A}.Release|Any CPU.Build.0 = Release|Any CPU
{063178CF-C5B9-463C-A8A4-F32B743818E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{063178CF-C5B9-463C-A8A4-F32B743818E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{063178CF-C5B9-463C-A8A4-F32B743818E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{063178CF-C5B9-463C-A8A4-F32B743818E2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -317,6 +323,7 @@ Global
{1BF3115D-B027-4805-AF7B-41B3AE9CB355} = {EEF5F221-0E32-4A3D-B647-B4B5E7305806}
{590B1EC0-CDA9-4937-BE07-FBB04437D21F} = {5F2B846D-96CE-400A-878E-220498F4EE31}
{8941B30D-698B-477A-8737-43E7B4A8695A} = {EEF5F221-0E32-4A3D-B647-B4B5E7305806}
{063178CF-C5B9-463C-A8A4-F32B743818E2} = {EEF5F221-0E32-4A3D-B647-B4B5E7305806}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6C1A3808-0F4F-43FB-A9FE-5F27A3BB2ECF}

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)
{