master
xiaochanghai 2 weeks ago
parent 6caeda7651
commit 75351ca06c
  1. 13
      Ocelot.Provider.Nacos/Nacos.cs
  2. 9
      Ocelot.Provider.Nacos/NacosClient/LoadBalance/ILBStrategy.cs
  3. 7
      Ocelot.Provider.Nacos/NacosClient/LoadBalance/LBStrategyName.cs
  4. 7
      Ocelot.Provider.Nacos/NacosClient/LoadBalance/LbKv.cs
  5. 13
      Ocelot.Provider.Nacos/NacosClient/LoadBalance/WeightRandomLBStrategy.cs
  6. 12
      Ocelot.Provider.Nacos/NacosClient/LoadBalance/WeightRoundRobinLBStrategy.cs
  7. 12
      Ocelot.Provider.Nacos/NacosClient/UriTool.cs
  8. 8
      Ocelot.Provider.Nacos/NacosClient/V2/NacosAspNetOptions.cs
  9. 12
      Ocelot.Provider.Nacos/NacosClient/V2/RegSvcBgTask.cs
  10. 9
      Ocelot.Provider.Nacos/NacosClient/V2/ServiceCollectionExtensions.cs
  11. 13
      Ocelot.Provider.Nacos/NacosMiddlewareConfigurationProvider.cs
  12. 14
      Ocelot.Provider.Nacos/NacosProviderFactory.cs
  13. 10
      Ocelot.Provider.Nacos/OcelotBuilderExtensions.cs
  14. 8
      Tiobon.Core.Common/Helper/ExtensionHelper.cs
  15. 13
      Tiobon.Core.EventBus/EventBusKafka/EventBusKafka.cs
  16. 14
      Tiobon.Core.EventBus/EventBusKafka/IKafkaConnectionPool.cs
  17. 17
      Tiobon.Core.EventBus/EventBusKafka/KafkaConnectionPool.cs
  18. 17
      Tiobon.Core.EventBus/EventBusKafka/KafkaConsumerHostService.cs
  19. 13
      Tiobon.Core.EventBus/EventBusKafka/KafkaOptions.cs
  20. 9
      Tiobon.Core.EventBus/EventBusKafka/ProtobufTransfer.cs
  21. 22
      Tiobon.Core.EventBus/EventBusSubscriptions/InMemoryEventBusSubscriptionsManager.cs
  22. 14
      Tiobon.Core.EventBus/EventBusSubscriptions/SubscriptionInfo.cs
  23. 15
      Tiobon.Core.EventBus/Eventbus/IDynamicIntegrationEventHandler.cs
  24. 15
      Tiobon.Core.EventBus/Eventbus/IEventBus.cs
  25. 17
      Tiobon.Core.EventBus/Eventbus/IEventBusSubscriptionsManager.cs
  26. 33
      Tiobon.Core.EventBus/Eventbus/IIntegrationEventHandler.cs
  27. 16
      Tiobon.Core.EventBus/Eventbus/IntegrationEvent.cs
  28. 13
      Tiobon.Core.EventBus/RabbitMQPersistent/EventBusRabbitMQ.cs
  29. 18
      Tiobon.Core.EventBus/RabbitMQPersistent/IRabbitMQPersistentConnection.cs
  30. 17
      Tiobon.Core.EventBus/RabbitMQPersistent/RabbitMQPersistentConnection.cs
  31. 17
      Tiobon.Core.Gateway/Controllers/UserController.cs
  32. 11
      Tiobon.Core.Gateway/Extensions/CustomAuthenticationHandler.cs
  33. 15
      Tiobon.Core.Gateway/Extensions/CustomOcelotSetup.cs
  34. 11
      Tiobon.Core.Gateway/Extensions/CustomResultHandler.cs
  35. 21
      Tiobon.Core.Gateway/Extensions/CustomSwaggerSetup.cs
  36. 35
      Tiobon.Core.Gateway/Helper/CustomJwtTokenAuthMiddleware.cs
  37. 9
      Tiobon.Core.Gateway/Program.cs
  38. 7
      Tiobon.Core.Model/HttpEnum.cs
  39. 16
      Tiobon.Core.Model/ViewModels/EnumDemoDto.cs
  40. 22
      Tiobon.Core.Model/ViewModels/TopgbViewModels.cs
  41. 18
      Tiobon.Core.Model/ViewModels/UploadFileDto.cs
  42. 5
      Tiobon.Core.Tasks/GlobalUsings.cs
  43. 7
      Tiobon.Core.Tasks/QuartzNet/ISchedulerCenter.cs
  44. 5
      Tiobon.Core.Tasks/QuartzNet/Jobs/JobBase.cs
  45. 4
      Tiobon.Core.Tasks/QuartzNet/Jobs/Job_AutoClearLog_Quartz.cs
  46. 4
      Tiobon.Core.Tasks/QuartzNet/Jobs/Job_AutoIssueCertificate_Quartz.cs
  47. 3
      Tiobon.Core.Tasks/QuartzNet/Jobs/Job_AutoIssueCredit_Quartz.cs
  48. 4
      Tiobon.Core.Tasks/QuartzNet/Jobs/Job_AutoMarkCompleteStatus_Quartz.cs
  49. 1
      Tiobon.Core.Tasks/QuartzNet/Jobs/Job_OperateLog_Quartz.cs
  50. 4
      Tiobon.Core.Tasks/QuartzNet/Jobs/Job_URL_Quartz.cs
  51. 3
      Tiobon.Core.Tasks/QuartzNet/SchedulerCenterServer.cs
  52. 8
      Tiobon.Core.Tests/Common_Test/DbAccess_Should.cs
  53. 7
      Tiobon.Core.Tests/Common_Test/HttpHelper_Should.cs
  54. 11
      Tiobon.Core.Tests/Common_Test/SM4Helper_Should.cs
  55. 7
      Tiobon.Core.Tests/Controller_Test/LoginController_Should.cs
  56. 7
      Tiobon.Core.Tests/DependencyInjection/DI_Test.cs
  57. 7
      Tiobon.Core.Tests/Redis_Test/Redis_Should.cs
  58. 19
      Tiobon.Core.Tests/Repository_Test/MongoRepository_Base_Should.cs
  59. 15
      Tiobon.Core.Tests/Repository_Test/Repository_Base_Should.cs
  60. 9
      Tiobon.Core.sln
  61. 25
      Tiobon.Core/Tiobon.Core.Model.xml

@ -1,14 +1,14 @@
using Ocelot.ServiceDiscovery.Providers;
using Ocelot.Values;
using Microsoft.Extensions.Options;
using Nacos.V2;
using Microsoft.Extensions.Options;
using Ocelot.Provider.Nacos.NacosClient.V2;
using Ocelot.ServiceDiscovery.Providers;
using Ocelot.Values;
using NacosConstants = Nacos.V2.Common.Constants;
namespace Ocelot.Provider.Nacos
namespace Ocelot.Provider.Nacos;
public class Nacos : IServiceDiscoveryProvider
{
public class Nacos : IServiceDiscoveryProvider
{
private readonly INacosNamingService _client;
private readonly string _serviceName;
private readonly string _groupName;
@ -53,5 +53,4 @@ namespace Ocelot.Provider.Nacos
{
throw new NotImplementedException();
}
}
}

@ -2,10 +2,10 @@
using Nacos.V2.Naming.Dtos;
using System.Collections.Generic;
namespace Ocelot.Provider.Nacos.NacosClient
namespace Ocelot.Provider.Nacos.NacosClient;
public interface ILBStrategy
{
public interface ILBStrategy
{
/// <summary>
/// Strategy Name
/// </summary>
@ -17,10 +17,9 @@ namespace Ocelot.Provider.Nacos.NacosClient
/// <param name="list">host list</param>
/// <returns>The Host</returns>
Instance GetHost(List<Instance> list);
}
}
}

@ -1,7 +1,7 @@
namespace Ocelot.Provider.Nacos.NacosClient
namespace Ocelot.Provider.Nacos.NacosClient;
public enum LBStrategyName
{
public enum LBStrategyName
{
/// <summary>
/// Weight Round Robin
/// </summary>
@ -16,5 +16,4 @@
/// Ext1
/// </summary>
Ext1
}
}

@ -1,9 +1,8 @@
namespace Ocelot.Provider.Nacos.NacosClient
namespace Ocelot.Provider.Nacos.NacosClient;
public class LbKv
{
public class LbKv
{
public string InstanceId { get; set; }
public double Weight { get; set; }
}
}

@ -1,13 +1,9 @@
using Nacos;
using Nacos.V2.Naming.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using Nacos.V2.Naming.Dtos;
namespace Ocelot.Provider.Nacos.NacosClient
namespace Ocelot.Provider.Nacos.NacosClient;
public class WeightRandomLBStrategy : ILBStrategy
{
public class WeightRandomLBStrategy : ILBStrategy
{
public LBStrategyName Name => LBStrategyName.WeightRandom;
public Instance GetHost(List<Instance> list)
@ -70,5 +66,4 @@ namespace Ocelot.Provider.Nacos.NacosClient
return dict;
}
}
}

@ -1,11 +1,8 @@
using Nacos;
using System.Collections.Generic;
using System.Linq;
using Nacos.V2.Naming.Dtos;
namespace Ocelot.Provider.Nacos.NacosClient
using Nacos.V2.Naming.Dtos;
namespace Ocelot.Provider.Nacos.NacosClient;
public class WeightRoundRobinLBStrategy : ILBStrategy
{
public class WeightRoundRobinLBStrategy : ILBStrategy
{
public LBStrategyName Name => LBStrategyName.WeightRoundRobin;
private int _pos;
@ -67,5 +64,4 @@ namespace Ocelot.Provider.Nacos.NacosClient
return instance;
}
}
}

@ -1,15 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http.Features;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
namespace Ocelot.Provider.Nacos.NacosClient
namespace Ocelot.Provider.Nacos.NacosClient;
internal static class UriTool
{
internal static class UriTool
{
public static IEnumerable<Uri> GetUri(IFeatureCollection features, string ip, int port, string preferredNetworks)
{
var splitChars = new char[] { ',', ';' };
@ -140,6 +137,5 @@ namespace Ocelot.Provider.Nacos.NacosClient
return instanceIp;
}
}
}

@ -1,11 +1,10 @@
using Nacos.V2;
using Nacos.V2.Common;
using System.Collections.Generic;
namespace Ocelot.Provider.Nacos.NacosClient.V2
namespace Ocelot.Provider.Nacos.NacosClient.V2;
public class NacosAspNetOptions : NacosSdkOptions
{
public class NacosAspNetOptions : NacosSdkOptions
{
/// <summary>
/// the name of the service.
/// </summary>
@ -92,5 +91,4 @@ namespace Ocelot.Provider.Nacos.NacosClient.V2
UserName = this.UserName,
};
}
}
}

@ -1,20 +1,15 @@
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Nacos.V2;
using Nacos.V2.Naming.Core;
using Nacos.V2.Naming.Dtos;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Ocelot.Provider.Nacos.NacosClient.V2
namespace Ocelot.Provider.Nacos.NacosClient.V2;
public class RegSvcBgTask
{
public class RegSvcBgTask
{
private static readonly string MetadataNetVersion = "DOTNET_VERSION";
private static readonly string MetadataHostOs = "HOST_OS";
private static readonly string MetadataSecure = "secure";
@ -123,5 +118,4 @@ namespace Ocelot.Provider.Nacos.NacosClient.V2
}
}
}
}
}

@ -3,13 +3,11 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Nacos.V2.DependencyInjection;
using System;
using System.Threading.Tasks;
namespace Ocelot.Provider.Nacos.NacosClient.V2
namespace Ocelot.Provider.Nacos.NacosClient.V2;
public static class ServiceCollectionExtensions
{
public static class ServiceCollectionExtensions
{
/// <summary>
/// Add Nacos AspNet. This will register and de-register instance automatically.
/// Mainly for nacos server 2.x
@ -55,5 +53,4 @@ namespace Ocelot.Provider.Nacos.NacosClient.V2
});
return app;
}
}
}

@ -1,16 +1,14 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Ocelot.Configuration;
using Ocelot.Configuration.Repository;
using Ocelot.Middleware;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Ocelot.Provider.Nacos.NacosClient.V2;
namespace Ocelot.Provider.Nacos
namespace Ocelot.Provider.Nacos;
public class NacosMiddlewareConfigurationProvider
{
public class NacosMiddlewareConfigurationProvider
{
public static OcelotMiddlewareConfigurationDelegate Get = builder =>
{
var internalConfigRepo = builder.ApplicationServices.GetService<IInternalConfigurationRepository>();
@ -30,5 +28,4 @@ namespace Ocelot.Provider.Nacos
{
return configuration?.ServiceProviderConfiguration != null && configuration.ServiceProviderConfiguration.Type?.ToLower() == "nacos";
}
}
}

@ -1,14 +1,13 @@
using System;
using Ocelot.ServiceDiscovery;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Nacos.V2;
using Ocelot.Provider.Nacos.NacosClient.V2;
using Microsoft.Extensions.Options;
using Ocelot.ServiceDiscovery;
namespace Ocelot.Provider.Nacos
namespace Ocelot.Provider.Nacos;
public static class NacosProviderFactory
{
public static class NacosProviderFactory
{
public static ServiceDiscoveryFinderDelegate Get = (provider, config, route) =>
{
var client = provider.GetService<INacosNamingService>();
@ -19,5 +18,4 @@ namespace Ocelot.Provider.Nacos
}
return null;
};
}
}

@ -1,14 +1,13 @@
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Provider.Nacos.NacosClient.V2;
using Ocelot.ServiceDiscovery;
namespace Ocelot.Provider.Nacos
namespace Ocelot.Provider.Nacos;
public static class OcelotBuilderExtensions
{
public static class OcelotBuilderExtensions
{
public static IOcelotBuilder AddNacosDiscovery(this IOcelotBuilder builder)
{
builder.Services.AddNacosAspNet(builder.Configuration);
@ -16,5 +15,4 @@ namespace Ocelot.Provider.Nacos
builder.Services.AddSingleton<OcelotMiddlewareConfigurationDelegate>(NacosMiddlewareConfigurationProvider.Get);
return builder;
}
}
}

@ -1,4 +1,10 @@
namespace Tiobon.Core.Common.Helper;
using SqlSugar;
using System.Data;
using Tiobon.Core.Helper;
using Tiobon.Core.Model.Entity;
using Tiobon.Core.Model.ViewModels.Extend;
namespace Tiobon.Core.Common.Helper;
public class ExtensionHelper
{

@ -4,13 +4,13 @@ using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Tiobon.Core.Extensions;
namespace Tiobon.Core.EventBus
namespace Tiobon.Core.EventBus;
/// <summary>
/// 基于Kafka的事件总线
/// </summary>
public class EventBusKafka : IEventBus
{
/// <summary>
/// 基于Kafka的事件总线
/// </summary>
public class EventBusKafka : IEventBus
{
private readonly ILogger<EventBusKafka> _logger;
private readonly IEventBusSubscriptionsManager _subsManager;
private readonly IKafkaConnectionPool _connectionPool;
@ -113,5 +113,4 @@ namespace Tiobon.Core.EventBus
_subsManager.Clear();
}
}
}

@ -1,14 +1,13 @@
using Confluent.Kafka;
using System;
namespace Tiobon.Core.EventBus
namespace Tiobon.Core.EventBus;
/// <summary>
/// Kafka连接池
/// </summary>
public interface IKafkaConnectionPool:IDisposable
{
/// <summary>
/// Kafka连接池
/// </summary>
public interface IKafkaConnectionPool:IDisposable
{
/// <summary>
/// 取对象
/// </summary>
@ -21,5 +20,4 @@ namespace Tiobon.Core.EventBus
/// <param name="producer"></param>
/// <returns></returns>
bool Return(IProducer<string, byte[]> producer);
}
}

@ -1,18 +1,16 @@
using Confluent.Kafka;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Collections.Concurrent;
using System.Threading;
namespace Tiobon.Core.EventBus
namespace Tiobon.Core.EventBus;
/// <summary>
/// Kafka producer 连接池管理
/// 可以使用微软官方的对象池进行构造ObjectPool
/// </summary>
public class KafkaConnectionPool : IKafkaConnectionPool
{
/// <summary>
/// Kafka producer 连接池管理
/// 可以使用微软官方的对象池进行构造ObjectPool
/// </summary>
public class KafkaConnectionPool : IKafkaConnectionPool
{
private readonly KafkaOptions _options;
private ConcurrentQueue<IProducer<string, byte[]>> _producerPool = new();
private int _currentCount;
@ -75,5 +73,4 @@ namespace Tiobon.Core.EventBus
}
}
}
}

@ -6,18 +6,14 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Tiobon.Core.EventBus
namespace Tiobon.Core.EventBus;
/// <summary>
/// Kafka consumer 监听服务
/// </summary>
public class KafkaConsumerHostService : BackgroundService
{
/// <summary>
/// Kafka consumer 监听服务
/// </summary>
public class KafkaConsumerHostService : BackgroundService
{
private readonly string AUTOFAC_SCOPE_NAME = "Tioboncore_event_bus";
private readonly ILogger<KafkaConsumerHostService> _logger;
private readonly IConsumer<string, byte[]> _consumer;
@ -158,5 +154,4 @@ namespace Tiobon.Core.EventBus
{
_logger.LogError("An error occurred during connect kafka:" + e.Reason);
}
}
}

@ -1,12 +1,12 @@

namespace Tiobon.Core.EventBus
namespace Tiobon.Core.EventBus;
/// <summary>
/// Kafka 配置项
/// </summary>
public class KafkaOptions
{
/// <summary>
/// Kafka 配置项
/// </summary>
public class KafkaOptions
{
public int ConnectionPoolSize { get; set; } = 10;
/// <summary>
/// 地址
@ -24,5 +24,4 @@ namespace Tiobon.Core.EventBus
/// 主题分区
/// </summary>
public int NumPartitions { get; set; }
}
}

@ -1,9 +1,7 @@
using System;
using System.IO;
namespace Tiobon.Core.EventBus
namespace Tiobon.Core.EventBus;
public class Protobuf
{
public class Protobuf
{
/// <summary>
/// Protobuf 反序列化
/// </summary>
@ -27,6 +25,5 @@ namespace Tiobon.Core.EventBus
return datas;
}
}
}

@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Tiobon.Core.EventBus
namespace Tiobon.Core.EventBus;
/// <summary>
/// 基于内存
/// 事件总线订阅管理器
/// 单例模式
/// </summary>
public partial class InMemoryEventBusSubscriptionsManager : IEventBusSubscriptionsManager
{
/// <summary>
/// 基于内存
/// 事件总线订阅管理器
/// 单例模式
/// </summary>
public partial class InMemoryEventBusSubscriptionsManager : IEventBusSubscriptionsManager
{
private readonly Dictionary<string, List<SubscriptionInfo>> _handlers;
private readonly List<Type> _eventTypes;
@ -178,6 +174,4 @@ namespace Tiobon.Core.EventBus
{
return typeof(T).Name;
}
}
}

@ -1,12 +1,10 @@
using System;
namespace Tiobon.Core.EventBus;
namespace Tiobon.Core.EventBus
/// <summary>
/// 订阅信息模型
/// </summary>
public class SubscriptionInfo
{
/// <summary>
/// 订阅信息模型
/// </summary>
public class SubscriptionInfo
{
public bool IsDynamic { get; }
public Type HandlerType { get; }
@ -24,6 +22,4 @@ namespace Tiobon.Core.EventBus
{
return new SubscriptionInfo(false, handlerType);
}
}
}

@ -1,13 +1,10 @@
using System.Threading.Tasks;
namespace Tiobon.Core.EventBus;
namespace Tiobon.Core.EventBus
/// <summary>
/// 动态集成事件处理程序
/// 接口
/// </summary>
public interface IDynamicIntegrationEventHandler
{
/// <summary>
/// 动态集成事件处理程序
/// 接口
/// </summary>
public interface IDynamicIntegrationEventHandler
{
Task Handle(dynamic eventData);
}
}

@ -1,11 +1,11 @@
namespace Tiobon.Core.EventBus
namespace Tiobon.Core.EventBus;
/// <summary>
/// 事件总线
/// 接口
/// </summary>
public interface IEventBus
{
/// <summary>
/// 事件总线
/// 接口
/// </summary>
public interface IEventBus
{
/// <summary>
/// 发布
/// </summary>
@ -45,5 +45,4 @@
/// <param name="eventName"></param>
void UnsubscribeDynamic<TH>(string eventName)
where TH : IDynamicIntegrationEventHandler;
}
}

@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
namespace Tiobon.Core.EventBus;
namespace Tiobon.Core.EventBus
/// <summary>
/// 事件总线订阅管理器
/// 接口
/// </summary>
public interface IEventBusSubscriptionsManager
{
/// <summary>
/// 事件总线订阅管理器
/// 接口
/// </summary>
public interface IEventBusSubscriptionsManager
{
bool IsEmpty { get; }
event EventHandler<string> OnEventRemoved;
void AddDynamicSubscription<TH>(string eventName)
@ -31,6 +28,4 @@ namespace Tiobon.Core.EventBus
IEnumerable<SubscriptionInfo> GetHandlersForEvent<T>() where T : IntegrationEvent;
IEnumerable<SubscriptionInfo> GetHandlersForEvent(string eventName);
string GetEventKey<T>();
}
}

@ -1,23 +1,20 @@
using System.Threading.Tasks;
namespace Tiobon.Core.EventBus;
namespace Tiobon.Core.EventBus
{
/// <summary>
/// 集成事件处理程序
/// 泛型接口
/// </summary>
/// <typeparam name="TIntegrationEvent"></typeparam>
public interface IIntegrationEventHandler<in TIntegrationEvent> : IIntegrationEventHandler
/// <summary>
/// 集成事件处理程序
/// 泛型接口
/// </summary>
/// <typeparam name="TIntegrationEvent"></typeparam>
public interface IIntegrationEventHandler<in TIntegrationEvent> : IIntegrationEventHandler
where TIntegrationEvent : IntegrationEvent
{
{
Task Handle(TIntegrationEvent @event);
}
}
/// <summary>
/// 集成事件处理程序
/// 基 接口
/// </summary>
public interface IIntegrationEventHandler
{
}
/// <summary>
/// 集成事件处理程序
/// 基 接口
/// </summary>
public interface IIntegrationEventHandler
{
}

@ -1,14 +1,13 @@
using Newtonsoft.Json;
using System;
namespace Tiobon.Core.EventBus
namespace Tiobon.Core.EventBus;
/// <summary>
/// 事件模型
/// 基类
/// </summary>
public class IntegrationEvent
{
/// <summary>
/// 事件模型
/// 基类
/// </summary>
public class IntegrationEvent
{
public IntegrationEvent()
{
Id = Guid.NewGuid();
@ -27,5 +26,4 @@ namespace Tiobon.Core.EventBus
[JsonProperty]
public DateTime CreationDate { get; private set; }
}
}

@ -11,13 +11,13 @@ using System.Net.Sockets;
using System.Text;
using Tiobon.Core.Extensions;
namespace Tiobon.Core.EventBus
namespace Tiobon.Core.EventBus;
/// <summary>
/// 基于RabbitMQ的事件总线
/// </summary>
public class EventBusRabbitMQ : IEventBus, IDisposable
{
/// <summary>
/// 基于RabbitMQ的事件总线
/// </summary>
public class EventBusRabbitMQ : IEventBus, IDisposable
{
const string BROKER_NAME = "Tioboncore_event_bus";
private readonly IRabbitMQPersistentConnection _persistentConnection;
@ -347,5 +347,4 @@ namespace Tiobon.Core.EventBus
_logger.LogWarning("No subscription for RabbitMQ event: {EventName}", eventName);
}
}
}
}

@ -1,15 +1,14 @@
using RabbitMQ.Client;
using System;
namespace Tiobon.Core.EventBus
{
/// <summary>
/// RabbitMQ持久连接
/// 接口
/// </summary>
public interface IRabbitMQPersistentConnection
namespace Tiobon.Core.EventBus;
/// <summary>
/// RabbitMQ持久连接
/// 接口
/// </summary>
public interface IRabbitMQPersistentConnection
: IDisposable
{
{
/// <summary>
/// 是否已经连接
/// </summary>
@ -40,5 +39,4 @@ namespace Tiobon.Core.EventBus
/// </summary>
/// <param name="queueName"></param>
void StartConsuming(string queueName);
}
}

@ -4,19 +4,17 @@ using Polly.Retry;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using RabbitMQ.Client.Exceptions;
using System;
using System.IO;
using System.Net.Sockets;
using System.Text;
namespace Tiobon.Core.EventBus
{
/// <summary>
/// RabbitMQ持久连接
/// </summary>
public class RabbitMQPersistentConnection
namespace Tiobon.Core.EventBus;
/// <summary>
/// RabbitMQ持久连接
/// </summary>
public class RabbitMQPersistentConnection
: IRabbitMQPersistentConnection
{
{
private readonly IConnectionFactory _connectionFactory;
private readonly ILogger<RabbitMQPersistentConnection> _logger;
private readonly int _retryCount;
@ -207,5 +205,4 @@ namespace Tiobon.Core.EventBus
Console.WriteLine("Consuming messages...");
}
}
}

@ -3,12 +3,12 @@ using Microsoft.AspNetCore.Mvc;
using Tiobon.Core.HttpContextUser;
using Tiobon.Core.Model.Entity;
namespace Tiobon.Core.Gateway.Controllers
namespace Tiobon.Core.Gateway.Controllers;
[Authorize(AuthenticationSchemes = Permissions.GWName)]
[Route("/gateway/[controller]/[action]")]
public class UserController : ControllerBase
{
[Authorize(AuthenticationSchemes = Permissions.GWName)]
[Route("/gateway/[controller]/[action]")]
public class UserController : ControllerBase
{
private readonly IUser _user;
public UserController(IUser user)
@ -31,10 +31,9 @@ namespace Tiobon.Core.Gateway.Controllers
).ToList()
};
}
}
public class ClaimDto
{
}
public class ClaimDto
{
public string Type { get; set; }
public string Value { get; set; }
}
}

@ -1,17 +1,13 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
namespace Tiobon.Core.Gateway.Extensions
namespace Tiobon.Core.Gateway.Extensions;
public class CustomAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
{
public class CustomAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
{
public CustomAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options,
ILoggerFactory logger,
UrlEncoder encoder,
@ -49,5 +45,4 @@ namespace Tiobon.Core.Gateway.Extensions
return token;
}
}
}

@ -1,17 +1,13 @@
using Tiobon.Core.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.DependencyInjection;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
//using Ocelot.Provider.Nacos;
using Ocelot.Provider.Polly;
using System;
using System.Threading.Tasks;
using Tiobon.Core.Extensions;
namespace Tiobon.Core.Gateway.Extensions
namespace Tiobon.Core.Gateway.Extensions;
public static class CustomOcelotSetup
{
public static class CustomOcelotSetup
{
public static void AddCustomOcelotSetup(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
@ -30,5 +26,4 @@ namespace Tiobon.Core.Gateway.Extensions
return app;
}
}
}

@ -1,16 +1,12 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Tiobon.Core.Gateway.Extensions
namespace Tiobon.Core.Gateway.Extensions;
public class CustomResultHandler : DelegatingHandler
{
public class CustomResultHandler : DelegatingHandler
{
JsonSerializerSettings _camelSettings = new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() };
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
@ -58,5 +54,4 @@ namespace Tiobon.Core.Gateway.Extensions
return response;
}
}
}

@ -1,20 +1,10 @@
using Tiobon.Core.Common;
using Tiobon.Core.Extensions.Middlewares;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.Filters;
using Swashbuckle.AspNetCore.SwaggerUI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using static Tiobon.Core.Extensions.CustomApiVersion;
namespace Tiobon.Core.Gateway.Extensions
namespace Tiobon.Core.Gateway.Extensions;
public static class CustomSwaggerSetup
{
public static class CustomSwaggerSetup
{
public static void AddCustomSwaggerSetup(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
@ -77,5 +67,4 @@ namespace Tiobon.Core.Gateway.Extensions
}
}
}

@ -4,15 +4,15 @@ using System.Text.RegularExpressions;
using Tiobon.Core.Caches;
using Tiobon.Core.Helper;
namespace Tiobon.Core.AuthHelper
namespace Tiobon.Core.AuthHelper;
/// <summary>
/// 中间件
/// 原做为自定义授权中间件
/// 先做检查 header token的使用
/// </summary>
public class CustomJwtTokenAuthMiddleware
{
/// <summary>
/// 中间件
/// 原做为自定义授权中间件
/// 先做检查 header token的使用
/// </summary>
public class CustomJwtTokenAuthMiddleware
{
private readonly ICaching _cache;
@ -27,7 +27,7 @@ namespace Tiobon.Core.AuthHelper
private readonly RequestDelegate _next;
public CustomJwtTokenAuthMiddleware(RequestDelegate next, IAuthenticationSchemeProvider schemes, AppSettings appset,ICaching cache)
public CustomJwtTokenAuthMiddleware(RequestDelegate next, IAuthenticationSchemeProvider schemes, AppSettings appset, ICaching cache)
{
_cache = cache;
_next = next;
@ -50,12 +50,12 @@ namespace Tiobon.Core.AuthHelper
return;
}
//黑名单验证
if(CheckBlackList(questUrl))
if (CheckBlackList(questUrl))
{
return;
}
List<PermissionItem> Permissions= new();
List<PermissionItem> Permissions = new();
httpContext.Features.Set<IAuthenticationFeature>(new AuthenticationFeature
{
@ -97,20 +97,20 @@ namespace Tiobon.Core.AuthHelper
if (currentUserRoles.Count <= 0 || !isMatchRole)
{
await httpContext.Cof_SendResponse(HttpStatusCode.ServiceUnavailable, "未授权此资源");
return ;
return;
}
}
else
{
await httpContext.Cof_SendResponse(HttpStatusCode.Unauthorized, "请重新登录");
return ;
return;
}
}
else
{
await httpContext.Cof_SendResponse(HttpStatusCode.Unauthorized, "系统鉴权出错");
return ;
return;
}
await _next.Invoke(httpContext);
}
@ -175,11 +175,10 @@ namespace Tiobon.Core.AuthHelper
return false;
}
}
}
public class Urlobj
{
public class Urlobj
{
public string url { get; set; }
}
}

@ -1,11 +1,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
namespace Tiobon.Core.AdminMvc;
namespace Tiobon.Core.AdminMvc
public class Program
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
@ -24,5 +20,4 @@ namespace Tiobon.Core.AdminMvc
{
webBuilder.UseStartup<Startup>().UseUrls("http://*:9000");
});
}
}

@ -1,7 +0,0 @@
namespace Tiobon.Core.Model;
public enum HttpEnum
{
Common,
LocalHost
}

@ -1,16 +0,0 @@
namespace Tiobon.Core.Model.ViewModels;
public class EnumDemoDto
{
public int Id { get; set; }
/// <summary>
/// Type Description balabala
/// </summary>
public EnumType Type { get; set; }
}
public enum EnumType
{
foo, bar, baz
}

@ -1,22 +0,0 @@
namespace Tiobon.Core.Model.ViewModels;
/// <summary>
/// 留言排名展示类
/// </summary>
public class TopgbViewModels
{
/// <summary>博客ID
///
/// </summary>
public int? TiobonId { get; set; }
/// <summary>
/// 评论数量
/// </summary>
public int counts { get; set; }
/// <summary>博客标题
///
/// </summary>
public string btitle { get; set; }
}

@ -1,18 +0,0 @@
using Microsoft.AspNetCore.Http;
namespace Tiobon.Core.Model.ViewModels;
public class UploadFileDto
{
//多文件
[Required]
public IFormFileCollection file { get; set; }
//单文件
//public IFormFile File { get; set; }
//其他数据
public string Foo { get; set; }
}

@ -1,2 +1,7 @@
global using Tiobon.Core.IServices;
global using Quartz;
global using Microsoft.Extensions.Logging;
global using Tiobon.Core.Model.Entity;
global using Tiobon.Core.Model.Models;
global using Tiobon.Core.Model.ViewModels;
global using Tiobon.Core.Helper;

@ -1,9 +1,4 @@
using Tiobon.Core.Model;
using Tiobon.Core.Model.Entity;
using Tiobon.Core.Model.Models;
using Tiobon.Core.Model.ViewModels;
namespace Tiobon.Core.Tasks;
namespace Tiobon.Core.Tasks;
/// <summary>
/// 服务调度接口

@ -1,7 +1,4 @@
using Tiobon.Core.Helper;
using Tiobon.Core.Model.Models;
namespace Tiobon.Core.Tasks;
namespace Tiobon.Core.Tasks;
public class JobBase
{

@ -1,6 +1,4 @@
using Microsoft.Extensions.Logging;
/// <summary>
/// <summary>
/// 这里要注意下,命名空间和程序集是一样的,不然反射不到(任务类要去JobSetup添加注入)
/// </summary>
namespace Tiobon.Core.Tasks;

@ -1,6 +1,4 @@
using Microsoft.Extensions.Logging;
/// <summary>
/// <summary>
/// 这里要注意下,命名空间和程序集是一样的,不然反射不到(任务类要去JobSetup添加注入)
/// </summary>
namespace Tiobon.Core.Tasks;

@ -1,5 +1,4 @@
using Microsoft.Extensions.Logging;

/// <summary>
/// 这里要注意下,命名空间和程序集是一样的,不然反射不到(任务类要去JobSetup添加注入)
/// </summary>

@ -1,6 +1,4 @@
using Microsoft.Extensions.Logging;
/// <summary>
/// <summary>
/// 这里要注意下,命名空间和程序集是一样的,不然反射不到(任务类要去JobSetup添加注入)
/// </summary>
namespace Tiobon.Core.Tasks;

@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Hosting;
using System.Text;
using Tiobon.Core.LogHelper;
using Tiobon.Core.Model.Models;
/// <summary>
/// 这里要注意下,命名空间和程序集是一样的,不然反射不到

@ -1,6 +1,4 @@
using Microsoft.Extensions.Logging;
using Tiobon.Core.Helper;

/// <summary>
/// 这里要注意下,命名空间和程序集是一样的,不然反射不到(任务类要去JobSetup添加注入)
/// </summary>

@ -4,9 +4,6 @@ using Quartz.Spi;
using System.Collections.Specialized;
using System.Reflection;
using Tiobon.Core.DB.Dapper;
using Tiobon.Core.Model.Entity;
using Tiobon.Core.Model.Models;
using Tiobon.Core.Model.ViewModels;
namespace Tiobon.Core.Tasks;

@ -1,12 +1,11 @@
using System.Data;
using Tiobon.Core.DB.Dapper;
using Tiobon.Core.Model.Models;
using Xunit;
namespace Tiobon.Core.Tests.Common_Test
namespace Tiobon.Core.Tests.Common_Test;
public class DbAccess_Should
{
public class DbAccess_Should
{
[Fact]
public async void Test()
@ -23,5 +22,4 @@ namespace Tiobon.Core.Tests.Common_Test
}
}
}

@ -1,10 +1,10 @@
using Tiobon.Core.Helper;
using Xunit;
namespace Tiobon.Core.Tests.Common_Test
namespace Tiobon.Core.Tests.Common_Test;
public class HttpHelper_Should
{
public class HttpHelper_Should
{
[Fact]
public async void Get_Async_Test()
@ -22,5 +22,4 @@ namespace Tiobon.Core.Tests.Common_Test
Assert.NotNull(responseString);
}
}
}

@ -1,12 +1,10 @@
using Tiobon.Core.Common.Helper;
using Tiobon.Core.Common.Helper.SM;
using System;
using Tiobon.Core.Common.Helper.SM;
using Xunit;
namespace Tiobon.Core.Tests.Common_Test
namespace Tiobon.Core.Tests.Common_Test;
public class SM4Helper_Should
{
public class SM4Helper_Should
{
[Fact]
public void Encrypt_ECB_Test()
@ -38,5 +36,4 @@ namespace Tiobon.Core.Tests.Common_Test
Assert.Equal("老张的哲学", plainText);
}
}
}

@ -5,10 +5,10 @@ using Autofac;
using Tiobon.Core.AuthHelper;
using Microsoft.Extensions.Logging;
namespace Tiobon.Core.Tests
namespace Tiobon.Core.Tests;
public class LoginController_Should
{
public class LoginController_Should
{
LoginController loginController;
private readonly IGhrs_UserServices _ghrs_UserServices;
@ -74,5 +74,4 @@ namespace Tiobon.Core.Tests
Assert.NotNull(res);
}
}
}

@ -19,10 +19,10 @@ using Tiobon.Core.IRepository.Base;
using Tiobon.Core.Repository.Base;
using Tiobon.Core.Repository.MongoRepository;
namespace Tiobon.Core.Tests
namespace Tiobon.Core.Tests;
public class DI_Test
{
public class DI_Test
{
/// <summary>
/// 连接字符串
/// Tiobon.Core
@ -139,5 +139,4 @@ namespace Tiobon.Core.Tests
return ApplicationContainer;
}
}
}

@ -1,9 +1,9 @@
using Xunit;
namespace Tiobon.Core.Tests
namespace Tiobon.Core.Tests;
public class Redis_Should
{
public class Redis_Should
{
DI_Test dI_Test = new DI_Test();
public Redis_Should()
@ -22,5 +22,4 @@ namespace Tiobon.Core.Tests
//Assert.Null(redisTiobonCache);
}
}
}

@ -1,18 +1,14 @@
using Tiobon.Core.Model.Models;
using Xunit;
using System;
using System.Linq;
using Autofac;
using Tiobon.Core.IRepository.Base;
using Tiobon.Core.Repository.MongoRepository;
using MongoDB.Bson.Serialization.Attributes;
using Autofac;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using Tiobon.Core.Repository.MongoRepository;
using Xunit;
namespace Tiobon.Core.Tests;
namespace Tiobon.Core.Tests
public class MongoRepository_Base_Should
{
public class MongoRepository_Base_Should
{
public class MongoTest
{
[BsonId]
@ -56,5 +52,4 @@ namespace Tiobon.Core.Tests
Assert.NotNull(data);
}
}
}

@ -1,14 +1,12 @@
using Tiobon.Core.Model.Models;
using Xunit;
using System;
using System.Linq;
using Autofac;
using Autofac;
using Tiobon.Core.IRepository.Base;
using Tiobon.Core.Model.Models;
using Xunit;
namespace Tiobon.Core.Tests;
namespace Tiobon.Core.Tests
public class Repository_Base_Should
{
public class Repository_Base_Should
{
private IBaseRepository<TiobonArticle> baseRepository;
DI_Test dI_Test = new DI_Test();
@ -77,5 +75,4 @@ namespace Tiobon.Core.Tests
Assert.True(IsDel);
}
}
}

@ -8,16 +8,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt
.dockerignore = .dockerignore
.editorconfig = .editorconfig
.gitignore = .gitignore
Blog.Core.Build.bat = Blog.Core.Build.bat
Blog.Core.Publish.bat = Blog.Core.Publish.bat
Blog.Core.Publish.Docker.Jenkins.sh = Blog.Core.Publish.Docker.Jenkins.sh
Blog.Core.Publish.Docker.sh = Blog.Core.Publish.Docker.sh
Blog.Core.Publish.Linux.sh = Blog.Core.Publish.Linux.sh
codecov.yml = codecov.yml
build\common.targets = build\common.targets
CreateYourProject.bat = CreateYourProject.bat
DockerBuild.bat = DockerBuild.bat
Dockerfile = Dockerfile
nuget.config = nuget.config
README.md = README.md
EndProjectSection

@ -42792,11 +42792,6 @@
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.EnumDemoDto.Type">
<summary>
Type Description balabala
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.Extend.CertificateDesignerData.bgColor">
<summary>
bgColor
@ -43662,26 +43657,6 @@
用来测试 RestSharp Post 请求
</summary>
</member>
<member name="T:Tiobon.Core.Model.ViewModels.TopgbViewModels">
<summary>
留言排名展示类
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.TopgbViewModels.TiobonId">
<summary>博客ID
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.TopgbViewModels.counts">
<summary>
评论数量
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.TopgbViewModels.btitle">
<summary>博客标题
</summary>
</member>
<member name="P:Tiobon.Core.Model.CustomFieldView.GroupName">
<summary>
分组

Loading…
Cancel
Save