diff --git a/BPA.SaaS.BizLog.Api.sln b/BPA.SaaS.BizLog.Api.sln
index 99205e0..e7e24e0 100644
--- a/BPA.SaaS.BizLog.Api.sln
+++ b/BPA.SaaS.BizLog.Api.sln
@@ -43,11 +43,6 @@ ProjectSection(SolutionItems) = preProject
src\nuget.config = src\nuget.config
EndProjectSection
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".pack", ".pack", "{5CE18647-CEFB-483A-B384-99D4FB47DA29}"
-ProjectSection(SolutionItems) = preProject
-src\.pack\pack.sh = src\.pack\pack.sh
-EndProjectSection
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -114,9 +109,8 @@ Global
{4F48E97A-2DC3-4720-98F7-25935258D79C} = {0265A6CF-0D40-4A59-B6DF-2F25099DA95B}
{CFDFD099-D03F-441A-A3CD-28C7320742C5} = {71207855-D2BE-48D3-86AD-D1E5BC389E64}
{FBE0E584-BF1F-498D-BBFC-66B790EAFC7C} = {FEDACFF6-C6AF-4C34-9575-9456856AEACC}
- {5CE18647-CEFB-483A-B384-99D4FB47DA29} = {0265A6CF-0D40-4A59-B6DF-2F25099DA95B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7A177DC6-A13E-4628-97F6-40DC7573252A}
EndGlobalSection
-EndGlobal
\ No newline at end of file
+EndGlobal
diff --git a/src/BPA.SaaS.BizLog.Api.Bootstrap/BPA.SaaS.BizLog.Api.Bootstrap.csproj b/src/BPA.SaaS.BizLog.Api.Bootstrap/BPA.SaaS.BizLog.Api.Bootstrap.csproj
index ac94829..6825b5c 100644
--- a/src/BPA.SaaS.BizLog.Api.Bootstrap/BPA.SaaS.BizLog.Api.Bootstrap.csproj
+++ b/src/BPA.SaaS.BizLog.Api.Bootstrap/BPA.SaaS.BizLog.Api.Bootstrap.csproj
@@ -1,22 +1,23 @@
-
+
-
- net6.0
- enable
- enable
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupBootstrap.cs b/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupBootstrap.cs
new file mode 100644
index 0000000..13e861e
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupBootstrap.cs
@@ -0,0 +1,132 @@
+using System.Net.NetworkInformation;
+using System.Net.Sockets;
+using System.Text;
+using Autofac;
+using BPA.Component.ApolloClient;
+using BPA.Component.Extensions;
+using BPA.Component.LogClient.Extensions;
+using BPA.Component.SDKCommon;
+using BPA.Component.WebApiExtensions.Extensions;
+using BPA.SaaS.BizLog.Api.IService.Queue;
+using BPA.SaaS.BizLog.Api.Model;
+using BPA.SaaS.BizLog.Api.Repository;
+using BPA.SaaS.BizLog.Api.Service.Queue;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Diagnostics.HealthChecks;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.OpenApi.Models;
+using IPAddress = System.Net.IPAddress;
+
+namespace BPA.SaaS.BizLog.Api.Bootstrap;
+
+///
+/// 启动配置
+///
+public static class SetupBootstrap
+{
+ private static IConfiguration _configuration;
+
+ ///
+ /// 添加配置中心
+ ///
+ ///
+ public static IConfiguration SetupConfiguration(this IConfiguration configuration)
+ {
+ _configuration = configuration;
+
+ // 初始化化 apollo配置
+ return configuration.AddApolloConfiguration();
+ }
+
+ ///
+ /// DI Inject
+ ///
+ public static IServiceCollection AddBPAMiddlewareServices(this IServiceCollection services, string[] args)
+ {
+ if (services == null) throw new ArgumentNullException(nameof(services));
+
+ services.AddApollo();
+ services.AddScoped();
+ services.AddBPALog();
+ services.AddRedis();
+ services.AddRabbitMQ();
+ services.AddHttpContextAccessor();
+ services.AddControllers(options => { options.AddDefaultMvcOptions(); });
+ services.AddEndpointsApiExplorer();
+ services.AddServiceSDK(_configuration);
+ services.AddHealthChecks();
+ services.AddSwaggerGen(options =>
+ {
+ options.SwaggerDoc("v1", new OpenApiInfo
+ {
+ Title = AppDomain.CurrentDomain.FriendlyName,
+ Description = AppDomain.CurrentDomain.FriendlyName,
+ Version = "v1"
+ });
+ options.CustomSchemaIds(type => type.GetDescribe(true, "BPA.", "BPA.SaaS."));
+ });
+
+ return services;
+ }
+
+ ///
+ /// DI Register
+ ///
+ public static ContainerBuilder SetupConfigureContainer(this ContainerBuilder builder)
+ {
+ // 控制注入实例
+ builder.RegisterType().InstancePerLifetimeScope();
+
+ // 服务层
+ builder.RegisterAssemblyTypes(typeof(BizLogConsumerService).Assembly)
+ .Where(t => t.Name.EndsWith("Service"))
+ .AsImplementedInterfaces();
+
+ // 仓储层
+ builder.RegisterAssemblyTypes(typeof(BizLogRepository).Assembly)
+ .Where(t => t.Name.EndsWith("Repository"))
+ .AsImplementedInterfaces();
+
+ return builder;
+ }
+
+ ///
+ /// pre run
+ ///
+ ///
+ public static void PreHeatRun(this IServiceProvider serviceProvider)
+ {
+ serviceProvider.GetService();
+ serviceProvider.PreHeatRunRedis();
+ serviceProvider.PreHeatRunRabbitMQ();
+ serviceProvider.SetDebug(true);
+ }
+
+ ///
+ /// APP健康检查
+ ///
+ ///
+ public static void UseBpaHealthChecks(this IApplicationBuilder app)
+ {
+ var ips = new List();
+ foreach (var network in NetworkInterface.GetAllNetworkInterfaces())
+ {
+ var ipAddress = network.GetIPProperties()
+ .UnicastAddresses
+ .FirstOrDefault(p => p.Address.AddressFamily == AddressFamily.InterNetwork && !IPAddress.IsLoopback(p.Address))
+ ?.Address.ToString();
+ if (ipAddress == null)
+ continue;
+ ips.Add(new {name = network.Name, ip = ipAddress});
+ }
+
+ var ipsJson = ips.ToJson();
+
+ app.UseHealthChecks("/health", new HealthCheckOptions
+ {
+ ResponseWriter = (httpContext, _) => httpContext.Response.WriteAsync(ipsJson, Encoding.UTF8)
+ });
+ }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupRabbitMqConfig.cs b/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupRabbitMqConfig.cs
new file mode 100644
index 0000000..e48b375
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupRabbitMqConfig.cs
@@ -0,0 +1,45 @@
+using BPA.Common.Infrastructure.BizLogs;
+using BPA.Common.Infrastructure.Queue;
+using BPA.Component.RabbitMQClient.Extensions;
+using BPA.Component.RabbitMQClient.Provider;
+using BPA.SaaS.BizLog.Api.Model;
+using BPA.SaaS.BizLog.Api.Service.Queue;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace BPA.SaaS.BizLog.Api.Bootstrap
+{
+ ///
+ /// RabbitMQ配置
+ ///
+ public static class SetupRabbitMqConfig
+ {
+ ///
+ /// 使用消息队列
+ ///
+ ///
+ ///
+ public static IServiceCollection AddRabbitMQ(this IServiceCollection services)
+ {
+ services.AddRabbitMQProvider(sp => sp.GetService()?.RabbitMqConfig);
+ services.AddRabbitMQConsumer();
+
+ return services;
+ }
+
+ ///
+ /// 预热消息队列
+ ///
+ ///
+ ///
+ public static IServiceProvider PreHeatRunRabbitMQ(this IServiceProvider serviceProvider)
+ {
+ var rabbitMqProvider = serviceProvider.UseRabbitMQProvider();
+
+ var createBizLogQueueConfig = rabbitMqProvider.BuildQueueConfig(MqNameConfig.BizLogQueue, MqNameConfig.BizLogExchange);
+ createBizLogQueueConfig.UseQueue();
+ createBizLogQueueConfig.UseMultipleConsumer(3);
+
+ return serviceProvider;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupRedisConfig.cs b/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupRedisConfig.cs
new file mode 100644
index 0000000..8c552d1
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupRedisConfig.cs
@@ -0,0 +1,48 @@
+using BPA.Component.RedisClient;
+using BPA.SaaS.BizLog.Api.Model;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace BPA.SaaS.BizLog.Api.Bootstrap;
+
+///
+/// redis DI配置
+///
+public static class SetupRedisConfig
+{
+ ///
+ /// 注入redis
+ ///
+ ///
+ public static void AddRedis(this IServiceCollection services)
+ {
+ services.UseRedisSingleton(sp => GetRedisSingletonConnectionString(sp.GetService()!));
+ }
+
+ ///
+ /// 预热redis
+ ///
+ ///
+ public static void PreHeatRunRedis(this IServiceProvider serviceProvider)
+ {
+ var config = serviceProvider.GetService();
+
+ // 添加配置改变时的事件
+ if (config != null)
+ config.OnConfigChange += (stockWebApiConfig, key, _, _, _) =>
+ {
+ if (nameof(stockWebApiConfig.RedisConfig) != key) return;
+ var conStr = GetRedisSingletonConnectionString(stockWebApiConfig);
+
+ //单个redis时 配置变化 触发生成新的实例
+ RedisConfigExtensions.OnRedisSingletonConnectionStringChange(conStr);
+ };
+ }
+
+ ///
+ /// 获取单例 Redis 连接字符串
+ ///
+ ///
+ ///
+ private static string GetRedisSingletonConnectionString(BizLogApiConfig config) =>
+ config.RedisConfig[new Random().Next(0, config.RedisConfig.Count)];
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupServiceSDK.cs b/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupServiceSDK.cs
new file mode 100644
index 0000000..cf6af49
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Bootstrap/SetupServiceSDK.cs
@@ -0,0 +1,47 @@
+using BPA.Component.DTOCommon.Langs;
+using BPA.Component.SDKCommon;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace BPA.SaaS.BizLog.Api.Bootstrap;
+
+///
+/// 其他SDK服务
+///
+public static class SetupServiceSDK
+{
+ ///
+ /// 注入其他SDK
+ ///
+ ///
+ ///
+ public static void AddServiceSDK(this IServiceCollection services, IConfiguration configuration)
+ {
+ // 初始化sdk配置和语言获取
+ services.AddApiSDK(_ => /*sp.GetService()?.HttpContext?.Request.GetLanguage() ??*/ LangType.Zn);
+
+ // 获取当前API启动时定义的环境
+ var environment = configuration.GetValue("ASPNETCORE_ENVIRONMENT");
+
+ // 环境选择
+ switch (environment)
+ {
+ case "Development":
+ // 开发本地连集群
+ // services.AddApiSDK(_ => "http://[IP]:[port]");
+ // 开发集群环境内
+ // services.UseApiSDK(_ => "http://serviceName");
+ break;
+
+
+ case "Production":
+ // services.AddApiSDK(_ => "http://[domainName].com:[80]/[serviceName]");
+ break;
+
+
+ case "Testing":
+ // services.AddApiSDK(_ => "http://test.[domainName].com:[80]/[serviceName]/");
+ break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.DTO/BPA.SaaS.BizLog.Api.DTO.csproj b/src/BPA.SaaS.BizLog.Api.DTO/BPA.SaaS.BizLog.Api.DTO.csproj
index d5a0aaa..a96ed7b 100644
--- a/src/BPA.SaaS.BizLog.Api.DTO/BPA.SaaS.BizLog.Api.DTO.csproj
+++ b/src/BPA.SaaS.BizLog.Api.DTO/BPA.SaaS.BizLog.Api.DTO.csproj
@@ -1,11 +1,14 @@
-
+
net6.0
enable
enable
+ 1.0.1
+
-
+
+
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Entity/BPA.SaaS.BizLog.Api.Entity.csproj b/src/BPA.SaaS.BizLog.Api.Entity/BPA.SaaS.BizLog.Api.Entity.csproj
index 0b15548..f3dd293 100644
--- a/src/BPA.SaaS.BizLog.Api.Entity/BPA.SaaS.BizLog.Api.Entity.csproj
+++ b/src/BPA.SaaS.BizLog.Api.Entity/BPA.SaaS.BizLog.Api.Entity.csproj
@@ -1,11 +1,17 @@
-
+
net6.0
enable
enable
+
+ 1701;1702;8618
+
-
+
+
+
+
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Base.cs b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Base.cs
new file mode 100644
index 0000000..49004df
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Base.cs
@@ -0,0 +1,12 @@
+using BPA.Common.Enums.BizLog;
+using BPA.Component.Extensions;
+
+namespace BPA.SaaS.BizLog.Api.Entity;
+
+public class BPA_BizLog_Base
+{
+ public string BusinessId { get; set; }
+
+ public long Id { get; set; } = BPAUniqueIdBulder.NextLong();
+ public EnumBizLogType EnumBizLogType { get; set; }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Create.cs b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Create.cs
new file mode 100644
index 0000000..f45c2a4
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Create.cs
@@ -0,0 +1,19 @@
+namespace BPA.SaaS.BizLog.Api.Entity;
+
+public class BPA_BizLog_Create : BPA_BizLog_Base
+{
+ ///
+ /// 创建时间
+ ///
+ public DateTime? CreateDateTime { get; set; }
+
+ ///
+ /// 创建人
+ ///
+ public string? CreateBy { get; set; }
+
+ ///
+ /// 创建数据
+ ///
+ public Dictionary? CreateData { get; set; }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Delete.cs b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Delete.cs
new file mode 100644
index 0000000..c7930e8
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Delete.cs
@@ -0,0 +1,14 @@
+namespace BPA.SaaS.BizLog.Api.Entity;
+
+public class BPA_BizLog_Delete : BPA_BizLog_Base
+{
+ ///
+ /// 删除时间
+ ///
+ public DateTime? DeleteDateTime { get; set; }
+
+ ///
+ /// 删除人
+ ///
+ public string? DeleteBy { get; set; }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Execetion_Time.cs b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Execetion_Time.cs
new file mode 100644
index 0000000..c363989
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Execetion_Time.cs
@@ -0,0 +1,43 @@
+using BPA.Component.Extensions;
+
+namespace BPA.SaaS.BizLog.Api.Entity;
+
+public class BPA_BizLog_Execetion_Time
+{
+ public long Id { get; set; } = BPAUniqueIdBulder.NextLong();
+
+ ///
+ /// BusinessIdStr
+ ///
+ public string BusinessIdStr { get; set; }
+
+ ///
+ /// BusinessId
+ ///
+ public long BusinessId { get; set; }
+
+ ///
+ /// TrackId
+ ///
+ public string TrackId { get; set; }
+
+ ///
+ /// TotalSeconds
+ ///
+ public double TotalSeconds { get; set; }
+
+ ///
+ /// FileName
+ ///
+ public string FileName { get; set; }
+
+ ///
+ /// FileLine
+ ///
+ public int FileLine { get; set; }
+
+ ///
+ /// FileMethodName
+ ///
+ public string FirstMethodName { get; set; }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Query.cs b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Query.cs
new file mode 100644
index 0000000..c2ce8a4
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Query.cs
@@ -0,0 +1,24 @@
+namespace BPA.SaaS.BizLog.Api.Entity;
+
+public class BPA_BizLog_Query : BPA_BizLog_Base
+{
+ ///
+ /// 查询
+ ///
+ public DateTime? QueryTime { get; set; }
+
+ ///
+ /// 查询人
+ ///
+ public string? QueryBy { get; set; }
+
+ ///
+ /// 查询条件数据
+ ///
+ public Dictionary? QueryConditionData { get; set; }
+
+ ///
+ /// 查询基础信息
+ ///
+ public Dictionary? QueryConditionBase { get; set; }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Update.cs b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Update.cs
new file mode 100644
index 0000000..a2afea5
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Entity/BPA_BizLog_Update.cs
@@ -0,0 +1,24 @@
+namespace BPA.SaaS.BizLog.Api.Entity;
+
+public class BPA_BizLog_Update : BPA_BizLog_Base
+{
+ ///
+ /// 更新时间
+ ///
+ public DateTime? UpdateDateTime { get; set; }
+
+ ///
+ /// 更新人
+ ///
+ public string? UpdateBy { get; set; }
+
+ ///
+ /// 更新之前的数据
+ ///
+ public Dictionary? UpdateBeforeData { get; set; }
+
+ ///
+ /// 更新之后的数据
+ ///
+ public Dictionary? UpdateAfterData { get; set; }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.IRepository/BPA.SaaS.BizLog.Api.IRepository.csproj b/src/BPA.SaaS.BizLog.Api.IRepository/BPA.SaaS.BizLog.Api.IRepository.csproj
index af17729..d253913 100644
--- a/src/BPA.SaaS.BizLog.Api.IRepository/BPA.SaaS.BizLog.Api.IRepository.csproj
+++ b/src/BPA.SaaS.BizLog.Api.IRepository/BPA.SaaS.BizLog.Api.IRepository.csproj
@@ -1,4 +1,4 @@
-
+
net6.0
@@ -6,7 +6,8 @@
enable
-
+
+
diff --git a/src/BPA.SaaS.BizLog.Api.IRepository/IBizLogRepository.cs b/src/BPA.SaaS.BizLog.Api.IRepository/IBizLogRepository.cs
new file mode 100644
index 0000000..e9ff540
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.IRepository/IBizLogRepository.cs
@@ -0,0 +1,12 @@
+using BPA.Component.MongoClient.Repository;
+using BPA.SaaS.BizLog.Api.Entity;
+
+namespace BPA.SaaS.BizLog.Api.IRepository;
+
+public interface IBizLogRepository : IBaseMongoDbRepository
+{
+ bool AddCreateBizLog(BPA_BizLog_Create bpaBizLogCreate);
+ bool AddUpdateBizLog(BPA_BizLog_Update bpaBizLogUpdate);
+ bool AddDeleteBizLog(BPA_BizLog_Delete bpaBizLogDelete);
+ bool AddQueryBizLog(BPA_BizLog_Query bpaBizLogCreate);
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.IRepository/IBizLogTimeoutRepository.cs b/src/BPA.SaaS.BizLog.Api.IRepository/IBizLogTimeoutRepository.cs
new file mode 100644
index 0000000..1618d36
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.IRepository/IBizLogTimeoutRepository.cs
@@ -0,0 +1,8 @@
+using BPA.SaaS.BizLog.Api.Entity;
+
+namespace BPA.SaaS.BizLog.Api.IRepository;
+
+public interface IBizLogTimeoutRepository
+{
+ bool AddTimeoutBizLog(BPA_BizLog_Execetion_Time bpaBizLogExecetionTime);
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.IService/BPA.SaaS.BizLog.Api.IService.csproj b/src/BPA.SaaS.BizLog.Api.IService/BPA.SaaS.BizLog.Api.IService.csproj
index bbb402f..c1b9ff1 100644
--- a/src/BPA.SaaS.BizLog.Api.IService/BPA.SaaS.BizLog.Api.IService.csproj
+++ b/src/BPA.SaaS.BizLog.Api.IService/BPA.SaaS.BizLog.Api.IService.csproj
@@ -1,4 +1,4 @@
-
+
net6.0
diff --git a/src/BPA.SaaS.BizLog.Api.IService/Queue/IBizLogConsumerService.cs b/src/BPA.SaaS.BizLog.Api.IService/Queue/IBizLogConsumerService.cs
new file mode 100644
index 0000000..63111ca
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.IService/Queue/IBizLogConsumerService.cs
@@ -0,0 +1,6 @@
+namespace BPA.SaaS.BizLog.Api.IService.Queue;
+
+public interface IBizLogConsumerService
+{
+
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Model/BPA.SaaS.BizLog.Api.Model.csproj b/src/BPA.SaaS.BizLog.Api.Model/BPA.SaaS.BizLog.Api.Model.csproj
index f8f853c..b5058cb 100644
--- a/src/BPA.SaaS.BizLog.Api.Model/BPA.SaaS.BizLog.Api.Model.csproj
+++ b/src/BPA.SaaS.BizLog.Api.Model/BPA.SaaS.BizLog.Api.Model.csproj
@@ -1,17 +1,24 @@
-
+
net6.0
enable
enable
+
+ 1701;1702;0618;8618
+
+
+ 1701;1702;0618
+
-
+
+
-
+
-
-
+
+
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Model/BizLogApiConfig.cs b/src/BPA.SaaS.BizLog.Api.Model/BizLogApiConfig.cs
new file mode 100644
index 0000000..8b1885b
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Model/BizLogApiConfig.cs
@@ -0,0 +1,38 @@
+using BPA.Component.ApolloClient;
+using BPA.Component.MongoClient;
+using BPA.Component.RabbitMQClient.Connection;
+using BPA.Component.RabbitMQClient.Options;
+using Com.Ctrip.Framework.Apollo;
+using Microsoft.Extensions.Configuration;
+
+namespace BPA.SaaS.BizLog.Api.Model;
+
+///
+/// BasicWebApiConfig
+///
+// ReSharper disable once ClassNeverInstantiated.Global
+public class BizLogApiConfig : ApolloBPAConfig
+{
+ ///
+ /// RedisConfig
+ ///
+ [AutoWrite]
+ public new List RedisConfig { set; get; }
+
+ ///
+ /// RabbitMQ配置
+ ///
+ [AutoWrite]
+ public new RabbitMqConnectionConfig RabbitMqConfig { get; set; }
+
+ ///
+ /// MongoClient
+ ///
+ [AutoWrite]
+ public MongoConfig BizLogMongoConfig { get; set; }
+
+ public BizLogApiConfig(ApolloConfigurationManager apolloConfigurationManager, IConfiguration configuration) : base(
+ apolloConfigurationManager, configuration)
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Model/BizLogMongoDbClient.cs b/src/BPA.SaaS.BizLog.Api.Model/BizLogMongoDbClient.cs
new file mode 100644
index 0000000..d5f1c6c
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Model/BizLogMongoDbClient.cs
@@ -0,0 +1,15 @@
+using BPA.Component.MongoClient;
+using Microsoft.Extensions.Logging;
+
+namespace BPA.SaaS.BizLog.Api.Model;
+
+public class BizLogMongoDbClient : BaseMongoDbClient
+{
+ private readonly ILogger _logger;
+
+ public BizLogMongoDbClient(BizLogApiConfig config, ILogger logger)
+ : base(config.BizLogMongoConfig, logger)
+ {
+ _logger = logger;
+ }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Repository/BPA.SaaS.BizLog.Api.Repository.csproj b/src/BPA.SaaS.BizLog.Api.Repository/BPA.SaaS.BizLog.Api.Repository.csproj
index c7ce82d..acca37b 100644
--- a/src/BPA.SaaS.BizLog.Api.Repository/BPA.SaaS.BizLog.Api.Repository.csproj
+++ b/src/BPA.SaaS.BizLog.Api.Repository/BPA.SaaS.BizLog.Api.Repository.csproj
@@ -1,4 +1,4 @@
-
+
net6.0
@@ -6,9 +6,12 @@
enable
-
+
+
+
-
+
+
diff --git a/src/BPA.SaaS.BizLog.Api.Repository/BizLogRepository.cs b/src/BPA.SaaS.BizLog.Api.Repository/BizLogRepository.cs
new file mode 100644
index 0000000..fbd082f
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Repository/BizLogRepository.cs
@@ -0,0 +1,21 @@
+using BPA.Component.MongoClient.Repository;
+using BPA.SaaS.BizLog.Api.Entity;
+using BPA.SaaS.BizLog.Api.IRepository;
+using BPA.SaaS.BizLog.Api.Model;
+
+namespace BPA.SaaS.BizLog.Api.Repository;
+
+public class BizLogRepository : BaseMongoDbRepository, IBizLogRepository
+{
+ public BizLogRepository(BizLogMongoDbClient mongoDbClient) : base(mongoDbClient)
+ {
+ }
+
+ public bool AddCreateBizLog(BPA_BizLog_Create bpaBizLogCreate) => Add(bpaBizLogCreate) > 0;
+
+ public bool AddUpdateBizLog(BPA_BizLog_Update bpaBizLogUpdate) => Add(bpaBizLogUpdate) > 0;
+
+ public bool AddDeleteBizLog(BPA_BizLog_Delete bpaBizLogDelete) => Add(bpaBizLogDelete) > 0;
+
+ public bool AddQueryBizLog(BPA_BizLog_Query bpaBizLogCreate) => Add(bpaBizLogCreate) > 0;
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Repository/BizLogTimeoutRepository.cs b/src/BPA.SaaS.BizLog.Api.Repository/BizLogTimeoutRepository.cs
new file mode 100644
index 0000000..6ca65eb
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Repository/BizLogTimeoutRepository.cs
@@ -0,0 +1,15 @@
+using BPA.Component.MongoClient.Repository;
+using BPA.SaaS.BizLog.Api.Entity;
+using BPA.SaaS.BizLog.Api.IRepository;
+using BPA.SaaS.BizLog.Api.Model;
+
+namespace BPA.SaaS.BizLog.Api.Repository;
+
+public class BizLogTimeoutRepository : BaseMongoDbRepository, IBizLogTimeoutRepository
+{
+ public BizLogTimeoutRepository(BizLogMongoDbClient mongoDbClient) : base(mongoDbClient)
+ {
+ }
+
+ public bool AddTimeoutBizLog(BPA_BizLog_Execetion_Time bpaBizLogExecetionTime) => Add(bpaBizLogExecetionTime) > 0;
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.SDK/BPA.SaaS.BizLog.Api.SDK.csproj b/src/BPA.SaaS.BizLog.Api.SDK/BPA.SaaS.BizLog.Api.SDK.csproj
index 6c24557..20f17f8 100644
--- a/src/BPA.SaaS.BizLog.Api.SDK/BPA.SaaS.BizLog.Api.SDK.csproj
+++ b/src/BPA.SaaS.BizLog.Api.SDK/BPA.SaaS.BizLog.Api.SDK.csproj
@@ -1,13 +1,14 @@
-
+
-
- net6.0
- enable
- enable
-
-
-
-
-
-
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.Service/BPA.SaaS.BizLog.Api.Service.csproj b/src/BPA.SaaS.BizLog.Api.Service/BPA.SaaS.BizLog.Api.Service.csproj
index 3306313..26bbfdb 100644
--- a/src/BPA.SaaS.BizLog.Api.Service/BPA.SaaS.BizLog.Api.Service.csproj
+++ b/src/BPA.SaaS.BizLog.Api.Service/BPA.SaaS.BizLog.Api.Service.csproj
@@ -1,4 +1,4 @@
-
+
net6.0
@@ -6,8 +6,14 @@
enable
-
+
+
+
+
+
+
+
diff --git a/src/BPA.SaaS.BizLog.Api.Service/Queue/BizLogConsumerService.cs b/src/BPA.SaaS.BizLog.Api.Service/Queue/BizLogConsumerService.cs
new file mode 100644
index 0000000..f5b6257
--- /dev/null
+++ b/src/BPA.SaaS.BizLog.Api.Service/Queue/BizLogConsumerService.cs
@@ -0,0 +1,94 @@
+using BPA.Common.Enums.Queue;
+using BPA.Component.RabbitMQClient.Base;
+using BPA.SaaS.BizLog.Api.IRepository;
+using BPA.SaaS.BizLog.Api.IService.Queue;
+using Microsoft.Extensions.Logging;
+using BPA.Common.Infrastructure.BizLogs;
+using BPA.Component.Extensions;
+using BPA.SaaS.BizLog.Api.Entity;
+using RabbitMQ.Client.Events;
+
+namespace BPA.SaaS.BizLog.Api.Service.Queue;
+
+///
+/// 业务日志消费者端
+///
+public class BizLogConsumerService : BaseConsumer, IBizLogConsumerService
+{
+ private readonly IServiceProvider _serviceProvider;
+ private readonly ILogger _logger;
+ private readonly IBizLogRepository _bizLogRepository;
+ private readonly IBizLogTimeoutRepository _bizLogTimeoutRepository;
+
+ ///
+ /// 构造方法
+ ///
+ ///
+ ///
+ ///
+ ///
+ public BizLogConsumerService(IServiceProvider serviceProvider, ILogger logger,
+ IBizLogRepository bizLogRepository,
+ IBizLogTimeoutRepository bizLogTimeoutRepository) :
+ base(logger)
+ {
+ _serviceProvider = serviceProvider;
+ _logger = logger;
+ _bizLogRepository = bizLogRepository;
+ _bizLogTimeoutRepository = bizLogTimeoutRepository;
+ }
+
+ ///
+ /// 消费出队
+ ///
+ ///
+ ///
+ ///
+ public override bool Dequeue(BaseBizLogMsgBody msgBody, BasicDeliverEventArgs eventArgs)
+ {
+ _logger.LogDebug("Received message:");
+ _logger.LogDebug($"{msgBody.ToJson()}");
+ _logger.LogDebug(string.Empty);
+
+ return msgBody.EnumMessageType switch
+ {
+ EnumMessageType.BizLog => AddBizLogs(msgBody),
+ EnumMessageType.BizLogExt => AddBizLogExt(msgBody),
+ _ => false
+ };
+ }
+
+ private bool AddBizLogExt(BaseBizLogMsgBody msgBody) =>
+ _bizLogTimeoutRepository.AddTimeoutBizLog(msgBody.MapTo());
+
+ private bool AddBizLogs(BaseBizLogMsgBody msgBody)
+ {
+ if (msgBody.CreateDateTime.HasValue && msgBody.CreateBy != null)
+ {
+ var bpaBizLogCreate = msgBody.MapTo();
+ if (msgBody.EnumBizLogType != null) bpaBizLogCreate.EnumBizLogType = msgBody.EnumBizLogType.Value;
+ return _bizLogRepository.AddCreateBizLog(bpaBizLogCreate);
+ }
+
+ if (msgBody.UpdateDateTime.HasValue && msgBody.UpdateBy != null)
+ {
+ var bpaBizLogCreate = msgBody.MapTo();
+ if (msgBody.EnumBizLogType != null) bpaBizLogCreate.EnumBizLogType = msgBody.EnumBizLogType.Value;
+ return _bizLogRepository.AddUpdateBizLog(bpaBizLogCreate);
+ }
+
+ if (msgBody.DeleteDateTime.HasValue && msgBody.DeleteBy != null)
+ {
+ var bpaBizLogDelete = msgBody.MapTo();
+ if (msgBody.EnumBizLogType != null) bpaBizLogDelete.EnumBizLogType = msgBody.EnumBizLogType.Value;
+ return _bizLogRepository.AddDeleteBizLog(bpaBizLogDelete);
+ }
+
+ if (!msgBody.QueryTime.HasValue || msgBody.QueryBy == null) return false;
+ {
+ var bpaBizLogQuery = msgBody.MapTo();
+ if (msgBody.EnumBizLogType != null) bpaBizLogQuery.EnumBizLogType = msgBody.EnumBizLogType.Value;
+ return _bizLogRepository.AddQueryBizLog(bpaBizLogQuery);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.UnitTest/BPA.SaaS.BizLog.Api.UnitTest.csproj b/src/BPA.SaaS.BizLog.Api.UnitTest/BPA.SaaS.BizLog.Api.UnitTest.csproj
index e1015fb..709dcd6 100644
--- a/src/BPA.SaaS.BizLog.Api.UnitTest/BPA.SaaS.BizLog.Api.UnitTest.csproj
+++ b/src/BPA.SaaS.BizLog.Api.UnitTest/BPA.SaaS.BizLog.Api.UnitTest.csproj
@@ -1,7 +1,20 @@
-
-
-net6.0
-enable
-enable
-
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.WebApi/BPA.SaaS.BizLog.Api.WebApi.csproj b/src/BPA.SaaS.BizLog.Api.WebApi/BPA.SaaS.BizLog.Api.WebApi.csproj
index 7990cd6..0ffc92d 100644
--- a/src/BPA.SaaS.BizLog.Api.WebApi/BPA.SaaS.BizLog.Api.WebApi.csproj
+++ b/src/BPA.SaaS.BizLog.Api.WebApi/BPA.SaaS.BizLog.Api.WebApi.csproj
@@ -1,4 +1,4 @@
-
+
net6.0
diff --git a/src/BPA.SaaS.BizLog.Api.WebApi/Program.cs b/src/BPA.SaaS.BizLog.Api.WebApi/Program.cs
index e2d1548..77a8b1d 100644
--- a/src/BPA.SaaS.BizLog.Api.WebApi/Program.cs
+++ b/src/BPA.SaaS.BizLog.Api.WebApi/Program.cs
@@ -1,8 +1,38 @@
+using Autofac;
+using Autofac.Extensions.DependencyInjection;
+using BPA.Component.WebApiExtensions.Extensions;
+using BPA.SaaS.BizLog.Api.Bootstrap;
+using Microsoft.AspNetCore.Mvc;
+
var builder = WebApplication.CreateBuilder(args);
-builder.Services.AddControllers();
+builder.Configuration.SetupConfiguration();
+
+// DI
+builder.Services.AddBPAMiddlewareServices(args);
+
+// DI config
+builder.Services.Configure(options => { options.AddDefaultBehaviorOptions(); });
+
+// Use Autofac
+builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
+builder.Host.ConfigureContainer(containerBuilder => { containerBuilder.SetupConfigureContainer(); });
var app = builder.Build();
+if (app.Environment.IsDevelopment())
+{
+ app.UseSwagger();
+ app.UseSwaggerUI();
+}
+
+// Use module
+app.UseRouting();
app.UseHttpsRedirection();
app.UseAuthorization();
+app.UseBpaHealthChecks();
app.MapControllers();
-app.Run();
+app.UseGlobalErrorHandler();
+
+// PreRun
+((IApplicationBuilder) app).ApplicationServices.PreHeatRun();
+
+app.Run();
\ No newline at end of file
diff --git a/src/BPA.SaaS.BizLog.Api.WebApi/Properties/launchSettings.json b/src/BPA.SaaS.BizLog.Api.WebApi/Properties/launchSettings.json
index 2127f25..222579f 100644
--- a/src/BPA.SaaS.BizLog.Api.WebApi/Properties/launchSettings.json
+++ b/src/BPA.SaaS.BizLog.Api.WebApi/Properties/launchSettings.json
@@ -1,30 +1,15 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:11305",
- "sslPort": 44315
- }
- },
"profiles": {
- "BPA.SaaS.Stock.Api": {
+ "BPA.SaaS.BizLog.Api": {
"commandName": "Project",
"dotnetRunMessages": true,
- "launchBrowser": true,
- "launchUrl": "weatherforecast",
- "applicationUrl": "https://localhost:7047;http://localhost:5047",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": true,
- "launchUrl": "weatherforecast",
+ "applicationUrl": "http://localhost:5017",
"environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
+ "ASPNETCORE_ENVIRONMENT": "Development",
+ "APOLLO_META_SERVER_URL": "http://10.2.1.21:28080",
+ "APOLLO_COMMON_NAMESPACE": "DEV.Common",
+ "APP_NAME": "BPA.SaaS.BizLog.Api"
}
}
}
diff --git a/src/BPA.SaaS.BizLog.Api.WebApi/appsettings.Development.json b/src/BPA.SaaS.BizLog.Api.WebApi/appsettings.Development.json
deleted file mode 100644
index 0c208ae..0000000
--- a/src/BPA.SaaS.BizLog.Api.WebApi/appsettings.Development.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Warning"
- }
- }
-}
diff --git a/src/BPA.SaaS.BizLog.Api.WebApi/appsettings.json b/src/BPA.SaaS.BizLog.Api.WebApi/appsettings.json
deleted file mode 100644
index 10f68b8..0000000
--- a/src/BPA.SaaS.BizLog.Api.WebApi/appsettings.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Warning"
- }
- },
- "AllowedHosts": "*"
-}