|
|
|
@ -56,7 +56,7 @@ public static class SqlsugarInstall
|
|
|
|
|
{
|
|
|
|
|
dbList.Add(item);
|
|
|
|
|
}
|
|
|
|
|
var _serviceProvider =services.GetService<IServiceProvider>();
|
|
|
|
|
var _serviceProvider = services.GetService<IServiceProvider>();
|
|
|
|
|
ICacheService myCache = new SqlSugarCsRedisCache(_serviceProvider);
|
|
|
|
|
var connectConfigList = SqlsugarHelper.ReturnConnectionConfig(dbList, myCache);
|
|
|
|
|
|
|
|
|
@ -97,7 +97,7 @@ public static class SqlsugarInstall
|
|
|
|
|
OrgId = 1288018625843826688
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//全局上下文生效
|
|
|
|
|
SqlSugarScope sqlSugar = new SqlSugarScope(connectConfigList,
|
|
|
|
|
db =>
|
|
|
|
@ -108,7 +108,7 @@ public static class SqlsugarInstall
|
|
|
|
|
foreach (var c in connectConfigList)
|
|
|
|
|
{
|
|
|
|
|
var dbProvider = db.GetConnectionScope((string)c.ConfigId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var user = services.GetService<IUser>();
|
|
|
|
|
//单例参数配置,所有上下文生效
|
|
|
|
@ -178,7 +178,7 @@ public static class SqlsugarInstall
|
|
|
|
|
{
|
|
|
|
|
var tenantId = ((dynamic)entityInfo.EntityValue).TenantId;
|
|
|
|
|
if (tenantId == null || tenantId == 0)
|
|
|
|
|
entityInfo.SetValue(user.GetTenantId());
|
|
|
|
|
entityInfo.SetValue(user.TenantId);
|
|
|
|
|
}
|
|
|
|
|
if (entityInfo.PropertyName == "TenantName")
|
|
|
|
|
{
|
|
|
|
@ -215,7 +215,7 @@ public static class SqlsugarInstall
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (entityInfo.PropertyName == "Deleted")
|
|
|
|
|
entityInfo.SetValue(false);
|
|
|
|
|
entityInfo.SetValue(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新操作
|
|
|
|
@ -234,7 +234,7 @@ public static class SqlsugarInstall
|
|
|
|
|
entityInfo.SetValue(user.UserId);
|
|
|
|
|
if (entityInfo.PropertyName == "DeleteUserName" && user != null)
|
|
|
|
|
entityInfo.SetValue(user.UserName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dbProvider.Aop.OnDiffLogEvent = it =>
|
|
|
|
@ -253,13 +253,13 @@ public static class SqlsugarInstall
|
|
|
|
|
var time = it.Time;
|
|
|
|
|
var diffType = it.DiffType; //enum insert 、update and delete
|
|
|
|
|
|
|
|
|
|
var diffData = SqlSugarDiffUtil.GetDiff(editBeforeData,editAfterData);
|
|
|
|
|
|
|
|
|
|
var diffData = SqlSugarDiffUtil.GetDiff(editBeforeData, editAfterData);
|
|
|
|
|
|
|
|
|
|
var auditData = new SysLogAudit()
|
|
|
|
|
{
|
|
|
|
|
KeyId =Convert.ToInt64(diffData.Id),
|
|
|
|
|
KeyId = Convert.ToInt64(diffData.Id),
|
|
|
|
|
Sql = it.Sql,
|
|
|
|
|
Param = JsonConvert.SerializeObject(it.Parameters),
|
|
|
|
|
Param = JsonConvert.SerializeObject(it.Parameters),
|
|
|
|
|
OperateType = diffType.ToString(),
|
|
|
|
|
OldValue = JsonConvert.SerializeObject(editBeforeData),
|
|
|
|
|
NewValue = JsonConvert.SerializeObject(editAfterData),
|
|
|
|
@ -270,10 +270,10 @@ public static class SqlsugarInstall
|
|
|
|
|
db.GetConnection(1288018625843826680).Insertable(auditData).ExecuteCommand();
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
//全局过滤租户
|
|
|
|
|
dbProvider.QueryFilter.AddTableFilter<ITenantId>(m => m.TenantId == user.GetTenantId());
|
|
|
|
|
dbProvider.QueryFilter.AddTableFilter<ITenantId>(m => m.TenantId == long.Parse(user.TenantId));
|
|
|
|
|
//全局过滤机构Id
|
|
|
|
|
dbProvider.QueryFilter.AddTableFilter<IOrgId>(m => m.OrgId == user.OrgId);
|
|
|
|
|
//全局软删除过滤
|
|
|
|
|