基类模型修改为接口
This commit is contained in:
Binary file not shown.
@@ -15,7 +15,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
[ApiController]
|
||||
public class BaseCrudController<T> : ControllerBase where T : BaseModelEntity,new()
|
||||
public class BaseCrudController<T> : ControllerBase where T : class, IBaseModelEntity,new()
|
||||
{
|
||||
private readonly ILogger<T> _logger;
|
||||
private IBaseService<T> _baseService;
|
||||
|
||||
Binary file not shown.
@@ -8,7 +8,7 @@ using Yi.Framework.Repository;
|
||||
|
||||
namespace Yi.Framework.Interface
|
||||
{
|
||||
public interface IBaseService<T> where T:BaseModelEntity,new()
|
||||
public interface IBaseService<T> where T: class, IBaseModelEntity,new()
|
||||
{
|
||||
public IRepository<T> _repository { get; set; }
|
||||
}
|
||||
|
||||
@@ -13,5 +13,6 @@ namespace Yi.Framework.Model.Models
|
||||
{
|
||||
[SplitField] //分表字段 在插入的时候会根据这个字段插入哪个表,在更新删除的时候用这个字段找出相关表
|
||||
public DateTime? LogCreateTime { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
59
Yi.Framework.Net6/Yi.Framework.Model/Models/LogEntity.cs
Normal file
59
Yi.Framework.Net6/Yi.Framework.Model/Models/LogEntity.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SqlSugar;
|
||||
namespace Yi.Framework.Model.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志表
|
||||
///</summary>
|
||||
public partial class LogEntity:IBaseModelEntity
|
||||
{
|
||||
public LogEntity()
|
||||
{
|
||||
this.IsDeleted = false;
|
||||
this.CreateTime = DateTime.Now;
|
||||
}
|
||||
/// <summary>
|
||||
/// 1
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="CreateUser" )]
|
||||
public long? CreateUser { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="CreateTime" )]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 修改者
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="ModifyUser" )]
|
||||
public long? ModifyUser { get; set; }
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="ModifyTime" )]
|
||||
public DateTime? ModifyTime { get; set; }
|
||||
/// <summary>
|
||||
/// 是否删除
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="IsDeleted" )]
|
||||
public bool? IsDeleted { get; set; }
|
||||
/// <summary>
|
||||
/// 租户Id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="TenantId" )]
|
||||
public long? TenantId { get; set; }
|
||||
/// <summary>
|
||||
/// 消息
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="Message" )]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace Yi.Framework.Model.Models
|
||||
[SugarTable("Role")]
|
||||
public partial class RoleEntity:IBaseModelEntity
|
||||
{
|
||||
public BaseModelEntity()
|
||||
public RoleEntity()
|
||||
{
|
||||
this.IsDeleted = false;
|
||||
this.CreateTime = DateTime.Now;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Yi.Framework.Model.Models
|
||||
[SugarTable("User")]
|
||||
public partial class UserEntity:IBaseModelEntity
|
||||
{
|
||||
public BaseModelEntity()
|
||||
public UserEntity()
|
||||
{
|
||||
this.IsDeleted = false;
|
||||
this.CreateTime = DateTime.Now;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Yi.Framework.Model.Models
|
||||
[SugarTable("UserRole")]
|
||||
public partial class UserRoleEntity:IBaseModelEntity
|
||||
{
|
||||
public BaseModelEntity()
|
||||
public UserRoleEntity()
|
||||
{
|
||||
this.IsDeleted = false;
|
||||
this.CreateTime = DateTime.Now;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using SqlSugar;
|
||||
namespace Yi.Framework.Model.Models
|
||||
{
|
||||
public partial class UserEntity:BaseModelEntity
|
||||
public partial class UserEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 看好啦!ORM精髓,导航属性
|
||||
|
||||
@@ -4,7 +4,7 @@ using Yi.Framework.Model.Models;
|
||||
|
||||
namespace Yi.Framework.Repository
|
||||
{
|
||||
public class DataContext<T> : SimpleClient<T> where T : class, BaseModelEntity, new()
|
||||
public class DataContext<T> : SimpleClient<T> where T : class, IBaseModelEntity, new()
|
||||
{
|
||||
public DataContext(ISqlSugarClient context) : base(context)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ using Yi.Framework.Model.Query;
|
||||
|
||||
namespace Yi.Framework.Repository
|
||||
{
|
||||
public interface IRepository<T> : ISimpleClient<T> where T : BaseModelEntity,new()
|
||||
public interface IRepository<T> : ISimpleClient<T> where T : class, IBaseModelEntity, new()
|
||||
{
|
||||
public ISqlSugarClient _Db { get; set; }
|
||||
public Task<bool> UseTranAsync(Func<Task> func);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Yi.Framework.Repository
|
||||
/// 仓储模式
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class Repository<T> : DataContext<T>, IRepository<T> where T : BaseModelEntity,new()
|
||||
public class Repository<T> : DataContext<T>, IRepository<T> where T : class, IBaseModelEntity, new()
|
||||
{
|
||||
public ISqlSugarClient _Db { get; set; }
|
||||
/// <summary>
|
||||
|
||||
@@ -9,7 +9,7 @@ using Yi.Framework.Repository;
|
||||
|
||||
namespace Yi.Framework.Service
|
||||
{
|
||||
public class BaseService<T>:IBaseService<T> where T:BaseModelEntity,new()
|
||||
public class BaseService<T>:IBaseService<T> where T:class, IBaseModelEntity,new()
|
||||
{
|
||||
public IRepository<T> _repository { get; set; }
|
||||
public BaseService(IRepository<T> iRepository)
|
||||
|
||||
Reference in New Issue
Block a user