From 207e944d02bb3cb55aac39930e27f88e0b8cfd87 Mon Sep 17 00:00:00 2001 From: falcon <9504402@qq.com> Date: Fri, 10 Feb 2023 09:57:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E7=A1=80=E8=A1=A8?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DatabaseDefinitions/SugarBasicTable.cs | 9 ++------- .../DatabaseDefinitions/SugarDbContext.cs | 1 - .../DatabaseDefinitions/SugarTableBase.cs | 18 ++++-------------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/Falcon.SugarApi/DatabaseDefinitions/SugarBasicTable.cs b/Falcon.SugarApi/DatabaseDefinitions/SugarBasicTable.cs index 56e8330..306d456 100644 --- a/Falcon.SugarApi/DatabaseDefinitions/SugarBasicTable.cs +++ b/Falcon.SugarApi/DatabaseDefinitions/SugarBasicTable.cs @@ -5,9 +5,9 @@ using System.ComponentModel.DataAnnotations; namespace Falcon.SugarApi.DatabaseDefinitions { /// - /// 基础表,定义表基础数据结构和构造方法 + /// 基础表.只定义表基础主键和创建时间 /// - public abstract class SugarBasicTable : ICreateNew + public abstract class SugarBasicTable { /// /// 主键 @@ -21,11 +21,6 @@ namespace Falcon.SugarApi.DatabaseDefinitions [SugarColumn(IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间")] public DateTime CreateTime { get; set; } = DateTime.Now; - /// - public void CreateNew(string createBy) { - this.SetNew(); - } - /// /// 将数据设置为新数据。 /// 主要更新Id、创建时间和记录状态 diff --git a/Falcon.SugarApi/DatabaseDefinitions/SugarDbContext.cs b/Falcon.SugarApi/DatabaseDefinitions/SugarDbContext.cs index a8f201e..844b77f 100644 --- a/Falcon.SugarApi/DatabaseDefinitions/SugarDbContext.cs +++ b/Falcon.SugarApi/DatabaseDefinitions/SugarDbContext.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; namespace Falcon.SugarApi.DatabaseDefinitions { diff --git a/Falcon.SugarApi/DatabaseDefinitions/SugarTableBase.cs b/Falcon.SugarApi/DatabaseDefinitions/SugarTableBase.cs index 49b9ad8..d7749aa 100644 --- a/Falcon.SugarApi/DatabaseDefinitions/SugarTableBase.cs +++ b/Falcon.SugarApi/DatabaseDefinitions/SugarTableBase.cs @@ -5,25 +5,16 @@ using System.Reflection; namespace Falcon.SugarApi.DatabaseDefinitions { /// - /// 表基类。一般表应该继承此类 + /// 负载表基类。一般表应该继承此类,包括SugarBasicTable定义,和修改人,行状态,以及一些相关方法等 /// - public abstract class SugarTableBase : ICreateNew, IModify, IDelete + public abstract class SugarTableBase :SugarBasicTable, ICreateNew, IModify, IDelete { - /// - /// 主键 - /// - [SugarColumn(IsPrimaryKey = true, ColumnDescription = "主键")] - public Guid Id { get; set; } = Guid.NewGuid(); /// /// 创建人 /// [SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "首次创建人")] public string? CreateBy { get; set; } - /// - /// 创建时间 - /// - [SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "首次创建时间")] - public DateTime? CreateTime { get; set; } = DateTime.Now; + /// /// 更新人 /// @@ -45,9 +36,8 @@ namespace Falcon.SugarApi.DatabaseDefinitions /// /// 创建人 public virtual void CreateNew(string createBy) { - this.Id = Guid.NewGuid(); + base.SetNew(); this.CreateBy = createBy; - this.CreateTime = DateTime.Now; this.UpdateBy = this.CreateBy; this.UpdateTime = this.CreateTime; this.Status = RecordStetus.Effective;