修改基础表定义!

This commit is contained in:
falcon 2023-02-10 09:57:00 +08:00
parent 02c2c8843e
commit 207e944d02
3 changed files with 6 additions and 22 deletions

View File

@ -5,9 +5,9 @@ using System.ComponentModel.DataAnnotations;
namespace Falcon.SugarApi.DatabaseDefinitions namespace Falcon.SugarApi.DatabaseDefinitions
{ {
/// <summary> /// <summary>
/// 基础表,定义表基础数据结构和构造方法 /// 基础表.只定义表基础主键和创建时间
/// </summary> /// </summary>
public abstract class SugarBasicTable : ICreateNew public abstract class SugarBasicTable
{ {
/// <summary> /// <summary>
/// 主键 /// 主键
@ -21,11 +21,6 @@ namespace Falcon.SugarApi.DatabaseDefinitions
[SugarColumn(IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间")] [SugarColumn(IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间")]
public DateTime CreateTime { get; set; } = DateTime.Now; public DateTime CreateTime { get; set; } = DateTime.Now;
/// <inheritdoc/>
public void CreateNew(string createBy) {
this.SetNew();
}
/// <summary> /// <summary>
/// 将数据设置为新数据。 /// 将数据设置为新数据。
/// <para>主要更新Id、创建时间和记录状态</para> /// <para>主要更新Id、创建时间和记录状态</para>

View File

@ -4,7 +4,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace Falcon.SugarApi.DatabaseDefinitions namespace Falcon.SugarApi.DatabaseDefinitions
{ {

View File

@ -5,25 +5,16 @@ using System.Reflection;
namespace Falcon.SugarApi.DatabaseDefinitions namespace Falcon.SugarApi.DatabaseDefinitions
{ {
/// <summary> /// <summary>
/// 表基类。一般表应该继承此类 /// 负载表基类。一般表应该继承此类包括SugarBasicTable定义和修改人行状态,以及一些相关方法等
/// </summary> /// </summary>
public abstract class SugarTableBase : ICreateNew, IModify, IDelete public abstract class SugarTableBase :SugarBasicTable, ICreateNew, IModify, IDelete
{ {
/// <summary>
/// 主键
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnDescription = "主键")]
public Guid Id { get; set; } = Guid.NewGuid();
/// <summary> /// <summary>
/// 创建人 /// 创建人
/// </summary> /// </summary>
[SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "首次创建人")] [SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "首次创建人")]
public string? CreateBy { get; set; } public string? CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "首次创建时间")]
public DateTime? CreateTime { get; set; } = DateTime.Now;
/// <summary> /// <summary>
/// 更新人 /// 更新人
/// </summary> /// </summary>
@ -45,9 +36,8 @@ namespace Falcon.SugarApi.DatabaseDefinitions
/// </summary> /// </summary>
/// <param name="createBy">创建人</param> /// <param name="createBy">创建人</param>
public virtual void CreateNew(string createBy) { public virtual void CreateNew(string createBy) {
this.Id = Guid.NewGuid(); base.SetNew();
this.CreateBy = createBy; this.CreateBy = createBy;
this.CreateTime = DateTime.Now;
this.UpdateBy = this.CreateBy; this.UpdateBy = this.CreateBy;
this.UpdateTime = this.CreateTime; this.UpdateTime = this.CreateTime;
this.Status = RecordStetus.Effective; this.Status = RecordStetus.Effective;