短信发送
This commit is contained in:
@@ -7,8 +7,10 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Yi.Framework.Common;
|
using Yi.Framework.Common;
|
||||||
|
using Yi.Framework.Common.Const;
|
||||||
using Yi.Framework.Common.Helper;
|
using Yi.Framework.Common.Helper;
|
||||||
using Yi.Framework.Common.Models;
|
using Yi.Framework.Common.Models;
|
||||||
|
using Yi.Framework.Common.QueueModel;
|
||||||
using Yi.Framework.Core;
|
using Yi.Framework.Core;
|
||||||
using Yi.Framework.DTOModel;
|
using Yi.Framework.DTOModel;
|
||||||
using Yi.Framework.Interface;
|
using Yi.Framework.Interface;
|
||||||
@@ -25,11 +27,13 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
|
|
||||||
private IUserService _userService;
|
private IUserService _userService;
|
||||||
private IMenuService _menuService;
|
private IMenuService _menuService;
|
||||||
public AccountController(ILogger<UserController> logger, IUserService userService, IMenuService menuService)
|
private RabbitMQInvoker _rabbitMQInvoker;
|
||||||
|
public AccountController(ILogger<UserController> logger, IUserService userService, IMenuService menuService,RabbitMQInvoker rabbitMQInvoker)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
_menuService = menuService;
|
_menuService = menuService;
|
||||||
|
_rabbitMQInvoker = rabbitMQInvoker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -83,6 +87,14 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
return Result.Error();
|
return Result.Error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public Result SendSMS(SMSQueueModel test)
|
||||||
|
{
|
||||||
|
_rabbitMQInvoker.Send(new Common.IOCOptions.RabbitMQConsumerModel() { ExchangeName=RabbitConst.SMS_Exchange,QueueName=RabbitConst.SMS_Queue_Send} );
|
||||||
|
return Result.Success();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 传入邮箱,需要先到数据库判断该邮箱是否被人注册过,到userservice写mail_exist方法,还有接口别忘了。这个接口不需要洞,只需要完成userservice写mail_exist与接口即可
|
/// 传入邮箱,需要先到数据库判断该邮箱是否被人注册过,到userservice写mail_exist方法,还有接口别忘了。这个接口不需要洞,只需要完成userservice写mail_exist与接口即可
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
_quartzInvoker = quartzInvoker;
|
_quartzInvoker = quartzInvoker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<Result> startJob()
|
public async Task<Result> startJob()
|
||||||
{
|
{
|
||||||
@@ -44,18 +48,30 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
return Result.Success();
|
return Result.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<Result> getRunJobList()
|
public async Task<Result> getRunJobList()
|
||||||
{
|
{
|
||||||
return Result.Success().SetData(await _quartzInvoker.getRunJobList());
|
return Result.Success().SetData(await _quartzInvoker.getRunJobList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public Result getJobClass()
|
public Result getJobClass()
|
||||||
{
|
{
|
||||||
return Result.Success().SetData(_quartzInvoker.getJobClassList());
|
return Result.Success().SetData(_quartzInvoker.getJobClassList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
public async Task<Result> stopJob()
|
public async Task<Result> stopJob()
|
||||||
{
|
{
|
||||||
@@ -63,6 +79,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
return Result.Success();
|
return Result.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public async Task<Result> DeleteJob()
|
public async Task<Result> DeleteJob()
|
||||||
{
|
{
|
||||||
@@ -70,6 +90,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
return Result.Success();
|
return Result.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
public async Task<Result> ResumeJob()
|
public async Task<Result> ResumeJob()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// SetRoleByUser
|
||||||
/// 给多个用户设置多个角色,ids有用户id与 角色列表ids,多对多,ids1用户,ids2为角色
|
/// 给多个用户设置多个角色,ids有用户id与 角色列表ids,多对多,ids1用户,ids2为角色
|
||||||
/// 用户设置给用户设置角色
|
/// 用户设置给用户设置角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ namespace Yi.Framework.ApiMicroservice
|
|||||||
#endregion
|
#endregion
|
||||||
services.AddRabbitMQService();
|
services.AddRabbitMQService();
|
||||||
|
|
||||||
|
#region
|
||||||
|
//<2F><><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
#endregion
|
||||||
|
services.AddSMSService();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Autofac<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>
|
#region Autofac<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>
|
||||||
@@ -158,6 +161,7 @@ namespace Yi.Framework.ApiMicroservice
|
|||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers();
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,12 @@
|
|||||||
<param name="code"></param>
|
<param name="code"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.SendMail">
|
||||||
|
<summary>
|
||||||
|
发送邮件
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Email(System.String)">
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Email(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
传入邮箱,需要先到数据库判断该邮箱是否被人注册过,到userservice写mail_exist方法,还有接口别忘了。这个接口不需要洞,只需要完成userservice写mail_exist与接口即可
|
传入邮箱,需要先到数据库判断该邮箱是否被人注册过,到userservice写mail_exist方法,还有接口别忘了。这个接口不需要洞,只需要完成userservice写mail_exist与接口即可
|
||||||
@@ -47,6 +53,42 @@
|
|||||||
<param name="file"></param>
|
<param name="file"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.JobController.startJob">
|
||||||
|
<summary>
|
||||||
|
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.JobController.getRunJobList">
|
||||||
|
<summary>
|
||||||
|
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.JobController.getJobClass">
|
||||||
|
<summary>
|
||||||
|
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.JobController.stopJob">
|
||||||
|
<summary>
|
||||||
|
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.JobController.DeleteJob">
|
||||||
|
<summary>
|
||||||
|
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.JobController.ResumeJob">
|
||||||
|
<summary>
|
||||||
|
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.GetMenuInMould">
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.GetMenuInMould">
|
||||||
<summary>
|
<summary>
|
||||||
这个是要递归的,但是要过滤掉删除的,所以,可以写一个通用过滤掉删除的方法
|
这个是要递归的,但是要过滤掉删除的,所以,可以写一个通用过滤掉删除的方法
|
||||||
@@ -203,6 +245,7 @@
|
|||||||
</member>
|
</member>
|
||||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.SetRoleByUser(Yi.Framework.DTOModel.IdsListDto{System.Int32})">
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.SetRoleByUser(Yi.Framework.DTOModel.IdsListDto{System.Int32})">
|
||||||
<summary>
|
<summary>
|
||||||
|
SetRoleByUser
|
||||||
给多个用户设置多个角色,ids有用户id与 角色列表ids,多对多,ids1用户,ids2为角色
|
给多个用户设置多个角色,ids有用户id与 角色列表ids,多对多,ids1用户,ids2为角色
|
||||||
用户设置给用户设置角色
|
用户设置给用户设置角色
|
||||||
</summary>
|
</summary>
|
||||||
|
|||||||
@@ -13,11 +13,12 @@
|
|||||||
"Apollo_Enabled": false,
|
"Apollo_Enabled": false,
|
||||||
"HealthCheck_Enabled": false,
|
"HealthCheck_Enabled": false,
|
||||||
"Cors_Enabled": true,
|
"Cors_Enabled": true,
|
||||||
"RabbitMQ_Enabled": false,
|
"RabbitMQ_Enabled": true,
|
||||||
"Redis_Enabled": true,
|
"Redis_Enabled": true,
|
||||||
"RedisSeed_Enabled": true,
|
"RedisSeed_Enabled": true,
|
||||||
"Kafka_Enabled": false,
|
"Kafka_Enabled": false,
|
||||||
"MutiDB_Enabled": false,
|
"MutiDB_Enabled": false,
|
||||||
|
"SMS_Enabled": true,
|
||||||
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
||||||
"DbSelect": "Mysql",
|
"DbSelect": "Mysql",
|
||||||
|
|
||||||
@@ -46,6 +47,12 @@
|
|||||||
"DB": 1,
|
"DB": 1,
|
||||||
"Password": "Qz52013142020."
|
"Password": "Qz52013142020."
|
||||||
},
|
},
|
||||||
|
"RabbitConn": {
|
||||||
|
"HostName": "118.195.191.41",
|
||||||
|
"UserName": "cc",
|
||||||
|
"Password": "cc",
|
||||||
|
"Port": 5672
|
||||||
|
},
|
||||||
"KafkaOptions": {
|
"KafkaOptions": {
|
||||||
"BrokerList": "192.168.3.230:9092",
|
"BrokerList": "192.168.3.230:9092",
|
||||||
"TopicName": "kafkalog"
|
"TopicName": "kafkalog"
|
||||||
@@ -65,5 +72,11 @@
|
|||||||
"DeregisterCriticalServiceAfter": 60,
|
"DeregisterCriticalServiceAfter": 60,
|
||||||
"Tag": "13"
|
"Tag": "13"
|
||||||
},
|
},
|
||||||
|
"SMS": {
|
||||||
|
"ID": "LTAI5tJvjPaXCyyPMfXLNbVA",
|
||||||
|
"Secret": "fLQv7jjj57fUKLFK8REeAQPFVDjUYn",
|
||||||
|
"Sign": "JiftCC",
|
||||||
|
"Template": "SMS_221640732"
|
||||||
|
},
|
||||||
"IPLibraryServiceUrl": "http://gRPCIPLibraryService"
|
"IPLibraryServiceUrl": "http://gRPCIPLibraryService"
|
||||||
}
|
}
|
||||||
15
Yi.Framework/Yi.Framework.Common/Const/RabbitConst.cs
Normal file
15
Yi.Framework/Yi.Framework.Common/Const/RabbitConst.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Common.Const
|
||||||
|
{
|
||||||
|
public class RabbitConst
|
||||||
|
{
|
||||||
|
private const string prefix = "Yi.Framework.";
|
||||||
|
public const string SMS_Exchange = prefix+"SMS.Exchange";
|
||||||
|
public const string SMS_Queue_Send = prefix+ "SMS.Queue.Send";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,8 @@ namespace Yi.Framework.Common.IOCOptions
|
|||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
|
public int Port { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RabbitMQConsumerModel
|
public class RabbitMQConsumerModel
|
||||||
|
|||||||
18
Yi.Framework/Yi.Framework.Common/IOCOptions/SMSOptions.cs
Normal file
18
Yi.Framework/Yi.Framework.Common/IOCOptions/SMSOptions.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Common.IOCOptions
|
||||||
|
{
|
||||||
|
public class SMSOptions
|
||||||
|
{
|
||||||
|
|
||||||
|
public string ID { get; set; }
|
||||||
|
public string Secret { get; set; }
|
||||||
|
public string Sign { get; set; }
|
||||||
|
public string Template { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Yi.Framework/Yi.Framework.Common/QueueModel/SMSQueueModel.cs
Normal file
14
Yi.Framework/Yi.Framework.Common/QueueModel/SMSQueueModel.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Common.QueueModel
|
||||||
|
{
|
||||||
|
public class SMSQueueModel
|
||||||
|
{
|
||||||
|
public string code { get; set; }
|
||||||
|
public string phone { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,16 +26,18 @@ namespace Yi.Framework.Core
|
|||||||
private readonly string _HostName = null;
|
private readonly string _HostName = null;
|
||||||
private readonly string _UserName = null;
|
private readonly string _UserName = null;
|
||||||
private readonly string _Password = null;
|
private readonly string _Password = null;
|
||||||
public RabbitMQInvoker(IOptionsMonitor<RabbitMQOptions> optionsMonitor) : this(optionsMonitor.CurrentValue.HostName, optionsMonitor.CurrentValue.UserName, optionsMonitor.CurrentValue.Password)
|
private readonly int _Port = 0;
|
||||||
|
public RabbitMQInvoker(IOptionsMonitor<RabbitMQOptions> optionsMonitor) : this(optionsMonitor.CurrentValue.HostName, optionsMonitor.CurrentValue.UserName, optionsMonitor.CurrentValue.Password,optionsMonitor.CurrentValue.Port)
|
||||||
{
|
{
|
||||||
this._rabbitMQOptions = optionsMonitor.CurrentValue;
|
this._rabbitMQOptions = optionsMonitor.CurrentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RabbitMQInvoker(string hostName, string userName = "cc", string password = "cc")
|
public RabbitMQInvoker(string hostName, string userName = "cc", string password = "cc",int port= 5672)
|
||||||
{
|
{
|
||||||
this._HostName = hostName;
|
this._HostName = hostName;
|
||||||
this._UserName = userName;
|
this._UserName = userName;
|
||||||
this._Password = password;
|
this._Password = password;
|
||||||
|
this._Port = port;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -103,7 +105,9 @@ namespace Yi.Framework.Core
|
|||||||
{
|
{
|
||||||
HostName = this._HostName,
|
HostName = this._HostName,
|
||||||
Password = this._Password,
|
Password = this._Password,
|
||||||
UserName = this._UserName
|
UserName = this._UserName,
|
||||||
|
Port=this._Port
|
||||||
|
|
||||||
};
|
};
|
||||||
_CurrentConnection = factory.CreateConnection();
|
_CurrentConnection = factory.CreateConnection();
|
||||||
}
|
}
|
||||||
|
|||||||
46
Yi.Framework/Yi.Framework.Core/SMS/AliyunSMSInvoker.cs
Normal file
46
Yi.Framework/Yi.Framework.Core/SMS/AliyunSMSInvoker.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Common.IOCOptions;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Core.SMS
|
||||||
|
{
|
||||||
|
public class AliyunSMSInvoker
|
||||||
|
{
|
||||||
|
private IOptionsMonitor<SMSOptions> _sMSOptions;
|
||||||
|
public AliyunSMSInvoker(IOptionsMonitor<SMSOptions> sMSOptions)
|
||||||
|
{
|
||||||
|
_sMSOptions = sMSOptions;
|
||||||
|
}
|
||||||
|
private static AlibabaCloud.SDK.Dysmsapi20170525.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 AlibabaCloud.SDK.Dysmsapi20170525.Client(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendCode(string code,string phone)
|
||||||
|
{
|
||||||
|
AlibabaCloud.SDK.Dysmsapi20170525.Client client = CreateClient(_sMSOptions.CurrentValue.ID, _sMSOptions.CurrentValue.Secret);
|
||||||
|
AlibabaCloud.SDK.Dysmsapi20170525.Models.SendSmsRequest sendSmsRequest = new AlibabaCloud.SDK.Dysmsapi20170525.Models.SendSmsRequest
|
||||||
|
{
|
||||||
|
PhoneNumbers = phone,
|
||||||
|
SignName = _sMSOptions.CurrentValue.Sign,
|
||||||
|
TemplateCode = _sMSOptions.CurrentValue.Template,
|
||||||
|
TemplateParam = "{\"code\":\""+ code + "\"}",
|
||||||
|
};
|
||||||
|
// 复制代码运行请自行打印 API 的返回值
|
||||||
|
client.SendSms(sendSmsRequest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="2.0.6" />
|
||||||
<PackageReference Include="Consul" Version="1.6.10.3" />
|
<PackageReference Include="Consul" Version="1.6.10.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.11" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.11" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
|||||||
65
Yi.Framework/Yi.Framework.SMSProcessor/Log4net.config
Normal file
65
Yi.Framework/Yi.Framework.SMSProcessor/Log4net.config
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<log4net>
|
||||||
|
<!-- 将日志以回滚文件的形式写到文件中 -->
|
||||||
|
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
|
||||||
|
<!--Error-->
|
||||||
|
<appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
|
||||||
|
<!--不加utf-8编码格式,中文字符将显示成乱码-->
|
||||||
|
<param name="Encoding" value="utf-8" />
|
||||||
|
<file value="log/"/>
|
||||||
|
<appendToFile value="true" />
|
||||||
|
<rollingStyle value="Date" />
|
||||||
|
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
|
||||||
|
<datePattern value=""GlobalExceptionLogs_"yyyyMMdd".log"" />
|
||||||
|
<!--日志文件名是否为静态-->
|
||||||
|
<StaticLogFileName value="false"/>
|
||||||
|
<!--多线程时采用最小锁定-->
|
||||||
|
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||||
|
<!--布局(向用户显示最后经过格式化的输出信息)-->
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<conversionPattern value="%date| %-5level %newline%message%newline--------------------------------%newline" />
|
||||||
|
</layout>
|
||||||
|
<filter type="log4net.Filter.LevelRangeFilter">
|
||||||
|
<levelMin value="ERROR" />
|
||||||
|
<levelMax value="FATAL" />
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<!--Error-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--Info-->
|
||||||
|
<appender name="InfoLog" type="log4net.Appender.RollingFileAppender">
|
||||||
|
<!--不加utf-8编码格式,中文字符将显示成乱码-->
|
||||||
|
<param name="Encoding" value="utf-8" />
|
||||||
|
<!--定义文件存放位置-->
|
||||||
|
<file value="log/"/>
|
||||||
|
<appendToFile value="true" />
|
||||||
|
<rollingStyle value="Date" />
|
||||||
|
<!--日志文件名是否为静态-->
|
||||||
|
<StaticLogFileName value="false"/>
|
||||||
|
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
|
||||||
|
<datePattern value=""GlobalInfoLogs_"yyyyMMdd".log"" />
|
||||||
|
<!--多线程时采用最小锁定-->
|
||||||
|
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||||
|
<!--布局(向用户显示最后经过格式化的输出信息)-->
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<conversionPattern value="%date| %-5level%c %newline%message%newline--------------------------------%newline" />
|
||||||
|
</layout>
|
||||||
|
<filter type="log4net.Filter.LevelRangeFilter">
|
||||||
|
<levelMin value="DEBUG" />
|
||||||
|
<levelMax value="WARN" />
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<!--Info-->
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<!-- 控制级别,由低到高:ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF -->
|
||||||
|
<!-- 比如定义级别为INFO,则INFO级别向下的级别,比如DEBUG日志将不会被记录 -->
|
||||||
|
<!-- 如果没有定义LEVEL的值,则缺省为DEBUG -->
|
||||||
|
<level value="ALL" />
|
||||||
|
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
|
||||||
|
<appender-ref ref="ErrorLog" />
|
||||||
|
<appender-ref ref="InfoLog" />
|
||||||
|
</root>
|
||||||
|
</log4net>
|
||||||
77
Yi.Framework/Yi.Framework.SMSProcessor/Program.cs
Normal file
77
Yi.Framework/Yi.Framework.SMSProcessor/Program.cs
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
using Com.Ctrip.Framework.Apollo;
|
||||||
|
using Com.Ctrip.Framework.Apollo.Core;
|
||||||
|
using Com.Ctrip.Framework.Apollo.Enums;
|
||||||
|
using Com.Ctrip.Framework.Apollo.Logging;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using Yi.Framework.Common.IOCOptions;
|
||||||
|
using Yi.Framework.Core;
|
||||||
|
using Yi.Framework.Core.ConsulExtend;
|
||||||
|
using Yi.Framework.WebCore;
|
||||||
|
using Yi.Framework.WebCore.MiddlewareExtend;
|
||||||
|
|
||||||
|
namespace Yi.Framework.SMSProcessor
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
CreateHostBuilder(args).Build().Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
|
Host.CreateDefaultBuilder(args)
|
||||||
|
.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) =>
|
||||||
|
{
|
||||||
|
configurationBuilder.AddCommandLine(args);
|
||||||
|
configurationBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false);
|
||||||
|
//configurationBuilder.AddJsonFile("configuration.json", optional: false, reloadOnChange: true);
|
||||||
|
#region
|
||||||
|
//Apollo配置
|
||||||
|
#endregion
|
||||||
|
//configurationBuilder.AddApolloService("Yi");
|
||||||
|
})
|
||||||
|
.ConfigureLogging(loggingBuilder =>
|
||||||
|
{
|
||||||
|
loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning);
|
||||||
|
loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning);
|
||||||
|
loggingBuilder.AddLog4Net();
|
||||||
|
})
|
||||||
|
.ConfigureServices((hostContext, services) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
IConfiguration configuration = services.BuildServiceProvider().GetRequiredService<IConfiguration>();
|
||||||
|
|
||||||
|
#region
|
||||||
|
//Ioc配置
|
||||||
|
#endregion
|
||||||
|
services.AddSingleton(new Appsettings(configuration));
|
||||||
|
services.AddHostedService<Worker>();
|
||||||
|
services.AddHostedService<SendWorker>();
|
||||||
|
|
||||||
|
#region 服务注入
|
||||||
|
//services.Configure<MySqlConnOptions>(configuration.GetSection("MysqlConn"));
|
||||||
|
|
||||||
|
|
||||||
|
#region
|
||||||
|
//RabbitMQ服务配置
|
||||||
|
#endregion
|
||||||
|
services.AddRabbitMQService();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region
|
||||||
|
//短信服务配置
|
||||||
|
#endregion
|
||||||
|
services.AddSMSService();
|
||||||
|
|
||||||
|
#region Consul
|
||||||
|
//services.Configure<ConsulClientOption>(configuration.GetSection("ConsulClientOption"));
|
||||||
|
//services.AddTransient<AbstractConsulDispatcher, PollingDispatcher>();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
67
Yi.Framework/Yi.Framework.SMSProcessor/SendWorker.cs
Normal file
67
Yi.Framework/Yi.Framework.SMSProcessor/SendWorker.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Common.Const;
|
||||||
|
using Yi.Framework.Common.IOCOptions;
|
||||||
|
using Yi.Framework.Common.Models;
|
||||||
|
using Yi.Framework.Common.QueueModel;
|
||||||
|
using Yi.Framework.Core;
|
||||||
|
using Yi.Framework.Core.ConsulExtend;
|
||||||
|
using Yi.Framework.Core.SMS;
|
||||||
|
|
||||||
|
namespace Yi.Framework.SMSProcessor
|
||||||
|
{
|
||||||
|
public class SendWorker : BackgroundService
|
||||||
|
{
|
||||||
|
private readonly ILogger<SendWorker> _logger;
|
||||||
|
private readonly RabbitMQInvoker _RabbitMQInvoker;
|
||||||
|
private readonly AliyunSMSInvoker _aliyunSMSInvoker;
|
||||||
|
public SendWorker(ILogger<SendWorker> logger, RabbitMQInvoker rabbitMQInvoker,AliyunSMSInvoker aliyunSMSInvoker)
|
||||||
|
{
|
||||||
|
this._logger = logger;
|
||||||
|
this._RabbitMQInvoker = rabbitMQInvoker;
|
||||||
|
_aliyunSMSInvoker = aliyunSMSInvoker;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
RabbitMQConsumerModel rabbitMQConsumerModel = new RabbitMQConsumerModel()
|
||||||
|
{
|
||||||
|
ExchangeName = RabbitConst.SMS_Exchange,
|
||||||
|
QueueName = RabbitConst.SMS_Queue_Send
|
||||||
|
};
|
||||||
|
HttpClient _HttpClient = new HttpClient();
|
||||||
|
this._RabbitMQInvoker.RegistReciveAction(rabbitMQConsumerModel, message =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_aliyunSMSInvoker.SendCode("1234","15949688315");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var logModel = new LogModel()
|
||||||
|
{
|
||||||
|
OriginalClassName = this.GetType().FullName,
|
||||||
|
OriginalMethodName = nameof(ExecuteAsync),
|
||||||
|
Remark = "<22><>Ϣ<EFBFBD><CFA2><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>־"
|
||||||
|
};
|
||||||
|
this._logger.LogError(ex, $"{nameof(SendWorker)}, Exception:{ex.Message}", JsonConvert.SerializeObject(logModel));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
32
Yi.Framework/Yi.Framework.SMSProcessor/Worker.cs
Normal file
32
Yi.Framework/Yi.Framework.SMSProcessor/Worker.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.Framework.SMSProcessor
|
||||||
|
{
|
||||||
|
public class Worker : BackgroundService
|
||||||
|
{
|
||||||
|
private readonly ILogger<Worker> _logger;
|
||||||
|
private readonly IConfiguration _IConfiguration;
|
||||||
|
public Worker(ILogger<Worker> logger, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
this._logger = logger;
|
||||||
|
this._IConfiguration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
while (!stoppingToken.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
||||||
|
_logger.LogInformation($"Worker appsetting ConsulClientOption:Ip={this._IConfiguration["ConsulClientOption:Ip"]}");
|
||||||
|
await Task.Delay(1000, stoppingToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<StartupObject>Yi.Framework.SMSProcessor.Program</StartupObject>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Log4net.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Log4net.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="2.0.6" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="appsettings.Development.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft": "Warning",
|
||||||
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
Yi.Framework/Yi.Framework.SMSProcessor/appsettings.json
Normal file
45
Yi.Framework/Yi.Framework.SMSProcessor/appsettings.json
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft": "Warning",
|
||||||
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"RabbitMQ_Enabled": true,
|
||||||
|
"SMS_Enabled": true,
|
||||||
|
"RedisConn": {
|
||||||
|
"Host": "192.168.2.128",
|
||||||
|
"Prot": 6379,
|
||||||
|
"DB": 0,
|
||||||
|
"Password": "123456"
|
||||||
|
},
|
||||||
|
"RabbitConn": {
|
||||||
|
"HostName": "118.195.191.41",
|
||||||
|
"UserName": "cc",
|
||||||
|
"Password": "cc",
|
||||||
|
"Port": 5672
|
||||||
|
},
|
||||||
|
//"DetailPageUrl": "http://localhost:5728/item/",
|
||||||
|
"DetailPageUrl": "http://PageDetail/item/",
|
||||||
|
"ConsulClientOption": {
|
||||||
|
"IP": "192.168.2.128",
|
||||||
|
"Port": "8500",
|
||||||
|
"Datacenter": "dc1"
|
||||||
|
},
|
||||||
|
"MysqlConn": {
|
||||||
|
"Url": "server=192.168.2.128;port=3306;database=ECDB;user id=root;password=123456"
|
||||||
|
},
|
||||||
|
"Apollo": {
|
||||||
|
"AppId": "Yi.Framework.StaticPageProcessor",
|
||||||
|
"Env": "DEV",
|
||||||
|
"MetaServer": "http://192.168.2.168:8080",
|
||||||
|
"ConfigServer": [ "http://192.168.2.168:8080" ]
|
||||||
|
},
|
||||||
|
"SMS": {
|
||||||
|
"ID": "LTAI5tJvjPaXCyyPMfXLNbVA",
|
||||||
|
"Secret": "fLQv7jjj57fUKLFK8REeAQPFVDjUYn",
|
||||||
|
"Sign": "JiftCC",
|
||||||
|
"Template": "SMS_221640732"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ using Microsoft.OpenApi.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Yi.Framework.Common.IOCOptions;
|
using Yi.Framework.Common.IOCOptions;
|
||||||
|
using Yi.Framework.Core;
|
||||||
|
|
||||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||||
{
|
{
|
||||||
@@ -17,6 +18,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
|||||||
if (Appsettings.appBool("RabbitMQ_Enabled"))
|
if (Appsettings.appBool("RabbitMQ_Enabled"))
|
||||||
{
|
{
|
||||||
services.Configure<RabbitMQOptions>(Appsettings.appConfiguration("RabbitConn"));
|
services.Configure<RabbitMQOptions>(Appsettings.appConfiguration("RabbitConn"));
|
||||||
|
services.AddTransient<RabbitMQInvoker>();
|
||||||
}
|
}
|
||||||
return services;
|
return services;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using Yi.Framework.Common.IOCOptions;
|
||||||
|
using Yi.Framework.Core;
|
||||||
|
using Yi.Framework.Core.SMS;
|
||||||
|
|
||||||
|
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Redis扩展
|
||||||
|
/// </summary>
|
||||||
|
public static class SMSExtension
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddSMSService(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (Appsettings.appBool("SMS_Enabled"))
|
||||||
|
{
|
||||||
|
|
||||||
|
services.Configure<SMSOptions>(Appsettings.appConfiguration("SMS"));
|
||||||
|
services.AddTransient<AliyunSMSInvoker>();
|
||||||
|
}
|
||||||
|
return services;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using IGeekFan.AspNetCore.Knife4jUI;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using System;
|
using System;
|
||||||
@@ -32,7 +34,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
|||||||
var apiXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//控制器层注释
|
var apiXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//控制器层注释
|
||||||
//var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
|
//var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
|
||||||
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
|
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
|
||||||
c.IncludeXmlComments(apiXmlPath);
|
c.IncludeXmlComments(apiXmlPath,true);
|
||||||
|
|
||||||
//添加控制器注释
|
//添加控制器注释
|
||||||
//c.DocumentFilter<SwaggerDocTag>();
|
//c.DocumentFilter<SwaggerDocTag>();
|
||||||
@@ -59,6 +61,17 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
|||||||
}
|
}
|
||||||
}, Array.Empty<string>() }
|
}, Array.Empty<string>() }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
c.AddServer(new OpenApiServer()
|
||||||
|
{
|
||||||
|
Url = "https://ccnetcore.com",
|
||||||
|
Description = "Yi-Framework"
|
||||||
|
});
|
||||||
|
c.CustomOperationIds(apiDesc =>
|
||||||
|
{
|
||||||
|
var controllerAction = apiDesc.ActionDescriptor as ControllerActionDescriptor;
|
||||||
|
return controllerAction.ActionName;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -70,11 +83,14 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
|||||||
//在 Startup.Configure 方法中,启用中间件为生成的 JSON 文档和 Swagger UI 提供服务:
|
//在 Startup.Configure 方法中,启用中间件为生成的 JSON 文档和 Swagger UI 提供服务:
|
||||||
// Enable middleware to serve generated Swagger as a JSON endpoint.
|
// Enable middleware to serve generated Swagger as a JSON endpoint.
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI(c =>
|
|
||||||
|
|
||||||
|
app.UseKnife4UI(c =>
|
||||||
{
|
{
|
||||||
|
c.RoutePrefix = "swagger"; // serve the UI at root
|
||||||
if (swaggerModels.Length == 0)
|
if (swaggerModels.Length == 0)
|
||||||
{
|
{
|
||||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Yi.Framework");
|
c.SwaggerEndpoint("/v1/swagger.json", "Yi.Framework");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -83,10 +99,25 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
|||||||
c.SwaggerEndpoint(k.url, k.name);
|
c.SwaggerEndpoint(k.url, k.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
//app.UseSwaggerUI(c =>
|
||||||
|
//{
|
||||||
|
// if (swaggerModels.Length == 0)
|
||||||
|
// {
|
||||||
|
// c.SwaggerEndpoint("/swagger/v1/swagger.json", "Yi.Framework");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// foreach (var k in swaggerModels)
|
||||||
|
// {
|
||||||
|
// c.SwaggerEndpoint(k.url, k.name);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
);
|
//}
|
||||||
|
|
||||||
|
//);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||||
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
|
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
|
||||||
<PackageReference Include="Com.Ctrip.Framework.Apollo.Configuration" Version="2.4.1.1" />
|
<PackageReference Include="Com.Ctrip.Framework.Apollo.Configuration" Version="2.4.1.1" />
|
||||||
|
<PackageReference Include="IGeekFan.AspNetCore.Knife4jUI" Version="0.0.10" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.11" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.11" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.MSUnitTest", "
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.PageDetail", "Yi.Framework.PageDetail\Yi.Framework.PageDetail.csproj", "{637501E2-A32E-485C-8680-ED863D1793C2}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.PageDetail", "Yi.Framework.PageDetail\Yi.Framework.PageDetail.csproj", "{637501E2-A32E-485C-8680-ED863D1793C2}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.Job", "Yi.Framework.Task\Yi.Framework.Job.csproj", "{F1C990DD-32C3-4F02-83B0-6E52B18B0B17}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Job", "Yi.Framework.Task\Yi.Framework.Job.csproj", "{F1C990DD-32C3-4F02-83B0-6E52B18B0B17}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.SMSProcessor", "Yi.Framework.SMSProcessor\Yi.Framework.SMSProcessor.csproj", "{7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -109,6 +111,10 @@ Global
|
|||||||
{F1C990DD-32C3-4F02-83B0-6E52B18B0B17}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{F1C990DD-32C3-4F02-83B0-6E52B18B0B17}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{F1C990DD-32C3-4F02-83B0-6E52B18B0B17}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{F1C990DD-32C3-4F02-83B0-6E52B18B0B17}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{F1C990DD-32C3-4F02-83B0-6E52B18B0B17}.Release|Any CPU.Build.0 = Release|Any CPU
|
{F1C990DD-32C3-4F02-83B0-6E52B18B0B17}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -129,6 +135,7 @@ Global
|
|||||||
{531255B3-9669-4BC1-B4E5-A0C6E0540F0D} = {C90E38FB-69EA-4997-8B3A-2C71EFA65B2B}
|
{531255B3-9669-4BC1-B4E5-A0C6E0540F0D} = {C90E38FB-69EA-4997-8B3A-2C71EFA65B2B}
|
||||||
{637501E2-A32E-485C-8680-ED863D1793C2} = {026D2797-07D1-4BA5-8070-50CDE0258C59}
|
{637501E2-A32E-485C-8680-ED863D1793C2} = {026D2797-07D1-4BA5-8070-50CDE0258C59}
|
||||||
{F1C990DD-32C3-4F02-83B0-6E52B18B0B17} = {9ABAF6B1-6C02-498A-90A2-ABC1140CF89A}
|
{F1C990DD-32C3-4F02-83B0-6E52B18B0B17} = {9ABAF6B1-6C02-498A-90A2-ABC1140CF89A}
|
||||||
|
{7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E} = {D6B44435-EAFA-4D55-90D0-3AF80485FB83}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {1ED77A6E-377F-4EEF-A3D0-D65C94657DAF}
|
SolutionGuid = {1ED77A6E-377F-4EEF-A3D0-D65C94657DAF}
|
||||||
|
|||||||
Reference in New Issue
Block a user