😎1、增加 MQTT 相关WebAPI 2、调整远程请求定时任务脚本 3、升级依赖

This commit is contained in:
zuohuaijun 2025-02-20 09:44:03 +08:00
parent efeb9f843e
commit 42dc3b479f
4 changed files with 40 additions and 12 deletions

View File

@ -20,9 +20,9 @@
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.5.1" Aliases="BouncyCastleV2" />
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.17.1" />
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.7.8" />
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.7.8" />
<PackageReference Include="Furion.Pure" Version="4.9.7.8" />
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.7.9" />
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.7.9" />
<PackageReference Include="Furion.Pure" Version="4.9.7.9" />
<PackageReference Include="Hardware.Info" Version="101.0.1" />
<PackageReference Include="Hashids.net" Version="1.7.0" />
<PackageReference Include="IPTools.China" Version="1.6.0" />
@ -40,7 +40,7 @@
<PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="3.6.0" />
<PackageReference Include="OnceMi.AspNetCore.OSS" Version="1.2.0" />
<PackageReference Include="QRCoder" Version="1.6.0" />
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
<PackageReference Include="RabbitMQ.Client" Version="7.1.0" />
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.3" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.7.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.10.0" />

View File

@ -17,7 +17,7 @@ using System.Threading.Tasks;
/// <summary>
/// MQTT 服务
/// </summary>
public class MqttHostedService(IOptions<MqttOptions> mqttOptions, ISqlSugarClient db) : IHostedService, IDisposable
public class MqttHostedService(IOptions<MqttOptions> mqttOptions, ISqlSugarClient db) : IHostedService, ITransient
{
private const string ServerClientId = "Admin.NET.MQTT";
public MqttServer MqttServer { get; set; }
@ -181,9 +181,4 @@ public class MqttHostedService(IOptions<MqttOptions> mqttOptions, ISqlSugarClien
{
return Task.CompletedTask;
}
public void Dispose()
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,31 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using MQTTnet.Server;
namespace Admin.NET.Core.Service;
/// <summary>
/// 系统 MQTT 服务 🧩
/// </summary>
[ApiDescriptionSettings(Order = 90, Description = "MQTT 服务")]
public class SysMqttService(MqttHostedService mqttHostedService) : IDynamicApiController, ITransient
{
private readonly MqttHostedService _mqttHostedService = mqttHostedService;
/// <summary>
/// 获取客户端列表 🔖
/// </summary>
/// <returns></returns>
[DisplayName("获取客户端列表")]
public async Task<IList<MqttClientStatus>> GetClients()
{
if (_mqttHostedService.MqttServer == null)
throw Oops.Oh("【MQTT】服务未启动");
return await _mqttHostedService.MqttServer.GetClientsAsync();
}
}

View File

@ -7,8 +7,8 @@ export const JobScriptCode = `// Admin.NET 项目的版权、商标、专利和
#region using
using Furion;
using Furion.HttpRemote;
using Furion.Logging;
using Furion.RemoteRequest.Extensions;
using Furion.Schedule;
using Microsoft.Extensions.DependencyInjection;
using System;
@ -45,7 +45,9 @@ public class DynamicJob : IJob
// var rep = serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysUser>>();
// 请求网址
// var result = await "http://www.baidu.com".GetAsStringAsync();
// var url = "http://www.baidu.com";
// var httpRemoteService = App.GetRequiredService<IHttpRemoteService>();
// var result = await httpRemoteService.GetAsStringAsync(url);
// Console.WriteLine(result);
// 日志