first commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IAGVTaskRepository : IBaseRepository<AGVTask>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 领域聚合根标记接口,用于约束可由通用仓储持久化的实体。
|
||||
/// </summary>
|
||||
public interface IAggregateRoot
|
||||
{
|
||||
Guid Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
using SqlSugar;
|
||||
using System.Data;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 基于 SqlSugar 的通用仓储契约,提供聚合根的增删改查和分页能力。
|
||||
/// </summary>
|
||||
/// <typeparam name="TAggregateRoot">仓储管理的聚合根类型。</typeparam>
|
||||
public interface IBaseRepository<TAggregateRoot> where TAggregateRoot : AggregateRoot, IAggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置仓储共享的数据库作用域。
|
||||
/// </summary>
|
||||
public static SqlSugarScope DB { get; set; }
|
||||
|
||||
#region Add
|
||||
/// <summary>
|
||||
/// 添加单个实体
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Add(TAggregateRoot entity, SqlSugarScope sqlSugarScope = null);
|
||||
/// <summary>
|
||||
/// 添加单个实体
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="ignoreColumns">要忽略的字段</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Add(TAggregateRoot entity, params string[] ignoreColumns);
|
||||
/// <summary>
|
||||
/// 批量插入实体
|
||||
/// </summary>
|
||||
/// <param name="entities"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Add(List<TAggregateRoot> entities);
|
||||
/// <summary>
|
||||
/// 字典方式添加单个实体
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名称</param>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Add(string tableName, Dictionary<string, object> dic);
|
||||
/// <summary>
|
||||
/// 添加之前判断指定字段是否存在,不存在则添加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddIfNotExist(TAggregateRoot entity, Expression<Func<TAggregateRoot, bool>> expression);
|
||||
#endregion
|
||||
|
||||
#region Delete
|
||||
/// <summary>
|
||||
/// 根据Id删除记录
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteById(Guid id, SqlSugarScope sqlSugarScope = null);
|
||||
|
||||
/// <summary>
|
||||
/// 根据Id批量删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteBatch(Guid[] ids);
|
||||
|
||||
/// <summary>
|
||||
/// 根据实体删除
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteByEntity(TAggregateRoot aggregateRoot);
|
||||
/// <summary>
|
||||
/// 根据实体批量删除
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoots"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteByEntity(List<TAggregateRoot> aggregateRoots);
|
||||
/// <summary>
|
||||
/// 根据条件删除
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleByExpression(Expression<Func<TAggregateRoot, bool>> expression);
|
||||
#endregion
|
||||
|
||||
#region Edit
|
||||
/// <summary>
|
||||
/// 更改单个实体
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditSingal(TAggregateRoot aggregateRoot);
|
||||
|
||||
/// <summary>
|
||||
/// 更改单个实体但忽略指定的列
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="ignoredColumns">忽略指定的条件</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditSingal(TAggregateRoot aggregateRoot, Expression<Func<TAggregateRoot, object>> ignoredColumns);
|
||||
|
||||
/// <summary>
|
||||
/// 更改单个实体但忽略指定的列
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="ignoredColumns">要忽略的列名</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditSingal(TAggregateRoot aggregateRoot, string[] ignoredColumns);
|
||||
|
||||
/// <summary>
|
||||
/// 更改单个实体中指定的列
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="columns">要更改的列名</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditSingalWithSpecificCols(TAggregateRoot aggregateRoot, string[] columns);
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoots"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditBatch(List<TAggregateRoot> aggregateRoots);
|
||||
/// <summary>
|
||||
/// 快速批量更新
|
||||
/// </summary>
|
||||
/// <param name="dtos"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditBatchFast(List<TAggregateRoot> dtos);
|
||||
|
||||
/// <summary>
|
||||
/// 字典方式更改
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditByDic(string tableName, Dictionary<string, object> dic);
|
||||
|
||||
/// <summary>
|
||||
/// 字典方式批量更改
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditByDic(string tableName, List<Dictionary<string, object>> dic);
|
||||
#endregion
|
||||
|
||||
#region Query
|
||||
/// <summary>
|
||||
/// 查询所有
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetAll();
|
||||
/// <summary>
|
||||
/// 查询所有
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetAll(Expression<Func<TAggregateRoot, object>> orderByExpress, OrderByType orderByType);
|
||||
/// <summary>
|
||||
/// 分片查询所有
|
||||
/// </summary>
|
||||
/// <param name="fragmentSize"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
Task<List<TAggregateRoot>> GetAllFragment(int fragmentSize = 50000);
|
||||
/// <summary>
|
||||
/// 分片查询所有(带排序功能)
|
||||
/// </summary>
|
||||
/// <param name="orderByExpress">要排序的字段</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="fragmentSize">分片大小,分片越大效率越高,但是占用的内存也越大,需要合理考虑数据量和硬件性能确定此参数大小</param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetAllFragment(Expression<Func<TAggregateRoot, object>> orderByExpress, OrderByType orderByType, int fragmentSize = 200);
|
||||
|
||||
/// <summary>
|
||||
/// 查询数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<int> Count();
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询数量
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> Count(Expression<Func<TAggregateRoot, bool>> expression);
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键查询
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
Task<TAggregateRoot> QueryByKey(string key);
|
||||
|
||||
/// <summary>
|
||||
/// 查询满足条件的第一个
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<TAggregateRoot> GetSingalByExpression(Expression<Func<TAggregateRoot, bool>> expression);
|
||||
|
||||
/// <summary>
|
||||
/// 查询满足条件的第一个(带排序)
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <param name="orderByExpress"></param>
|
||||
/// <param name="orderByType"></param>
|
||||
/// <returns></returns>
|
||||
Task<TAggregateRoot> GetSingalByExpression(
|
||||
Expression<Func<TAggregateRoot, bool>> expression,
|
||||
Expression<Func<TAggregateRoot, object>> orderByExpress,
|
||||
OrderByType orderByType);
|
||||
|
||||
/// <summary>
|
||||
/// 查询满足条件的所有实体
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetListByExpression(Expression<Func<TAggregateRoot, bool>> expression);
|
||||
/// <summary>
|
||||
/// 查询满足条件的所有实体(带排序功能)
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <param name="orderByExpress"></param>
|
||||
/// <param name="orderByType">Asc = 0,Desc = 1</param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetListByExpression(Expression<Func<TAggregateRoot, bool>> expression,
|
||||
string filedName,
|
||||
OrderByType orderByType = OrderByType.Desc);
|
||||
/// <summary>
|
||||
/// 通过实体查询满足条件的数据
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetListWhereClass(TAggregateRoot aggregateRoot);
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="pageQueryCondition">当前页码</param>
|
||||
/// <returns></returns>
|
||||
Task<PagedResult<TAggregateRoot>> QueryByPage(PageQueryCondition pageQueryCondition);
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键批量查询
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> QueryByIds(Guid[] ids);
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Exist(Expression<Func<TAggregateRoot, bool>> expression);
|
||||
#endregion
|
||||
|
||||
#region RawSql Sql操作
|
||||
/// <summary>
|
||||
/// sql查询,不带参数
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetBySql(string sql);
|
||||
/// <summary>
|
||||
/// sql查询,带参数 参数示例 select * from table where id=@id and name=@name 则字典的key为 "@id"
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="sqlParam"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetBySql(string sql, Dictionary<string, object> sqlParam);
|
||||
/// <summary>
|
||||
/// sql查询匿名类型
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<dynamic>> GetDynamicsBysql(string sql);
|
||||
/// <summary>
|
||||
/// sql查询匿名类型,附带参数 参数示例 select * from table where id=@id and name=@name 则字典的key为 "@id"
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="sqlParam"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<dynamic>> GetDynamicsBysql(string sql, Dictionary<string, object> sqlParam);
|
||||
/// <summary>
|
||||
/// 通过sql查询DataTable
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
Task<DataTable> GetDataTableBysql(string sql);
|
||||
/// <summary>
|
||||
/// 通过sql查询DataTable, 参数示例 select * from table where id=@id and name=@name 则字典的key为 "@id"
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="sqlParam"></param>
|
||||
/// <returns></returns>
|
||||
Task<DataTable> GetDataTableBysql(string sql, Dictionary<string, object> sqlParam);
|
||||
/// <summary>
|
||||
/// 执行原生sql
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="params"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> ExcuteSql(string sql, params SugarParameter[] @params);
|
||||
#endregion
|
||||
|
||||
#region 事务
|
||||
/// <summary>
|
||||
/// 开始事务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task BeginTran(SqlSugarScope sqlSugarScope);
|
||||
/// <summary>
|
||||
/// 提交事务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task CommitTran(SqlSugarScope sqlSugarScope);
|
||||
/// <summary>
|
||||
/// 回滚事务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task RollbackTran(SqlSugarScope sqlSugarScope);
|
||||
SqlSugarTransaction UseTranAsync();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库配置接口,用于不同数据库切换
|
||||
/// </summary>
|
||||
public interface IDbConnectionConfig
|
||||
{
|
||||
ConnectionConfig ConnectionConfig { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IERPTaskRepository : IBaseRepository<ERPTask>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IElevatorCountRepository : IBaseRepository<ElevatorCount>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IElevatorPlcQueueRepository : IBaseRepository<ElevatorPlcQueue>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IOperationLogRepository : IBaseRepository<OperationLog>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IRcsTaskRepository : IBaseRepository<RcsTask>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IStorageRackRepository : IBaseRepository<StorageRack>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IUserInfoRepository : IBaseRepository<UserInfo>
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user