diff --git a/Lib/Tiobon.Core.Base.dll b/Lib/Tiobon.Core.Base.dll
index 191125fc..a7526e1d 100644
Binary files a/Lib/Tiobon.Core.Base.dll and b/Lib/Tiobon.Core.Base.dll differ
diff --git a/Lib/Tiobon.Core.dll b/Lib/Tiobon.Core.dll
index d8fad807..630019ab 100644
Binary files a/Lib/Tiobon.Core.dll and b/Lib/Tiobon.Core.dll differ
diff --git a/Lib/Tiobon.Core.xml b/Lib/Tiobon.Core.xml
index b7329e44..76878d99 100644
--- a/Lib/Tiobon.Core.xml
+++ b/Lib/Tiobon.Core.xml
@@ -1077,6 +1077,17 @@
以嵌套事务方式执行
+
+
+ 配置实体软删除过滤器
+ 统一过滤 软删除 无需自己写条件
+
+
+
+
+ 配置租户
+
+
Sql插入类
@@ -1258,6 +1269,26 @@
S盒
+
+
+ 租户隔离方案
+
+
+
+
+ Id隔离
+
+
+
+
+ 库隔离
+
+
+
+
+ 表隔离
+
+
组合继承属性选择表达式树,无拓展参数
@@ -3082,6 +3113,60 @@
Body参数
+
+
+ 状态
+ 中立字段,某些表可使用某些表不使用
+
+
+
+
+ 中立字段,某些表可使用某些表不使用
+ 逻辑上的删除,非物理删除
+ 例如:单据删除并非直接删除
+
+
+
+
+ 中立字段
+ 是否内置数据
+
+
+
+
+ 创建ID
+
+
+
+
+ 创建者
+
+
+
+
+ 创建时间
+
+
+
+
+ 修改ID
+
+
+
+
+ 更新者
+
+
+
+
+ 修改日期
+
+
+
+
+ 数据版本
+
+
表主键
@@ -3301,6 +3386,86 @@
返回信息
+
+
+ ID
+ 泛型主键Tkey
+
+
+
+
+ 租户模型接口
+
+
+
+
+ 租户Id
+
+
+
+
+ 标识 多租户 的业务表
+ 默认设置是多库
+ 公共表无需区分 直接使用主库 各自业务在各自库中
+
+
+
+
+ 系统租户表
+ 根据TenantType 分为两种方案:
+ 1.按租户字段区分
+ 2.按租户分库
+
+
+
+ 注意:
+ 使用租户Id方案,无需配置分库的连接
+
+
+
+
+ 名称
+
+
+
+
+ 租户类型
+
+
+
+
+ 数据库/租户标识 不可重复
+ 使用Id方案,可无需配置
+
+
+
+
+ 主机
+ 使用Id方案,可无需配置
+
+
+
+
+ 数据库类型
+ 使用Id方案,可无需配置
+
+
+
+
+ 数据库连接
+ 使用Id方案,可无需配置
+
+
+
+
+ 状态
+
+
+
+
+ 备注
+
+
添加选项配置
选项类型
diff --git a/Tiobon.Core.Api/Controllers/Systems/DynamicCodeFirstController.cs b/Tiobon.Core.Api/Controllers/Systems/DynamicCodeFirstController.cs
index 0b687812..e4fab457 100644
--- a/Tiobon.Core.Api/Controllers/Systems/DynamicCodeFirstController.cs
+++ b/Tiobon.Core.Api/Controllers/Systems/DynamicCodeFirstController.cs
@@ -1,6 +1,5 @@
using SqlSugar;
using Tiobon.Core.Common.DB.Extension;
-using Tiobon.Core.Model.Models.RootTkey;
namespace Tiobon.Core.Api.Controllers.Systems;
diff --git a/Tiobon.Core.Common/DB/Aop/SqlSugarReuse.cs b/Tiobon.Core.Common/DB/Aop/SqlSugarReuse.cs
deleted file mode 100644
index f7ffa8a0..00000000
--- a/Tiobon.Core.Common/DB/Aop/SqlSugarReuse.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using SqlSugar;
-using Tiobon.Core.DB;
-
-namespace Tiobon.Core.Common.DB.Aop;
-
-public class SqlSugarReuse
-{
- public static void AutoChangeAvailableConnect(SqlSugarClient db)
- {
- if (db == null) return;
- if (db.Ado.IsValidConnection()) return;
- if (!BaseDBConfig.ReuseConfigs.Any()) return;
-
- foreach (var connectionConfig in BaseDBConfig.ReuseConfigs)
- {
- var config = db.CurrentConnectionConfig.ConfigId;
- db.ChangeDatabase(connectionConfig.ConfigId);
- //移除旧的连接,只会在本次上下文移除,因为主库已经故障会导致多库事务无法使用
- db.RemoveConnection(config);
- if (db.Ado.IsValidConnection()) return;
- }
- }
-}
\ No newline at end of file
diff --git a/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs b/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs
deleted file mode 100644
index f63d7e7e..00000000
--- a/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs
+++ /dev/null
@@ -1,180 +0,0 @@
-using Serilog;
-using SqlSugar;
-using StackExchange.Profiling;
-using Tiobon.Core.LogHelper;
-using Tiobon.Core.Model.Entity;
-using Tiobon.Core.Model.Models.RootTkey;
-using Tiobon.Core.Model.Tenants;
-
-namespace Tiobon.Core.Common.DB.Aop;
-
-public static class SqlSugarAop
-{
- public static void OnLogExecuting(ISqlSugarClient sqlSugarScopeProvider, string user, string table, string operate, string sql, SugarParameter[] p, ConnectionConfig config)
- {
- try
- {
- MiniProfiler.Current.CustomTiming($"ConnId:[{config.ConfigId}] SQL:", GetParas(p) + "【SQL语句】:" + sql);
-
- if (!AppSettings.app(new string[] { "AppSettings", "SqlAOP", "Enabled" }).ObjToBool()) return;
-
- if (AppSettings.app(new string[] { "AppSettings", "SqlAOP", "LogToConsole", "Enabled" }).ObjToBool() ||
- AppSettings.app(new string[] { "AppSettings", "SqlAOP", "LogToFile", "Enabled" }).ObjToBool() ||
- AppSettings.app(new string[] { "AppSettings", "SqlAOP", "LogToDB", "Enabled" }).ObjToBool())
- {
- using (LogContextExtension.Create.SqlAopPushProperty(sqlSugarScopeProvider))
- {
- Log.Information("------------------ \r\n User:[{User}] Table:[{Table}] Operate:[{Operate}] ConnId:[{ConnId}]【SQL语句】: \r\n {Sql}",
- user, table, operate, config.ConfigId, UtilMethods.GetNativeSql(sql, p));
- }
- }
- }
- catch (Exception e)
- {
- Log.Error("Error occured OnLogExcuting:" + e);
- }
- }
-
- public static void DataExecuting(object oldValue, DataFilterModel entityInfo)
- {
- if (entityInfo.EntityValue is BasePoco rootEntity)
- if (rootEntity.Id == 0)
- rootEntity.Id = SnowFlakeSingle.Instance.NextId();
-
- if (entityInfo.EntityValue is BaseEntity baseEntity)
- {
- // 新增操作
- if (entityInfo.OperationType == DataFilterType.InsertByObject)
- if (baseEntity.CreateTime == DateTime.MinValue)
- baseEntity.CreateTime = DateTime.Now;
-
- if (entityInfo.OperationType == DataFilterType.UpdateByObject)
- baseEntity.ModifyTime = DateTime.Now;
-
- if (App.User?.ID > 0)
- {
- if (baseEntity is ITenantEntity tenant && App.User.TenantId > 0)
- {
- if (tenant.TenantId == 0)
- tenant.TenantId = App.User.TenantId;
- }
-
- switch (entityInfo.OperationType)
- {
- case DataFilterType.UpdateByObject:
- baseEntity.ModifyId = App.User.ID;
- baseEntity.ModifyBy = App.User.Name;
- break;
- case DataFilterType.InsertByObject:
- if (baseEntity.CreateBy.IsNullOrEmpty() || baseEntity.CreateId is null or <= 0)
- {
- baseEntity.CreateId = App.User.ID;
- baseEntity.CreateBy = App.User.Name;
- }
-
- break;
- }
- }
- }
- else
- {
- //兼容以前的表
- //这里要小心 在AOP里用反射 数据量多性能就会有问题
- //要么都统一使用基类
- //要么考虑老的表没必要兼容老的表
- //
-
- var getType = entityInfo.EntityValue.GetType();
- int userId = Convert.ToInt32(App.User.ID);
- switch (entityInfo.OperationType)
- {
- case DataFilterType.InsertByObject:
- var dyCreateBy = getType.GetProperty("CreateBy");
- var dyCreateTime = getType.GetProperty("CreateTime");
- BasePoco ent = entityInfo.EntityValue as BasePoco;
- if (ent != null && ent.Id == 0)
- ent.Id = SnowFlakeSingle.Instance.NextId();
- if (App.User?.ID > 0 && dyCreateBy != null && dyCreateBy.GetValue(entityInfo.EntityValue) == null)
- {
- try
- {
- dyCreateBy.SetValue(entityInfo.EntityValue, Convert.ToInt32(App.User.ID));
-
- }
- catch (Exception)
- {
- dyCreateBy.SetValue(entityInfo.EntityValue, App.User.ID);
-
- }
- }
-
- if ((dyCreateTime != null && dyCreateTime.GetValue(entityInfo.EntityValue) is null) || (dyCreateTime != null && dyCreateTime.GetValue(entityInfo.EntityValue) != null && (DateTime)dyCreateTime.GetValue(entityInfo.EntityValue) == DateTime.MinValue))
- dyCreateTime.SetValue(entityInfo.EntityValue, DateTime.Now);
-
- break;
- case DataFilterType.UpdateByObject:
- if (entityInfo.PropertyName == "UpdateBy")
- {
- var UpdateBy = getType.GetProperty("UpdateBy");
- if (App.User?.ID > 0 && UpdateBy != null)
- {
- try
- {
- UpdateBy.SetValue(entityInfo.EntityValue, Convert.ToInt32(App.User.ID));
-
- }
- catch (Exception)
- {
- UpdateBy.SetValue(entityInfo.EntityValue, App.User.ID);
-
- }
- }
- }
- else if (entityInfo.PropertyName == "UpdateTime")
- {
-
- var dyModifyTime = getType.GetProperty("UpdateTime");
-
- if (dyModifyTime != null)
- dyModifyTime.SetValue(entityInfo.EntityValue, DateTime.Now);
- }
- //else if (entityInfo.PropertyName == "UpdateTime")
- //{
-
- // HttpRequest request = UserContext.Context.Request;
- // var api = request.Path.ObjToString().TrimEnd('/').ToLower();
- //}
- //else if (entityInfo.PropertyName == "UpdateTime")
- //{
-
- // var dyModifyTime = getType.GetProperty("UpdateTime");
-
- // if (dyModifyTime != null)
- // dyModifyTime.SetValue(entityInfo.EntityValue, DateTime.Now);
- //}
- break;
- }
- }
- }
-
- private static string GetWholeSql(SugarParameter[] paramArr, string sql)
- {
- foreach (var param in paramArr)
- {
- sql = sql.Replace(param.ParameterName, $@"'{param.Value.ObjToString()}'");
- }
-
- return sql;
- }
-
- private static string GetParas(SugarParameter[] pars)
- {
- string key = "【SQL参数】:";
- foreach (var param in pars)
- {
- key += $"{param.ParameterName}:{param.Value}\n";
- }
-
- return key;
- }
-}
diff --git a/Tiobon.Core.Common/DB/AppSecretConfig.cs b/Tiobon.Core.Common/DB/AppSecretConfig.cs
deleted file mode 100644
index 00660835..00000000
--- a/Tiobon.Core.Common/DB/AppSecretConfig.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-namespace Tiobon.Core.Common.AppConfig;
-
-public class AppSecretConfig
-{
- private static string Audience_Secret = AppSettings.app(new string[] { "Audience", "Secret" });
- private static string Audience_Secret_File = AppSettings.app(new string[] { "Audience", "SecretFile" });
-
-
- public static string Audience_Secret_String => InitAudience_Secret();
-
-
- private static string InitAudience_Secret()
- {
- var securityString = DifDBConnOfSecurity(Audience_Secret_File);
- if (!string.IsNullOrEmpty(Audience_Secret_File)&& !string.IsNullOrEmpty(securityString))
- {
- return securityString;
- }
- else
- {
- return Audience_Secret;
- }
-
- }
-
- private static string DifDBConnOfSecurity(params string[] conn)
- {
- foreach (var item in conn)
- {
- try
- {
- if (File.Exists(item))
- {
- return File.ReadAllText(item).Trim();
- }
- }
- catch (System.Exception) { }
- }
-
- return "";
- }
-
-}
diff --git a/Tiobon.Core.Common/DB/EntityUtility.cs b/Tiobon.Core.Common/DB/EntityUtility.cs
deleted file mode 100644
index 755ff4b2..00000000
--- a/Tiobon.Core.Common/DB/EntityUtility.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using SqlSugar;
-using System.Diagnostics;
-using System.Reflection;
-using Tiobon.Core.Extensions;
-using Tiobon.Core.DB;
-using Tiobon.Core.Model;
-
-namespace Tiobon.Core.Common.DB;
-
-public class EntityUtility
-{
- private static readonly Lazy>> _tenantEntitys = new(() =>
- {
- Dictionary> dic = new Dictionary>();
- var assembly = Assembly.Load("Tiobon.Core.Model");
- //扫描 实体
- foreach (var type in assembly.GetTypes().Where(s => s.IsClass && !s.IsAbstract))
- {
- var tenant = type.GetCustomAttribute();
- if (tenant != null)
- {
- dic.TryAdd(tenant.configId.ToString(), type);
- continue;
- }
-
- if (type.IsSubclassOf(typeof(RootEntityTkey<>)))
- {
- dic.TryAdd(MainDb.CurrentDbConnId, type);
- continue;
- }
-
- var table = type.GetCustomAttribute();
- if (table != null)
- {
- dic.TryAdd(MainDb.CurrentDbConnId, type);
- continue;
- }
-
- Debug.Assert(type.Namespace != null, "type.Namespace != null");
- if (type.Namespace.StartsWith("Tiobon.Core.Model.Models"))
- {
- dic.TryAdd(MainDb.CurrentDbConnId, type);
- continue;
- }
- }
-
- return dic;
- });
-
- public static Dictionary> TenantEntitys => _tenantEntitys.Value;
-}
\ No newline at end of file
diff --git a/Tiobon.Core.Common/DB/Extension/DbEntityException.cs b/Tiobon.Core.Common/DB/Extension/DbEntityException.cs
deleted file mode 100644
index ff76ebac..00000000
--- a/Tiobon.Core.Common/DB/Extension/DbEntityException.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using SqlSugar;
-using System.Reflection;
-
-namespace Tiobon.Core.Common.DB.Extension;
-
-public static class DbEntityException
-{
- public static object GetEntityTenant(this Type type)
- {
- var tenant = type.GetCustomAttribute();
- return tenant?.configId;
- }
-}
\ No newline at end of file
diff --git a/Tiobon.Core.Common/DB/Extension/DynamicBuildException.cs b/Tiobon.Core.Common/DB/Extension/DynamicBuildException.cs
deleted file mode 100644
index 15a768cf..00000000
--- a/Tiobon.Core.Common/DB/Extension/DynamicBuildException.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using SqlSugar;
-using System.Reflection;
-using System.Reflection.Emit;
-
-namespace Tiobon.Core.Common.DB.Extension;
-
-public static class DynamicBuildException
-{
- private static List GetEntityAttr(this DynamicBuilder builder)
- {
- FieldInfo fieldInfo = builder.GetType().GetField("entityAttr", BindingFlags.Instance | BindingFlags.NonPublic);
- List entityAttr = (List) fieldInfo.GetValue(builder);
- return entityAttr;
- }
-
- private static CustomAttributeBuilder CreateIndex(SugarIndexAttribute indexAttribute)
- {
- Type type = typeof(SugarIndexAttribute);
- var constructorTypes = new List() {typeof(string)};
- for (int i = 0; i < indexAttribute.IndexFields.Count; i++)
- {
- constructorTypes.AddRange(new[] {typeof(string), typeof(OrderByType)});
- }
-
- constructorTypes.Add(typeof(bool));
-
- var values = new List
-
-
- 状态
- 中立字段,某些表可使用某些表不使用
-
-
-
-
- 中立字段,某些表可使用某些表不使用
- 逻辑上的删除,非物理删除
- 例如:单据删除并非直接删除
-
-
-
-
- 中立字段
- 是否内置数据
-
-
-
-
- 创建ID
-
-
-
-
- 创建者
-
-
-
-
- 创建时间
-
-
-
-
- 修改ID
-
-
-
-
- 更新者
-
-
-
-
- 修改日期
-
-
-
-
- 数据版本
-
-
-
-
- 系统租户表
- 根据TenantType 分为两种方案:
- 1.按租户字段区分
- 2.按租户分库
-
-
-
- 注意:
- 使用租户Id方案,无需配置分库的连接
-
-
-
-
- 名称
-
-
-
-
- 租户类型
-
-
-
-
- 数据库/租户标识 不可重复
- 使用Id方案,可无需配置
-
-
-
-
- 主机
- 使用Id方案,可无需配置
-
-
-
-
- 数据库类型
- 使用Id方案,可无需配置
-
-
-
-
- 数据库连接
- 使用Id方案,可无需配置
-
-
-
-
- 状态
-
-
-
-
- 备注
-
-
用户信息表
@@ -42872,12 +42761,6 @@
api ID
-
-
- ID
- 泛型主键Tkey
-
-
用户信息表
@@ -42967,43 +42850,6 @@
数据库读取类型
-
-
- 租户模型接口
-
-
-
-
- 租户Id
-
-
-
-
- 标识 多租户 的业务表
- 默认设置是多库
- 公共表无需区分 直接使用主库 各自业务在各自库中
-
-
-
-
- 租户隔离方案
-
-
-
-
- Id隔离
-
-
-
-
- 库隔离
-
-
-
-
- 表隔离
-
-
博客信息展示类