|
|
@ -39,38 +39,25 @@ public static class SqlSugarAop |
|
|
|
public static void DataExecuting(object oldValue, DataFilterModel entityInfo) |
|
|
|
public static void DataExecuting(object oldValue, DataFilterModel entityInfo) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (entityInfo.EntityValue is RootEntityTkey<long> rootEntity) |
|
|
|
if (entityInfo.EntityValue is RootEntityTkey<long> rootEntity) |
|
|
|
{ |
|
|
|
|
|
|
|
if (rootEntity.Id == 0) |
|
|
|
if (rootEntity.Id == 0) |
|
|
|
{ |
|
|
|
|
|
|
|
rootEntity.Id = SnowFlakeSingle.Instance.NextId(); |
|
|
|
rootEntity.Id = SnowFlakeSingle.Instance.NextId(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (entityInfo.EntityValue is BaseEntity baseEntity) |
|
|
|
if (entityInfo.EntityValue is BaseEntity baseEntity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// 新增操作 |
|
|
|
// 新增操作 |
|
|
|
if (entityInfo.OperationType == DataFilterType.InsertByObject) |
|
|
|
if (entityInfo.OperationType == DataFilterType.InsertByObject) |
|
|
|
{ |
|
|
|
|
|
|
|
if (baseEntity.CreateTime == DateTime.MinValue) |
|
|
|
if (baseEntity.CreateTime == DateTime.MinValue) |
|
|
|
{ |
|
|
|
|
|
|
|
baseEntity.CreateTime = DateTime.Now; |
|
|
|
baseEntity.CreateTime = DateTime.Now; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (entityInfo.OperationType == DataFilterType.UpdateByObject) |
|
|
|
if (entityInfo.OperationType == DataFilterType.UpdateByObject) |
|
|
|
{ |
|
|
|
|
|
|
|
baseEntity.ModifyTime = DateTime.Now; |
|
|
|
baseEntity.ModifyTime = DateTime.Now; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (App.User?.ID > 0) |
|
|
|
if (App.User?.ID > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (baseEntity is ITenantEntity tenant && App.User.TenantId > 0) |
|
|
|
if (baseEntity is ITenantEntity tenant && App.User.TenantId > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (tenant.TenantId == 0) |
|
|
|
if (tenant.TenantId == 0) |
|
|
|
{ |
|
|
|
|
|
|
|
tenant.TenantId = App.User.TenantId; |
|
|
|
tenant.TenantId = App.User.TenantId; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (entityInfo.OperationType) |
|
|
|
switch (entityInfo.OperationType) |
|
|
|