抽象实体基类
This commit is contained in:
@@ -41,8 +41,4 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Library\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Model.Models
|
||||
{
|
||||
public abstract class BaseModelEntity
|
||||
{
|
||||
public BaseModelEntity()
|
||||
{
|
||||
this.Id = Guid.NewGuid();
|
||||
this.IsDeleted = false;
|
||||
this.CreateTime = DateTime.Now;
|
||||
}
|
||||
/// <summary>
|
||||
/// 1
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||
public Guid Id { get; set; }
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateUser")]
|
||||
public Guid? CreateUser { get; set; }
|
||||
/// <summary>
|
||||
/// 修改者
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "ModifyUser")]
|
||||
public Guid? ModifyUser { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "CreateTime")]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "ModifyTime")]
|
||||
public DateTime? ModifyTime { get; set; }
|
||||
/// <summary>
|
||||
/// 删除者
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "DeleteUser")]
|
||||
public Guid? DeleteUser { get; set; }
|
||||
/// <summary>
|
||||
/// 删除时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "DeleteTime")]
|
||||
public DateTime? DeleteTime { get; set; }
|
||||
/// <summary>
|
||||
/// 是否删除
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "IsDeleted")]
|
||||
public bool? IsDeleted { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,8 @@ namespace Yi.Framework.Model.Models
|
||||
/// 用户表
|
||||
///</summary>
|
||||
[SugarTable("User")]
|
||||
public partial class UserEntity
|
||||
public partial class UserEntity:BaseModelEntity
|
||||
{
|
||||
public UserEntity()
|
||||
{
|
||||
this.Id = Guid.NewGuid();
|
||||
this.IsDeleted=false;
|
||||
this.CreateTime = DateTime.Now;
|
||||
}
|
||||
/// <summary>
|
||||
/// 1
|
||||
///</summary>
|
||||
|
||||
@@ -6,11 +6,12 @@ using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Model.Query;
|
||||
|
||||
namespace Yi.Framework.Repository
|
||||
{
|
||||
public interface IRepository<T> : ISimpleClient<T> where T : class, new()
|
||||
public interface IRepository<T> : ISimpleClient<T> where T : BaseModelEntity,new()
|
||||
{
|
||||
public Task<T> InsertReturnEntityAsync(T entity);
|
||||
public Task<List<S>> StoreAsync<S>(string storeName, object para);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Data;
|
||||
using System.Linq.Expressions;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Model.Query;
|
||||
|
||||
/***这里面写的代码不会给覆盖,如果要重新生成请删除 Repository.cs ***/
|
||||
@@ -11,7 +12,7 @@ namespace Yi.Framework.Repository
|
||||
/// 仓储模式
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class Repository<T> : DataContext<T>, IRepository<T> where T : class, new()
|
||||
public class Repository<T> : DataContext<T>, IRepository<T> where T : BaseModelEntity,new()
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user