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.

207 lines
10 KiB
C#

using SLH.SSDMS.Model.DTO;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Services
{
/// <summary>
/// IBaseRepository
/// </summary>
public interface IBaseServices<TEntity> where TEntity : class
{
Task<TEntity> QuerySingle(Expression<Func<TEntity, bool>> whereExpression);
Task<TEntity> QueryById(object objId);
Task<TEntity> QueryById(object objId, bool blnUseCache = false);
Task<List<TEntity>> QueryByIDs(object[] lstIds);
Task<int> Add(TEntity model);
Task<int> AddLog(TEntity model);
Task<int> Add(List<TEntity> listEntity);
Task<bool> DeleteById(object id);
Task<bool> Delete(TEntity model);
Task<bool> Delete(Expression<Func<TEntity, bool>> whereExpression);
Task<bool> DeleteByIds(object[] ids);
Task<bool> Update(TEntity model);
Task<bool> Update(TEntity entity, string strWhere);
Task<bool> Update(object operateAnonymousObjects);
Task<bool> Update(TEntity entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string strWhere = "");
Task<List<TEntity>> Query();
Task<List<TEntity>> Query(string strWhere);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);
Task<List<TEntity>> Query(string strWhere, string strOrderByFileds);
Task<TEntity> QueryFirst(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, int intTop, string strOrderByFileds);
Task<List<TEntity>> Query(string strWhere, int intTop, string strOrderByFileds);
Task<List<TEntity>> Query(
Expression<Func<TEntity, bool>> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds);
Task<List<TEntity>> Query(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds);
Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);
Task<List<TResult>> QueryMuch<T, T2, T3, T4, T5, TResult>(
Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, T5, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new();
Task<List<TResult>> QueryMuch<T, T2, T3, T4, TResult>(
Expression<Func<T, T2, T3, T4, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new();
Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(
Expression<Func<T, T2, T3, object[]>> joinExpression,
Expression<Func<T, T2, T3, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new();
Task<List<TResult>> QueryMuch<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new();
#region 多表分页
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="T4">实体4</typeparam>
/// <typeparam name="T5">实体5</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
Task<PageModel<TResult>> QueryMuchPage<T, T2, T3, T4, T5, TResult>(
Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, T5, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20,
string strOrderByFileds = null) where T : class, new();
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="T4">实体4</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
Task<PageModel<TResult>> QueryMuchPage<T, T2, T3, T4, TResult>(
Expression<Func<T, T2, T3, T4, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20,
string strOrderByFileds = null) where T : class, new();
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
Task<PageModel<TResult>> QueryMuchPage<T, T2, T3, TResult>(
Expression<Func<T, T2, T3, object[]>> joinExpression,
Expression<Func<T, T2, T3, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20,
string strOrderByFileds = null) where T : class, new();
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
Task<PageModel<TResult>> QueryMuchPage<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20,
string strOrderByFileds = null) where T : class, new();
/// <summary>
///查询-多表查询 (测试)
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
Task<PageModel<TResult>> QueryMuchPage<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, object>> sortExpression,
Expression<Func<T, T2, bool>> whereLambda = null,
int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new();
#endregion
/// <summary>
/// 存储过程
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="parameters"></param>
/// <returns></returns>
Task<List<T>> QueryByProc<T>(string proc, List<SugarParameter> parameters) where T : class, new();
Task<Tuple<List<T>, List<T2>>> QueryByProc<T, T2>(string proc, List<SugarParameter> parameters)
where T : class, new();
/// <summary>
/// sql语句
/// </summary>
Task<List<T>> QueryBySql<T>(string sql, List<SugarParameter> parameters) where T : class, new();
#region 自定义
/// <summary>
/// 添加上机记录
/// </summary>
/// <param name="boardEntity"></param>
/// <param name="whereExpression"></param>
/// <returns></returns>
Task<int> BoardAdd(TEntity boardEntity, Expression<Func<TEntity, bool>> whereExpression);
#endregion
}
}