feat:全基础流程跑通
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using System.Linq.Expressions;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Data.Filters;
|
||||
|
||||
namespace Yi.Framework.Infrastructure.Sqlsugar.Filters
|
||||
{
|
||||
public class SqlsugarDataFilter : IDataFilter
|
||||
{
|
||||
private ISqlSugarClient _Db { get; set; }
|
||||
public SqlsugarDataFilter(ISqlSugarClient sqlSugarClient)
|
||||
{
|
||||
_Db = sqlSugarClient;
|
||||
}
|
||||
public void AddFilter<TFilter>(Expression<Func<TFilter, bool>> expression) where TFilter : class
|
||||
{
|
||||
_Db.QueryFilter.AddTableFilter(expression);
|
||||
}
|
||||
|
||||
public IDisposable Disable<TFilter>() where TFilter : class
|
||||
{
|
||||
_Db.QueryFilter.ClearAndBackup<TFilter>();
|
||||
return this;
|
||||
}
|
||||
|
||||
public IDisposable Enable<TFilter>() where TFilter : class
|
||||
{
|
||||
throw new NotImplementedException("暂时没有单独还原过滤器的方式");
|
||||
}
|
||||
|
||||
public bool IsEnabled<TFilter>() where TFilter : class
|
||||
{
|
||||
throw new NotImplementedException("暂时没有判断过滤器的方式");
|
||||
}
|
||||
|
||||
public void RemoveFilter<TFilter>() where TFilter : class
|
||||
{
|
||||
_Db.QueryFilter.Clear<TFilter>();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_Db.QueryFilter.Restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Infrastructure.CurrentUsers;
|
||||
using Yi.Framework.Infrastructure.Data.Auditing;
|
||||
using Yi.Framework.Infrastructure.Data.Entities;
|
||||
|
||||
namespace Yi.Framework.Infrastructure.Sqlsugar
|
||||
{
|
||||
@@ -83,45 +85,45 @@ namespace Yi.Framework.Infrastructure.Sqlsugar
|
||||
db.Aop.DataExecuting = (oldValue, entityInfo) =>
|
||||
{
|
||||
|
||||
//switch (entityInfo.OperationType)
|
||||
//{
|
||||
// case DataFilterType.UpdateByObject:
|
||||
switch (entityInfo.OperationType)
|
||||
{
|
||||
case DataFilterType.UpdateByObject:
|
||||
|
||||
// if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModificationTime)))
|
||||
// {
|
||||
// entityInfo.SetValue(DateTime.Now);
|
||||
// }
|
||||
// if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModifierId)))
|
||||
// {
|
||||
// if (_currentUser != null)
|
||||
// {
|
||||
// entityInfo.SetValue(_currentUser.Id);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case DataFilterType.InsertByObject:
|
||||
// if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreationTime)))
|
||||
// {
|
||||
// entityInfo.SetValue(DateTime.Now);
|
||||
// }
|
||||
// if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreatorId)))
|
||||
// {
|
||||
// if (_currentUser != null)
|
||||
// {
|
||||
// entityInfo.SetValue(_currentUser.Id);
|
||||
// }
|
||||
// }
|
||||
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModificationTime)))
|
||||
{
|
||||
entityInfo.SetValue(DateTime.Now);
|
||||
}
|
||||
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModifierId)))
|
||||
{
|
||||
if (_currentUser != null)
|
||||
{
|
||||
entityInfo.SetValue(_currentUser.Id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DataFilterType.InsertByObject:
|
||||
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreationTime)))
|
||||
{
|
||||
entityInfo.SetValue(DateTime.Now);
|
||||
}
|
||||
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreatorId)))
|
||||
{
|
||||
if (_currentUser != null)
|
||||
{
|
||||
entityInfo.SetValue(_currentUser.Id);
|
||||
}
|
||||
}
|
||||
|
||||
// //插入时,需要租户id,先预留
|
||||
// if (entityInfo.PropertyName.Equals(nameof(IMultiTenant.TenantId)))
|
||||
// {
|
||||
// //if (this.CurrentTenant is not null)
|
||||
// //{
|
||||
// // entityInfo.SetValue(this.CurrentTenant.Id);
|
||||
// //}
|
||||
// }
|
||||
// break;
|
||||
//}
|
||||
//插入时,需要租户id,先预留
|
||||
if (entityInfo.PropertyName.Equals(nameof(IMultiTenant.TenantId)))
|
||||
{
|
||||
//if (this.CurrentTenant is not null)
|
||||
//{
|
||||
// entityInfo.SetValue(this.CurrentTenant.Id);
|
||||
//}
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
db.Aop.OnLogExecuting = (s, p) =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user