You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
4.9 KiB
C#

using EntrustSettle.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
using System.Threading.Tasks;
9 months ago
namespace EntrustSettle.IServices.Base
{
/// <summary>
///
/// </summary>
/// <remarks>已在<see cref="AutofacModuleRegister"/>中注册,可以直接在需要的地方注入</remarks>
9 months ago
public interface IBaseServices<TEntity> where TEntity : class, new()
{
ISqlSugarClient Db { get; }
9 months ago
#region 查询
9 months ago
ISugarQueryable<TEntity> AsQueryable();
9 months ago
Task<TEntity> QueryById(object objId);
Task<TEntity> QueryById(object objId, bool blnUseCache = false);
Task<List<TEntity>> QueryByIDs(object[] lstIds);
Task<TEntity> QueryFirst(Expression<Func<TEntity, bool>> whereExpression);
Task<TResult> QueryFirst<TResult>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TResult>> selectExpression);
9 months ago
Task<TEntity> QueryFirstInclude<TReturn>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, List<TReturn>>> include);
Task<List<TEntity>> Query();
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression);
Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TResult>> selectExpression);
9 months ago
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string orderByFields);
Task<List<TEntity>> Query(string where, string orderByFields);
Task<List<TEntity>> QueryTop(string where, int intTop, string orderByFields);
Task<List<TEntity>> QueryTop(Expression<Func<TEntity, bool>> whereExpression, int intTop, string orderByFields);
Task<List<TEntity>> QueryPage(string where, int pageIndex, int pageSize, string orderByFields);
Task<List<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int pageIndex, int pageSize, string orderByFields);
Task<PageModel<TEntity>> QueryPageModel(Expression<Func<TEntity, bool>> whereExpression, int pageIndex = 1, int pageSize = 20, Expression<Func<TEntity, object>> orderByExpression = null, bool isAsc = true);
Task<PageModel<TEntity>> QueryPageModel(Expression<Func<TEntity, bool>> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null);
9 months ago
Task<PageModel<TEntity>> QueryPageModel(Expression<Func<TEntity, bool>> whereExpression, PaginationModel paginationModel);
9 months ago
Task<List<TEntity>> QuerySql(string sql, SugarParameter[] parameters = null);
Task<DataTable> QueryTable(string sql, SugarParameter[] parameters = null);
9 months ago
#endregion
9 months ago
#region 新增
9 months ago
IInsertable<TEntity> AsInsertable(TEntity model);
IInsertable<TEntity> AsInsertable(List<TEntity> listEntity);
9 months ago
Task<long> Add(TEntity model);
Task<List<long>> Add(List<TEntity> listEntity);
9 months ago
#endregion
9 months ago
#region 删除
Task<bool> Delete(Expression<Func<TEntity, bool>> whereExpression);
9 months ago
Task<bool> DeleteById(object id);
Task<bool> Delete(TEntity model);
Task<bool> DeleteByIds(object[] ids);
9 months ago
#endregion
9 months ago
#region 更新
9 months ago
IUpdateable<TEntity> AsUpdateable();
9 months ago
IUpdateable<TEntity> AsUpdateable(TEntity model);
IUpdateable<TEntity> AsUpdateable(params TEntity[] entities);
Task<bool> Update(TEntity model);
9 months ago
Task<bool> Update(TEntity entity, Expression<Func<TEntity, object>> updateColumns);
Task<bool> Update(List<TEntity> model);
Task<bool> Update(TEntity entity, string where);
Task<bool> Update(TEntity entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string where = "");
Task<bool> Update(Expression<Func<TEntity, TEntity>> columns, Expression<Func<TEntity, bool>> where);
9 months ago
#endregion
9 months ago
#region Split分表基础接口 基础CRUD
/// <summary>
/// 通过ID查询(自动分表)
/// </summary>
Task<TEntity> QueryByIdSplit(object objId);
9 months ago
/// <summary>
/// 分页查询(自动分表)
/// </summary>
Task<PageModel<TEntity>> QueryPageSplit(Expression<Func<TEntity, bool>> whereExpression, DateTime beginTime, DateTime endTime, int pageIndex = 1, int pageSize = 20, string orderByFields = null);
/// <summary>
/// 插入(自动分表)
/// </summary>
Task<List<long>> AddSplit(TEntity entity);
9 months ago
/// <summary>
/// 删除(自动分表)
/// </summary>
Task<bool> DeleteSplit(TEntity entity, DateTime dateTime);
9 months ago
/// <summary>
/// 更新(自动分表)
/// </summary>
Task<bool> UpdateSplit(TEntity entity, DateTime dateTime);
#endregion
}
}