基类模型修改为接口

This commit is contained in:
chenchun
2022-04-24 16:44:16 +08:00
parent 1ecd01204b
commit 6aa970c375
14 changed files with 71 additions and 11 deletions

Binary file not shown.

View File

@@ -15,7 +15,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
[ApiController] [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 readonly ILogger<T> _logger;
private IBaseService<T> _baseService; private IBaseService<T> _baseService;

View File

@@ -8,7 +8,7 @@ using Yi.Framework.Repository;
namespace Yi.Framework.Interface 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; } public IRepository<T> _repository { get; set; }
} }

View File

@@ -9,9 +9,10 @@ namespace Yi.Framework.Model.Models
///</summary> ///</summary>
[SplitTable(SplitType.Year)] [SplitTable(SplitType.Year)]
[SugarTable("SplitLog_{year}{month}{day}")] [SugarTable("SplitLog_{year}{month}{day}")]
public partial class LogEntity public partial class LogEntity
{ {
[SplitField] //分表字段 在插入的时候会根据这个字段插入哪个表,在更新删除的时候用这个字段找出相关表 [SplitField] //分表字段 在插入的时候会根据这个字段插入哪个表,在更新删除的时候用这个字段找出相关表
public DateTime? LogCreateTime { get; set; } public DateTime? LogCreateTime { get; set; }
} }
} }

View 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; }
}
}

View File

@@ -10,7 +10,7 @@ namespace Yi.Framework.Model.Models
[SugarTable("Role")] [SugarTable("Role")]
public partial class RoleEntity:IBaseModelEntity public partial class RoleEntity:IBaseModelEntity
{ {
public BaseModelEntity() public RoleEntity()
{ {
this.IsDeleted = false; this.IsDeleted = false;
this.CreateTime = DateTime.Now; this.CreateTime = DateTime.Now;

View File

@@ -10,7 +10,7 @@ namespace Yi.Framework.Model.Models
[SugarTable("User")] [SugarTable("User")]
public partial class UserEntity:IBaseModelEntity public partial class UserEntity:IBaseModelEntity
{ {
public BaseModelEntity() public UserEntity()
{ {
this.IsDeleted = false; this.IsDeleted = false;
this.CreateTime = DateTime.Now; this.CreateTime = DateTime.Now;

View File

@@ -10,7 +10,7 @@ namespace Yi.Framework.Model.Models
[SugarTable("UserRole")] [SugarTable("UserRole")]
public partial class UserRoleEntity:IBaseModelEntity public partial class UserRoleEntity:IBaseModelEntity
{ {
public BaseModelEntity() public UserRoleEntity()
{ {
this.IsDeleted = false; this.IsDeleted = false;
this.CreateTime = DateTime.Now; this.CreateTime = DateTime.Now;

View File

@@ -4,7 +4,7 @@ using System.Linq;
using SqlSugar; using SqlSugar;
namespace Yi.Framework.Model.Models namespace Yi.Framework.Model.Models
{ {
public partial class UserEntity:BaseModelEntity public partial class UserEntity
{ {
/// <summary> /// <summary>
/// 看好啦ORM精髓导航属性 /// 看好啦ORM精髓导航属性

View File

@@ -4,7 +4,7 @@ using Yi.Framework.Model.Models;
namespace Yi.Framework.Repository 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) public DataContext(ISqlSugarClient context) : base(context)
{ {

View File

@@ -11,7 +11,7 @@ using Yi.Framework.Model.Query;
namespace Yi.Framework.Repository 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 ISqlSugarClient _Db { get; set; }
public Task<bool> UseTranAsync(Func<Task> func); public Task<bool> UseTranAsync(Func<Task> func);

View File

@@ -12,7 +12,7 @@ namespace Yi.Framework.Repository
/// 仓储模式 /// 仓储模式
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <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; } public ISqlSugarClient _Db { get; set; }
/// <summary> /// <summary>

View File

@@ -9,7 +9,7 @@ using Yi.Framework.Repository;
namespace Yi.Framework.Service 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 IRepository<T> _repository { get; set; }
public BaseService(IRepository<T> iRepository) public BaseService(IRepository<T> iRepository)