😎1、去掉基类时间多余特性 2、修复创建时间默认逻辑
This commit is contained in:
parent
33c7f7c3bd
commit
deebfa5896
@ -38,7 +38,7 @@
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.166" />
|
||||
<PackageReference Include="SSH.NET" Version="2024.1.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.3" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1048" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1049" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -27,13 +27,13 @@ public abstract class EntityBase : EntityBaseId, IDeletedFilter
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "创建时间", IsNullable = true, IsOnlyIgnoreUpdate = true, InsertServerTime = true)]
|
||||
[SugarColumn(ColumnDescription = "创建时间", IsNullable = true, IsOnlyIgnoreUpdate = true)]
|
||||
public virtual DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "更新时间", IsOnlyIgnoreInsert = true, UpdateServerTime = true)]
|
||||
[SugarColumn(ColumnDescription = "更新时间", IsOnlyIgnoreInsert = true)]
|
||||
public virtual DateTime? UpdateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -172,9 +172,11 @@ public static class SqlSugarSetup
|
||||
entityInfo.SetValue(YitIdHelper.NextId());
|
||||
}
|
||||
// 若创建时间为空则赋值当前时间
|
||||
else if (entityInfo.PropertyName == nameof(EntityBase.CreateTime) && entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue) == null)
|
||||
else if (entityInfo.PropertyName == nameof(EntityBase.CreateTime))
|
||||
{
|
||||
entityInfo.SetValue(DateTime.UtcNow);
|
||||
var createTime = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue);
|
||||
if (createTime.Equals(DateTime.Parse("0001/1/1 0:00:00")))
|
||||
entityInfo.SetValue(DateTime.UtcNow);
|
||||
}
|
||||
// 若当前用户非空(web线程时)
|
||||
if (App.User != null)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user