【优化】移除2个orderBy使用的sql组合方法参数,移除4个仓储基类的所有sql组合方法,全部使用参数化提交,防止出现可能存在的sql注入。

This commit is contained in:
jianweie code
2024-01-17 20:02:06 +08:00
parent f16797adb5
commit a6e345a48b
15 changed files with 77 additions and 883 deletions

View File

@@ -142,13 +142,11 @@ namespace CoreCms.Net.IRepository
/// 重写根据条件及自定义排序查询分页数据返回DTO /// 重写根据条件及自定义排序查询分页数据返回DTO
/// </summary> /// </summary>
/// <param name="predicate"></param> /// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param> /// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param> /// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param> /// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns> /// <returns></returns>
Task<IPageList<GoodListDTO>> QueryPageByDTOAsync(Expression<Func<GoodListDTO, bool>> predicate, Task<IPageList<GoodListDTO>> QueryPageByDTOAsync(Expression<Func<GoodListDTO, bool>> predicate, int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false);
string orderBy = "", int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false);
/// <summary> /// <summary>
@@ -160,8 +158,7 @@ namespace CoreCms.Net.IRepository
/// <param name="pageSize">分布大小</param> /// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param> /// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns> /// <returns></returns>
Task<IPageList<CoreCmsGoods>> QueryAgentGoodsPageAsync(Expression<Func<CoreCmsGoods, bool>> predicate, Task<IPageList<CoreCmsGoods>> QueryAgentGoodsPageAsync(Expression<Func<CoreCmsGoods, bool>> predicate, int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false);
string orderBy = "", int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false);

View File

@@ -104,51 +104,6 @@ namespace CoreCms.Net.IRepository
/// <returns></returns> /// <returns></returns>
Task<List<T>> QueryAsync(bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue); Task<List<T>> QueryAsync(bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="orderBy">排序</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
List<T> QueryListByClause(string strWhere, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="orderBy">排序</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
Task<List<T>> QueryListByClauseAsync(string strWhere, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="orderBy">排序</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
List<T> QueryListByClause(Expression<Func<T, bool>> predicate, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="orderBy">排序</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, string orderBy = "",
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary> /// <summary>
/// 根据条件查询数据 /// 根据条件查询数据
/// </summary> /// </summary>
@@ -159,8 +114,8 @@ namespace CoreCms.Net.IRepository
/// <param name="isDataCache">是否启用缓存</param> /// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param> /// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns> /// <returns>泛型实体集合</returns>
List<T> QueryListByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, List<T> QueryListByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate = null,
OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue); OrderByType orderByType = OrderByType.Asc, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary> /// <summary>
/// 根据条件查询数据 /// 根据条件查询数据
@@ -173,7 +128,7 @@ namespace CoreCms.Net.IRepository
/// <param name="cacheTimes">缓存时长(分钟)</param> /// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns> /// <returns>泛型实体集合</returns>
Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate,
Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue); Expression<Func<T, object>> orderByPredicate = null, OrderByType orderByType=OrderByType.Asc, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary> /// <summary>
/// 根据条件查询一定数量数据 /// 根据条件查询一定数量数据
@@ -203,32 +158,6 @@ namespace CoreCms.Net.IRepository
Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, int take, Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, int take,
Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue); Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询一定数量数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="take">获取数量</param>
/// <param name="strOrderByFields">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
List<T> QueryListByClause(Expression<Func<T, bool>> predicate, int take, string strOrderByFields = "",
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询一定数量数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="take">获取数量</param>
/// <param name="strOrderByFields">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, int take,
string strOrderByFields = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary> /// <summary>
/// 根据条件查询数据 /// 根据条件查询数据
/// </summary> /// </summary>
@@ -394,40 +323,6 @@ namespace CoreCms.Net.IRepository
/// <returns></returns> /// <returns></returns>
Task<bool> UpdateAsync(T entity, bool isRemoveDataCache = false); Task<bool> UpdateAsync(T entity, bool isRemoveDataCache = false);
/// <summary>
/// 根据手写条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
bool Update(T entity, string strWhere, bool isRemoveDataCache = false);
/// <summary>
/// 根据手写条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
Task<bool> UpdateAsync(T entity, string strWhere, bool isRemoveDataCache = false);
/// <summary>
/// 根据手写sql语句更新数据
/// </summary>
/// <param name="strSql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
bool Update(string strSql, SugarParameter[] parameters = null);
/// <summary>
/// 根据手写sql语句更新数据
/// </summary>
/// <param name="strSql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task<bool> UpdateAsync(string strSql, SugarParameter[] parameters = null);
/// <summary> /// <summary>
/// 更新某个字段 /// 更新某个字段
/// </summary> /// </summary>
@@ -446,28 +341,6 @@ namespace CoreCms.Net.IRepository
/// <returns></returns> /// <returns></returns>
Task<bool> UpdateAsync(Expression<Func<T, T>> columns, Expression<Func<T, bool>> where, bool isRemoveDataCache = false); Task<bool> UpdateAsync(Expression<Func<T, T>> columns, Expression<Func<T, bool>> where, bool isRemoveDataCache = false);
/// <summary>
/// 根据条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="lstColumns"></param>
/// <param name="lstIgnoreColumns"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
Task<bool> UpdateAsync(T entity, List<string> lstColumns, List<string> lstIgnoreColumns,
string strWhere = "", bool isRemoveDataCache = false);
/// <summary>
/// 根据条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="lstColumns"></param>
/// <param name="lstIgnoreColumns"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
bool Update(T entity, List<string> lstColumns, List<string> lstIgnoreColumns, string strWhere = "", bool isRemoveDataCache = false);
#endregion #endregion
#region #region
@@ -778,33 +651,6 @@ namespace CoreCms.Net.IRepository
#endregion #endregion
#region #region
/// <summary>
/// 根据条件查询分页数据
/// </summary>
/// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
IPageList<T> QueryPage(Expression<Func<T, bool>> predicate, string orderBy = "", int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询分页数据
/// </summary>
/// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
Task<IPageList<T>> QueryPageAsync(Expression<Func<T, bool>> predicate, string orderBy = "", int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary> /// <summary>
/// 根据条件查询分页数据 /// 根据条件查询分页数据
/// </summary> /// </summary>

View File

@@ -206,13 +206,11 @@ namespace CoreCms.Net.IServices
/// 重写根据条件及自定义排序查询分页数据返回DTO /// 重写根据条件及自定义排序查询分页数据返回DTO
/// </summary> /// </summary>
/// <param name="predicate"></param> /// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param> /// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param> /// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param> /// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns> /// <returns></returns>
Task<IPageList<GoodListDTO>> QueryPageByDTOAsync(Expression<Func<GoodListDTO, bool>> predicate, Task<IPageList<GoodListDTO>> QueryPageByDTOAsync(Expression<Func<GoodListDTO, bool>> predicate, int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false);
string orderBy = "", int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false);
/// <summary> /// <summary>
/// 重写根据条件及自定义排序查询分页数据 /// 重写根据条件及自定义排序查询分页数据
@@ -223,8 +221,7 @@ namespace CoreCms.Net.IServices
/// <param name="pageSize">分布大小</param> /// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param> /// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns> /// <returns></returns>
Task<IPageList<CoreCmsGoods>> QueryAgentGoodsPageAsync(Expression<Func<CoreCmsGoods, bool>> predicate, Task<IPageList<CoreCmsGoods>> QueryAgentGoodsPageAsync(Expression<Func<CoreCmsGoods, bool>> predicate, int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false);
string orderBy = "", int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false);
/// <summary> /// <summary>

View File

@@ -105,51 +105,6 @@ namespace CoreCms.Net.IServices
/// <returns></returns> /// <returns></returns>
Task<List<T>> QueryAsync(bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue); Task<List<T>> QueryAsync(bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="orderBy">排序</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
List<T> QueryListByClause(string strWhere, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="orderBy">排序</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
Task<List<T>> QueryListByClauseAsync(string strWhere, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="orderBy">排序</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
List<T> QueryListByClause(Expression<Func<T, bool>> predicate, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="orderBy">排序</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, string orderBy = "",
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary> /// <summary>
/// 根据条件查询数据 /// 根据条件查询数据
/// </summary> /// </summary>
@@ -160,8 +115,8 @@ namespace CoreCms.Net.IServices
/// <param name="isDataCache">是否启用缓存</param> /// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param> /// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns> /// <returns>泛型实体集合</returns>
List<T> QueryListByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, List<T> QueryListByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate = null,
OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue); OrderByType orderByType = OrderByType.Asc, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary> /// <summary>
/// 根据条件查询数据 /// 根据条件查询数据
@@ -174,7 +129,7 @@ namespace CoreCms.Net.IServices
/// <param name="cacheTimes">缓存时长(分钟)</param> /// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns> /// <returns>泛型实体集合</returns>
Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate,
Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue); Expression<Func<T, object>> orderByPredicate = null, OrderByType orderByType = OrderByType.Asc, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary> /// <summary>
/// 根据条件查询一定数量数据 /// 根据条件查询一定数量数据
@@ -204,32 +159,6 @@ namespace CoreCms.Net.IServices
Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, int take, Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, int take,
Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue); Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询一定数量数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="take">获取数量</param>
/// <param name="strOrderByFields">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
List<T> QueryListByClause(Expression<Func<T, bool>> predicate, int take, string strOrderByFields = "",
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询一定数量数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="take">获取数量</param>
/// <param name="strOrderByFields">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, int take,
string strOrderByFields = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary> /// <summary>
/// 根据条件查询数据 /// 根据条件查询数据
/// </summary> /// </summary>
@@ -262,8 +191,7 @@ namespace CoreCms.Net.IServices
/// <param name="isDataCache">是否启用缓存</param> /// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param> /// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns> /// <returns></returns>
T QueryByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, T QueryByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary> /// <summary>
/// 根据条件查询数据 /// 根据条件查询数据
@@ -282,7 +210,7 @@ namespace CoreCms.Net.IServices
#endregion #endregion
#region #region
/// <summary> /// <summary>
/// 写入实体数据 /// 写入实体数据
@@ -396,40 +324,6 @@ namespace CoreCms.Net.IServices
/// <returns></returns> /// <returns></returns>
Task<bool> UpdateAsync(T entity, bool isRemoveDataCache = false); Task<bool> UpdateAsync(T entity, bool isRemoveDataCache = false);
/// <summary>
/// 根据手写条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
bool Update(T entity, string strWhere, bool isRemoveDataCache = false);
/// <summary>
/// 根据手写条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
Task<bool> UpdateAsync(T entity, string strWhere, bool isRemoveDataCache = false);
/// <summary>
/// 根据手写sql语句更新数据
/// </summary>
/// <param name="strSql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
bool Update(string strSql, SugarParameter[] parameters = null);
/// <summary>
/// 根据手写sql语句更新数据
/// </summary>
/// <param name="strSql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task<bool> UpdateAsync(string strSql, SugarParameter[] parameters = null);
/// <summary> /// <summary>
/// 更新某个字段 /// 更新某个字段
/// </summary> /// </summary>
@@ -448,28 +342,6 @@ namespace CoreCms.Net.IServices
/// <returns></returns> /// <returns></returns>
Task<bool> UpdateAsync(Expression<Func<T, T>> columns, Expression<Func<T, bool>> where, bool isRemoveDataCache = false); Task<bool> UpdateAsync(Expression<Func<T, T>> columns, Expression<Func<T, bool>> where, bool isRemoveDataCache = false);
/// <summary>
/// 根据条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="lstColumns"></param>
/// <param name="lstIgnoreColumns"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
Task<bool> UpdateAsync(T entity, List<string> lstColumns, List<string> lstIgnoreColumns,
string strWhere = "", bool isRemoveDataCache = false);
/// <summary>
/// 根据条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="lstColumns"></param>
/// <param name="lstIgnoreColumns"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
bool Update(T entity, List<string> lstColumns, List<string> lstIgnoreColumns, string strWhere = "", bool isRemoveDataCache = false);
#endregion #endregion
#region #region
@@ -602,7 +474,6 @@ namespace CoreCms.Net.IServices
/// <returns></returns> /// <returns></returns>
Task<bool> DeleteByIdsAsync(string[] ids, bool isRemoveDataCache = false); Task<bool> DeleteByIdsAsync(string[] ids, bool isRemoveDataCache = false);
/// <summary> /// <summary>
/// 删除指定ID集合的数据(批量删除) /// 删除指定ID集合的数据(批量删除)
/// </summary> /// </summary>
@@ -619,7 +490,6 @@ namespace CoreCms.Net.IServices
/// <returns></returns> /// <returns></returns>
Task<bool> DeleteByIdsAsync(List<int> ids, bool isRemoveDataCache = false); Task<bool> DeleteByIdsAsync(List<int> ids, bool isRemoveDataCache = false);
/// <summary> /// <summary>
/// 删除指定ID集合的数据(批量删除) /// 删除指定ID集合的数据(批量删除)
/// </summary> /// </summary>
@@ -636,7 +506,6 @@ namespace CoreCms.Net.IServices
/// <returns></returns> /// <returns></returns>
Task<bool> DeleteByIdsAsync(List<string> ids, bool isRemoveDataCache = false); Task<bool> DeleteByIdsAsync(List<string> ids, bool isRemoveDataCache = false);
/// <summary> /// <summary>
/// 删除指定ID集合的数据(批量删除) /// 删除指定ID集合的数据(批量删除)
/// </summary> /// </summary>
@@ -653,7 +522,6 @@ namespace CoreCms.Net.IServices
/// <returns></returns> /// <returns></returns>
Task<bool> DeleteByIdsAsync(List<Guid> ids, bool isRemoveDataCache = false); Task<bool> DeleteByIdsAsync(List<Guid> ids, bool isRemoveDataCache = false);
/// <summary> /// <summary>
/// 删除指定ID集合的数据(批量删除) /// 删除指定ID集合的数据(批量删除)
/// </summary> /// </summary>
@@ -781,32 +649,6 @@ namespace CoreCms.Net.IServices
#region #region
/// <summary>
/// 根据条件查询分页数据
/// </summary>
/// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
IPageList<T> QueryPage(Expression<Func<T, bool>> predicate, string orderBy = "", int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary>
/// 根据条件查询分页数据
/// </summary>
/// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
Task<IPageList<T>> QueryPageAsync(Expression<Func<T, bool>> predicate, string orderBy = "", int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue);
/// <summary> /// <summary>
/// 根据条件查询分页数据 /// 根据条件查询分页数据
/// </summary> /// </summary>

View File

@@ -9706,11 +9706,6 @@
每页数据量 每页数据量
</summary> </summary>
</member> </member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByWhereOrder.order">
<summary>
排序
</summary>
</member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByWhereOrder.where"> <member name="P:CoreCms.Net.Model.FromBody.FMPageByWhereOrder.where">
<summary> <summary>
判断条件 判断条件
@@ -9721,6 +9716,16 @@
根据int类型id加where查询条件和order排序获取列表(一般用于直接id分页) 根据int类型id加where查询条件和order排序获取列表(一般用于直接id分页)
</summary> </summary>
</member> </member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByIntId.otherData">
<summary>
其他数据
</summary>
</member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByIntId.id">
<summary>
序列
</summary>
</member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByIntId.page"> <member name="P:CoreCms.Net.Model.FromBody.FMPageByIntId.page">
<summary> <summary>
当前页码 当前页码
@@ -9731,11 +9736,6 @@
每页数据量 每页数据量
</summary> </summary>
</member> </member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByIntId.order">
<summary>
排序
</summary>
</member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByIntId.where"> <member name="P:CoreCms.Net.Model.FromBody.FMPageByIntId.where">
<summary> <summary>
判断条件 判断条件
@@ -9746,6 +9746,11 @@
根据String类型id加where查询条件和order排序获取列表(一般用于直接id分页) 根据String类型id加where查询条件和order排序获取列表(一般用于直接id分页)
</summary> </summary>
</member> </member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByStringId.id">
<summary>
序列
</summary>
</member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByStringId.page"> <member name="P:CoreCms.Net.Model.FromBody.FMPageByStringId.page">
<summary> <summary>
当前页码 当前页码
@@ -9756,21 +9761,16 @@
每页数据量 每页数据量
</summary> </summary>
</member> </member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByStringId.order">
<summary>
排序
</summary>
</member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByStringId.where">
<summary>
判断条件
</summary>
</member>
<member name="T:CoreCms.Net.Model.FromBody.FMPageByStringIdWhitStatus"> <member name="T:CoreCms.Net.Model.FromBody.FMPageByStringIdWhitStatus">
<summary> <summary>
根据String类型id加where查询条件和order排序获取列表(一般用于直接id分页) 根据String类型id加where查询条件和order排序获取列表(一般用于直接id分页)
</summary> </summary>
</member> </member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByStringIdWhitStatus.id">
<summary>
序列
</summary>
</member>
<member name="P:CoreCms.Net.Model.FromBody.FMPageByStringIdWhitStatus.page"> <member name="P:CoreCms.Net.Model.FromBody.FMPageByStringIdWhitStatus.page">
<summary> <summary>
当前页码 当前页码

View File

@@ -26,11 +26,6 @@ namespace CoreCms.Net.Model.FromBody
/// </summary> /// </summary>
public int limit { get; set; } = 10; public int limit { get; set; } = 10;
/// <summary>
/// 排序
/// </summary>
public string order { get; set; }
/// <summary> /// <summary>
/// 判断条件 /// 判断条件
/// </summary> /// </summary>
@@ -43,9 +38,14 @@ namespace CoreCms.Net.Model.FromBody
/// </summary> /// </summary>
public class FMPageByIntId public class FMPageByIntId
{ {
/// <summary>
/// 其他数据
/// </summary>
public object otherData { get; set; } public object otherData { get; set; }
/// <summary>
/// 序列
/// </summary>
public int id { get; set; } public int id { get; set; }
@@ -59,11 +59,6 @@ namespace CoreCms.Net.Model.FromBody
/// </summary> /// </summary>
public int limit { get; set; } = 10; public int limit { get; set; } = 10;
/// <summary>
/// 排序
/// </summary>
public string order { get; set; }
/// <summary> /// <summary>
/// 判断条件 /// 判断条件
/// </summary> /// </summary>
@@ -75,9 +70,11 @@ namespace CoreCms.Net.Model.FromBody
/// </summary> /// </summary>
public class FMPageByStringId public class FMPageByStringId
{ {
/// <summary>
/// 序列
/// </summary>
public string id { get; set; } public string id { get; set; }
/// <summary> /// <summary>
/// 当前页码 /// 当前页码
/// </summary> /// </summary>
@@ -87,16 +84,6 @@ namespace CoreCms.Net.Model.FromBody
/// 每页数据量 /// 每页数据量
/// </summary> /// </summary>
public int limit { get; set; } = 10; public int limit { get; set; } = 10;
/// <summary>
/// 排序
/// </summary>
public string order { get; set; }
/// <summary>
/// 判断条件
/// </summary>
public string where { get; set; }
} }
@@ -105,6 +92,9 @@ namespace CoreCms.Net.Model.FromBody
/// </summary> /// </summary>
public class FMPageByStringIdWhitStatus public class FMPageByStringIdWhitStatus
{ {
/// <summary>
/// 序列
/// </summary>
public string id { get; set; } public string id { get; set; }
/// <summary> /// <summary>

View File

@@ -139,82 +139,6 @@ namespace CoreCms.Net.Repository
return await DbBaseClient.Queryable<T>().WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync(); return await DbBaseClient.Queryable<T>().WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync();
} }
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="orderBy">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
public List<T> QueryListByClause(string strWhere, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return DbBaseClient.Queryable<T>()
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
.WhereIF(!string.IsNullOrEmpty(strWhere), strWhere)
.WithNoLockOrNot(blUseNoLock)
.WithCacheIF(isDataCache, cacheTimes)
.ToList();
}
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="orderBy">排序字段如name asc,age desc</param>
/// <returns>泛型实体集合</returns>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
public async Task<List<T>> QueryListByClauseAsync(string strWhere, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return await DbBaseClient.Queryable<T>()
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
.WhereIF(!string.IsNullOrEmpty(strWhere), strWhere)
.WithNoLockOrNot(blUseNoLock)
.WithCacheIF(isDataCache, cacheTimes)
.ToListAsync();
}
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="orderBy">排序字段如name asc,age desc</param>
/// <returns>泛型实体集合</returns>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return DbBaseClient.Queryable<T>()
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
.WhereIF(predicate != null, predicate)
.WithNoLockOrNot(blUseNoLock)
.WithCacheIF(isDataCache, cacheTimes)
.ToList();
}
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="orderBy">排序字段如name asc,age desc</param>
/// <returns>泛型实体集合</returns>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return await DbBaseClient.Queryable<T>()
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
.WhereIF(predicate != null, predicate)
.WithNoLockOrNot(blUseNoLock)
.WithCacheIF(isDataCache, cacheTimes)
.ToListAsync();
}
/// <summary> /// <summary>
/// 根据条件查询数据 /// 根据条件查询数据
/// </summary> /// </summary>
@@ -225,7 +149,7 @@ namespace CoreCms.Net.Repository
/// <param name="isDataCache">是否启用缓存</param> /// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param> /// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns> /// <returns>泛型实体集合</returns>
public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue) public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate = null, OrderByType orderByType = OrderByType.Asc, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{ {
return DbBaseClient.Queryable<T>() return DbBaseClient.Queryable<T>()
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType) .OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
@@ -245,7 +169,7 @@ namespace CoreCms.Net.Repository
/// <param name="isDataCache">是否启用缓存</param> /// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param> /// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns> /// <returns>泛型实体集合</returns>
public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue) public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate = null, OrderByType orderByType = OrderByType.Asc, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{ {
return await DbBaseClient.Queryable<T>() return await DbBaseClient.Queryable<T>()
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType) .OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
@@ -299,48 +223,6 @@ namespace CoreCms.Net.Repository
.ToListAsync(); .ToListAsync();
} }
/// <summary>
/// 根据条件查询一定数量数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="take">获取数量</param>
/// <param name="strOrderByFields">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, int take, string strOrderByFields = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return DbBaseClient.Queryable<T>()
.OrderByIF(!string.IsNullOrEmpty(strOrderByFields), strOrderByFields)
.Where(predicate)
.Take(take)
.WithNoLockOrNot(blUseNoLock)
.WithCacheIF(isDataCache, cacheTimes)
.ToList();
}
/// <summary>
/// 根据条件查询一定数量数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="take">获取数量</param>
/// <param name="strOrderByFields">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, int take, string strOrderByFields = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return await DbBaseClient.Queryable<T>()
.OrderByIF(!string.IsNullOrEmpty(strOrderByFields), strOrderByFields)
.Where(predicate)
.Take(take)
.WithNoLockOrNot(blUseNoLock)
.WithCacheIF(isDataCache, cacheTimes)
.ToListAsync();
}
/// <summary> /// <summary>
/// 根据条件查询数据 /// 根据条件查询数据
/// </summary> /// </summary>
@@ -597,54 +479,6 @@ namespace CoreCms.Net.Repository
: await DbBaseClient.Updateable(entity).ExecuteCommandHasChangeAsync(); : await DbBaseClient.Updateable(entity).ExecuteCommandHasChangeAsync();
} }
/// <summary>
/// 根据手写条件更新
/// </summary>
/// <param name="entity">实体数据</param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
public bool Update(T entity, string strWhere, bool isRemoveDataCache = false)
{
return isRemoveDataCache ? DbBaseClient.Updateable(entity).Where(strWhere).RemoveDataCache().ExecuteCommandHasChange() : DbBaseClient.Updateable(entity).Where(strWhere).ExecuteCommandHasChange();
}
/// <summary>
/// 根据手写条件更新
/// </summary>
/// <param name="entity">实体数据</param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
public async Task<bool> UpdateAsync(T entity, string strWhere, bool isRemoveDataCache = false)
{
return isRemoveDataCache
? await DbBaseClient.Updateable(entity).Where(strWhere).RemoveDataCache().ExecuteCommandHasChangeAsync()
: await DbBaseClient.Updateable(entity).Where(strWhere).ExecuteCommandHasChangeAsync();
}
/// <summary>
/// 根据手写sql语句更新数据
/// </summary>
/// <param name="strSql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public bool Update(string strSql, SugarParameter[] parameters = null)
{
return DbBaseClient.Ado.ExecuteCommand(strSql, parameters) > 0;
}
/// <summary>
/// 根据手写sql语句更新数据
/// </summary>
/// <param name="strSql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public async Task<bool> UpdateAsync(string strSql, SugarParameter[] parameters = null)
{
return await DbBaseClient.Ado.ExecuteCommandAsync(strSql, parameters) > 0;
}
/// <summary> /// <summary>
/// 更新某个字段 /// 更新某个字段
/// </summary> /// </summary>
@@ -672,45 +506,6 @@ namespace CoreCms.Net.Repository
: await DbBaseClient.Updateable<T>().SetColumns(columns).Where(where).ExecuteCommandHasChangeAsync(); : await DbBaseClient.Updateable<T>().SetColumns(columns).Where(where).ExecuteCommandHasChangeAsync();
} }
/// <summary>
/// 根据条件更新
/// </summary>
/// <param name="entity">实体数据</param>
/// <param name="lstColumns"></param>
/// <param name="lstIgnoreColumns"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
public async Task<bool> UpdateAsync(T entity, List<string> lstColumns, List<string> lstIgnoreColumns, string strWhere = "", bool isRemoveDataCache = false)
{
var up = DbBaseClient.Updateable(entity);
if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) up = up.IgnoreColumns(lstIgnoreColumns.ToArray());
if (lstColumns is { Count: > 0 }) up = up.UpdateColumns(lstColumns.ToArray());
if (!string.IsNullOrEmpty(strWhere)) up = up.Where(strWhere);
return isRemoveDataCache
? await up.RemoveDataCache().ExecuteCommandHasChangeAsync()
: await up.ExecuteCommandHasChangeAsync();
}
/// <summary>
/// 根据条件更新
/// </summary>
/// <param name="entity">实体数据</param>
/// <param name="lstColumns"></param>
/// <param name="lstIgnoreColumns"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache">是否清除缓存</param>
/// <returns></returns>
public bool Update(T entity, List<string> lstColumns, List<string> lstIgnoreColumns, string strWhere = "", bool isRemoveDataCache = false)
{
var up = DbBaseClient.Updateable(entity);
if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0)
up = up.IgnoreColumns(lstIgnoreColumns.ToArray());
if (lstColumns != null && lstColumns.Count > 0) up = up.UpdateColumns(lstColumns.ToArray());
if (!string.IsNullOrEmpty(strWhere)) up = up.Where(strWhere);
return isRemoveDataCache ? up.RemoveDataCache().ExecuteCommandHasChange() : up.ExecuteCommandHasChange();
}
#endregion #endregion
#region #region
@@ -1169,70 +964,6 @@ namespace CoreCms.Net.Repository
#region #region
/// <summary>
/// 根据条件查询分页数据
/// </summary>
/// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
public IPageList<T> QueryPage(Expression<Func<T, bool>> predicate, string orderBy = "", int pageIndex = 1,
int pageSize = 20, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
var totalCount = 0;
var page = blUseNoLock
? DbBaseClient.Queryable<T>()
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
.WhereIF(predicate != null, predicate)
.WithNoLockOrNot(blUseNoLock)
.WithCacheIF(isDataCache, cacheTimes)
.ToPageList(pageIndex, pageSize, ref totalCount)
: DbClient.Queryable<T>()
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
.WhereIF(predicate != null, predicate)
.WithCacheIF(isDataCache, cacheTimes)
.ToPageList(pageIndex, pageSize, ref totalCount);
var list = new PageList<T>(page, pageIndex, pageSize, totalCount);
return list;
}
/// <summary>
/// 根据条件查询分页数据
/// </summary>
/// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
public async Task<IPageList<T>> QueryPageAsync(Expression<Func<T, bool>> predicate, string orderBy = "",
int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
RefAsync<int> totalCount = 0;
var page = blUseNoLock
? await DbBaseClient.Queryable<T>()
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
.WhereIF(predicate != null, predicate)
.WithNoLockOrNot(blUseNoLock)
.WithCacheIF(isDataCache, cacheTimes)
.ToPageListAsync(pageIndex, pageSize, totalCount)
: await DbBaseClient.Queryable<T>()
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
.WhereIF(predicate != null, predicate)
.WithCacheIF(isDataCache, cacheTimes)
.ToPageListAsync(pageIndex, pageSize, totalCount);
var list = new PageList<T>(page, pageIndex, pageSize, totalCount);
return list;
}
/// <summary> /// <summary>
/// 根据条件查询分页数据 /// 根据条件查询分页数据
/// </summary> /// </summary>

View File

@@ -193,7 +193,7 @@ namespace CoreCms.Net.Repository
obj.points = p.points; obj.points = p.points;
obj.isDefalut = p.isDefalut; obj.isDefalut = p.isDefalut;
obj.isDel = false; obj.isDel = false;
obj.images=p.images; obj.images = p.images;
products.Add(obj); products.Add(obj);
var pd = new CoreCmsProductsDistribution(); var pd = new CoreCmsProductsDistribution();
@@ -1671,13 +1671,11 @@ namespace CoreCms.Net.Repository
/// 重写根据条件及自定义排序查询分页数据返回DTO /// 重写根据条件及自定义排序查询分页数据返回DTO
/// </summary> /// </summary>
/// <param name="predicate"></param> /// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param> /// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param> /// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param> /// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns> /// <returns></returns>
public async Task<IPageList<GoodListDTO>> QueryPageByDTOAsync(Expression<Func<GoodListDTO, bool>> predicate, string orderBy = "", public async Task<IPageList<GoodListDTO>> QueryPageByDTOAsync(Expression<Func<GoodListDTO, bool>> predicate, int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false)
int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false)
{ {
RefAsync<int> totalCount = 0; RefAsync<int> totalCount = 0;
List<GoodListDTO> page; List<GoodListDTO> page;
@@ -1720,7 +1718,7 @@ namespace CoreCms.Net.Repository
.With(SqlWith.NoLock) .With(SqlWith.NoLock)
.MergeTable() .MergeTable()
.Where(predicate) .Where(predicate)
.OrderBy(orderBy) .OrderBy(it => SqlFunc.Desc(it.isRecommend)).OrderBy(it => SqlFunc.Desc(it.isHot))
.ToPageListAsync(pageIndex, pageSize, totalCount); .ToPageListAsync(pageIndex, pageSize, totalCount);
} }
else else
@@ -1761,7 +1759,7 @@ namespace CoreCms.Net.Repository
}) })
.MergeTable() .MergeTable()
.Where(predicate) .Where(predicate)
.OrderBy(orderBy) .OrderBy(it => SqlFunc.Desc(it.isRecommend)).OrderBy(it => SqlFunc.Desc(it.isHot))
.ToPageListAsync(pageIndex, pageSize, totalCount); .ToPageListAsync(pageIndex, pageSize, totalCount);
} }
var list = new PageList<GoodListDTO>(page, pageIndex, pageSize, totalCount); var list = new PageList<GoodListDTO>(page, pageIndex, pageSize, totalCount);
@@ -1783,7 +1781,7 @@ namespace CoreCms.Net.Repository
/// <param name="pageSize">分布大小</param> /// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param> /// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns> /// <returns></returns>
public async Task<IPageList<CoreCmsGoods>> QueryAgentGoodsPageAsync(Expression<Func<CoreCmsGoods, bool>> predicate, string orderBy = "", public async Task<IPageList<CoreCmsGoods>> QueryAgentGoodsPageAsync(Expression<Func<CoreCmsGoods, bool>> predicate,
int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false) int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false)
{ {
RefAsync<int> totalCount = 0; RefAsync<int> totalCount = 0;
@@ -1840,7 +1838,7 @@ namespace CoreCms.Net.Repository
.With(SqlWith.NoLock) .With(SqlWith.NoLock)
.MergeTable() .MergeTable()
.Where(predicate) .Where(predicate)
.OrderBy(orderBy) .OrderBy(it => SqlFunc.Desc(it.isRecommend)).OrderBy(it => SqlFunc.Desc(it.isHot))
.ToPageListAsync(pageIndex, pageSize, totalCount); .ToPageListAsync(pageIndex, pageSize, totalCount);
} }
else else
@@ -1894,7 +1892,7 @@ namespace CoreCms.Net.Repository
}) })
.MergeTable() .MergeTable()
.Where(predicate) .Where(predicate)
.OrderBy(orderBy) .OrderBy(it => SqlFunc.Desc(it.isRecommend)).OrderBy(it => SqlFunc.Desc(it.isHot))
.ToPageListAsync(pageIndex, pageSize, totalCount); .ToPageListAsync(pageIndex, pageSize, totalCount);
} }
var list = new PageList<CoreCmsGoods>(page, pageIndex, pageSize, totalCount); var list = new PageList<CoreCmsGoods>(page, pageIndex, pageSize, totalCount);

View File

@@ -130,62 +130,6 @@ namespace CoreCms.Net.Services
return await BaseDal.QueryAsync(blUseNoLock, isDataCache, cacheTimes); return await BaseDal.QueryAsync(blUseNoLock, isDataCache, cacheTimes);
} }
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="orderBy">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
public List<T> QueryListByClause(string strWhere, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return BaseDal.QueryListByClause(strWhere, orderBy, blUseNoLock, isDataCache, cacheTimes);
}
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="orderBy">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
public async Task<List<T>> QueryListByClauseAsync(string strWhere, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return await BaseDal.QueryListByClauseAsync(strWhere, orderBy, blUseNoLock, isDataCache, cacheTimes);
}
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="orderBy">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return BaseDal.QueryListByClause(predicate, orderBy, blUseNoLock, isDataCache, cacheTimes);
}
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="orderBy">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns>
public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return await BaseDal.QueryListByClauseAsync(predicate, orderBy, blUseNoLock, isDataCache, cacheTimes);
}
/// <summary> /// <summary>
/// 根据条件查询数据 /// 根据条件查询数据
/// </summary> /// </summary>
@@ -196,7 +140,7 @@ namespace CoreCms.Net.Services
/// <param name="isDataCache">是否启用缓存</param> /// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param> /// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns> /// <returns>泛型实体集合</returns>
public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue) public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate = null, OrderByType orderByType = OrderByType.Asc, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{ {
return BaseDal.QueryListByClause(predicate, orderByPredicate, orderByType, blUseNoLock, isDataCache, cacheTimes); return BaseDal.QueryListByClause(predicate, orderByPredicate, orderByType, blUseNoLock, isDataCache, cacheTimes);
} }
@@ -211,7 +155,7 @@ namespace CoreCms.Net.Services
/// <param name="isDataCache">是否启用缓存</param> /// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param> /// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns>泛型实体集合</returns> /// <returns>泛型实体集合</returns>
public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue) public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate = null, OrderByType orderByType = OrderByType.Asc, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{ {
return await BaseDal.QueryListByClauseAsync(predicate, orderByPredicate, orderByType, blUseNoLock, isDataCache, cacheTimes); return await BaseDal.QueryListByClauseAsync(predicate, orderByPredicate, orderByType, blUseNoLock, isDataCache, cacheTimes);
} }
@@ -248,36 +192,6 @@ namespace CoreCms.Net.Services
return await BaseDal.QueryListByClauseAsync(predicate, take, orderByPredicate, orderByType, blUseNoLock, isDataCache, cacheTimes); return await BaseDal.QueryListByClauseAsync(predicate, take, orderByPredicate, orderByType, blUseNoLock, isDataCache, cacheTimes);
} }
/// <summary>
/// 根据条件查询一定数量数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="take">获取数量</param>
/// <param name="strOrderByFields">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, int take, string strOrderByFields = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return BaseDal.QueryListByClause(predicate, take, strOrderByFields, blUseNoLock, isDataCache, cacheTimes);
}
/// <summary>
/// 根据条件查询一定数量数据
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="take">获取数量</param>
/// <param name="strOrderByFields">排序字段如name asc,age desc</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, int take, string strOrderByFields = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return await BaseDal.QueryListByClauseAsync(predicate, take, strOrderByFields, blUseNoLock, isDataCache, cacheTimes);
}
/// <summary> /// <summary>
/// 根据条件查询数据 /// 根据条件查询数据
/// </summary> /// </summary>
@@ -494,52 +408,6 @@ namespace CoreCms.Net.Services
return await BaseDal.UpdateAsync(entity, isRemoveDataCache); return await BaseDal.UpdateAsync(entity, isRemoveDataCache);
} }
/// <summary>
/// 根据手写条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache"></param>
/// <returns></returns>
public bool Update(T entity, string strWhere, bool isRemoveDataCache = false)
{
return BaseDal.Update(entity, strWhere, isRemoveDataCache);
}
/// <summary>
/// 根据手写条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache"></param>
/// <returns></returns>
public async Task<bool> UpdateAsync(T entity, string strWhere, bool isRemoveDataCache = false)
{
return await BaseDal.UpdateAsync(entity, strWhere, isRemoveDataCache);
}
/// <summary>
/// 根据手写sql语句更新数据
/// </summary>
/// <param name="strSql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public bool Update(string strSql, SugarParameter[] parameters = null)
{
return BaseDal.Update(strSql, parameters);
}
/// <summary>
/// 根据手写sql语句更新数据
/// </summary>
/// <param name="strSql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public async Task<bool> UpdateAsync(string strSql, SugarParameter[] parameters = null)
{
return await BaseDal.UpdateAsync(strSql, parameters);
}
/// <summary> /// <summary>
/// 更新某个字段 /// 更新某个字段
/// </summary> /// </summary>
@@ -564,33 +432,6 @@ namespace CoreCms.Net.Services
return await BaseDal.UpdateAsync(columns, where, isRemoveDataCache); return await BaseDal.UpdateAsync(columns, where, isRemoveDataCache);
} }
/// <summary>
/// 根据条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="lstColumns"></param>
/// <param name="lstIgnoreColumns"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache"></param>
/// <returns></returns>
public async Task<bool> UpdateAsync(T entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string strWhere = "", bool isRemoveDataCache = false)
{
return await BaseDal.UpdateAsync(entity, lstColumns, lstIgnoreColumns, strWhere, isRemoveDataCache);
}
/// <summary>
/// 根据条件更新
/// </summary>
/// <param name="entity"></param>
/// <param name="lstColumns"></param>
/// <param name="lstIgnoreColumns"></param>
/// <param name="strWhere"></param>
/// <param name="isRemoveDataCache"></param>
/// <returns></returns>
public bool Update(T entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string strWhere = "", bool isRemoveDataCache = false)
{
return BaseDal.Update(entity, lstColumns, lstIgnoreColumns, strWhere, isRemoveDataCache);
}
#endregion #endregion
#region #region
@@ -1006,40 +847,6 @@ namespace CoreCms.Net.Services
#region #region
/// <summary>
/// 根据条件查询分页数据
/// </summary>
/// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
public IPageList<T> QueryPage(Expression<Func<T, bool>> predicate, string orderBy = "", int pageIndex = 1,
int pageSize = 20, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return BaseDal.QueryPage(predicate, orderBy, pageIndex, pageSize, blUseNoLock, isDataCache, cacheTimes);
}
/// <summary>
/// 根据条件查询分页数据
/// </summary>
/// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
/// <param name="isDataCache">是否启用缓存</param>
/// <param name="cacheTimes">缓存时长(分钟)</param>
/// <returns></returns>
public async Task<IPageList<T>> QueryPageAsync(Expression<Func<T, bool>> predicate, string orderBy = "",
int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return await BaseDal.QueryPageAsync(predicate, orderBy, pageIndex, pageSize, blUseNoLock, isDataCache, cacheTimes);
}
/// <summary> /// <summary>
/// 根据条件查询分页数据 /// 根据条件查询分页数据
/// </summary> /// </summary>

View File

@@ -1010,10 +1010,9 @@ namespace CoreCms.Net.Services
/// <param name="pageSize">分布大小</param> /// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param> /// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns> /// <returns></returns>
public async Task<IPageList<GoodListDTO>> QueryPageByDTOAsync(Expression<Func<GoodListDTO, bool>> predicate, public async Task<IPageList<GoodListDTO>> QueryPageByDTOAsync(Expression<Func<GoodListDTO, bool>> predicate, int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false)
string orderBy = "", int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false)
{ {
return await _dal.QueryPageByDTOAsync(predicate, orderBy, pageIndex, pageSize, blUseNoLock); return await _dal.QueryPageByDTOAsync(predicate, pageIndex, pageSize, blUseNoLock);
} }
#endregion #endregion
@@ -1026,10 +1025,10 @@ namespace CoreCms.Net.Services
/// <param name="pageSize">分布大小</param> /// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param> /// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns> /// <returns></returns>
public async Task<IPageList<CoreCmsGoods>> QueryAgentGoodsPageAsync(Expression<Func<CoreCmsGoods, bool>> predicate, string orderBy = "", public async Task<IPageList<CoreCmsGoods>> QueryAgentGoodsPageAsync(Expression<Func<CoreCmsGoods, bool>> predicate,
int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false) int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false)
{ {
return await _dal.QueryAgentGoodsPageAsync(predicate, orderBy, pageIndex, pageSize, blUseNoLock); return await _dal.QueryAgentGoodsPageAsync(predicate, pageIndex, pageSize, blUseNoLock);
} }

View File

@@ -190,7 +190,7 @@ namespace CoreCms.Net.Services
var dtoData = new List<GroupPurchaseSeckillDTO>(); var dtoData = new List<GroupPurchaseSeckillDTO>();
var promotions = await _dal.QueryListByClauseAsync(p => p.isEnable == true && p.isDel == false && promotionIds.Contains(p.id), promotionIds.Length, "", true, true); var promotions = await _dal.QueryListByClauseAsync(p => p.isEnable == true && p.isDel == false && promotionIds.Contains(p.id), promotionIds.Length, p => p.id, OrderByType.Desc, true, true);
if (promotions != null && promotions.Any()) if (promotions != null && promotions.Any())
{ {
//获取团购序列 //获取团购序列

View File

@@ -197,21 +197,21 @@ namespace CoreCms.Net.Services
var result = JArray.Parse(parameters["list"].ToString()); var result = JArray.Parse(parameters["list"].ToString());
var noticeIds = result.Select(ss => ((JObject)ss)["id"].ObjectToInt(0)).Where(noticeId => noticeId > 0).ToList(); var noticeIds = result.Select(ss => ((JObject)ss)["id"].ObjectToInt(0)).Where(noticeId => noticeId > 0).ToList();
where = where.And(p => noticeIds.Contains(p.id)); where = where.And(p => noticeIds.Contains(p.id));
if (noticeIds.Any()) //if (noticeIds.Any())
{ //{
noticeIdsStr = string.Join(",", noticeIdsStr); // noticeIdsStr = string.Join(",", noticeIdsStr);
//按照固定的序列id进行排序 // //按照固定的序列id进行排序
if (AppSettingsConstVars.DbDbType == DbType.SqlServer.ToString()) // if (AppSettingsConstVars.DbDbType == DbType.SqlServer.ToString())
{ // {
orderBy = " CHARINDEX(RTRIM(CAST(id as NCHAR)),'" + noticeIdsStr + "') "; // orderBy = " CHARINDEX(RTRIM(CAST(id as NCHAR)),'" + noticeIdsStr + "') ";
} // }
else if (AppSettingsConstVars.DbDbType == DbType.MySql.ToString()) // else if (AppSettingsConstVars.DbDbType == DbType.MySql.ToString())
{ // {
orderBy = " find_in_set(id,'" + noticeIdsStr + "') "; // orderBy = " find_in_set(id,'" + noticeIdsStr + "') ";
} // }
} //}
} }
var notices = await _noticeServices.QueryListByClauseAsync(where, orderBy); var notices = await _noticeServices.QueryListByClauseAsync(where, p => p.createTime, OrderByType.Desc);
if (notices != null && notices.Any()) if (notices != null && notices.Any())
{ {
var result = JArray.FromObject(notices); var result = JArray.FromObject(notices);

View File

@@ -1243,7 +1243,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
r.AddRange(arr); r.AddRange(arr);
}); });
var labels = _labelServices.QueryListByClause(p => r.Contains(p.id)); var labels =await _labelServices.QueryListByClauseAsync(p => r.Contains(p.id));
jm.code = 0; jm.code = 0;
jm.data = new jm.data = new

View File

@@ -162,13 +162,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
} }
} }
var orderBy = " isRecommend desc,isHot desc"; var list = await _goodsServices.QueryAgentGoodsPageAsync(where, entity.page, entity.limit, true);
if (!string.IsNullOrEmpty(entity.order))
{
orderBy += "," + entity.order;
}
var list = await _goodsServices.QueryAgentGoodsPageAsync(where, orderBy, entity.page, entity.limit, false);
if (list.Any()) if (list.Any())
{ {
foreach (var goods in list) foreach (var goods in list)
@@ -188,7 +182,6 @@ namespace CoreCms.Net.Web.WebApi.Controllers
list.TotalPages, list.TotalPages,
entity.limit, entity.limit,
entity.where, entity.where,
entity.order,
}; };
jm.msg = "数据调用成功!"; jm.msg = "数据调用成功!";

View File

@@ -249,13 +249,8 @@ namespace CoreCms.Net.Web.WebApi.Controllers
where = where.And(p => p.name.Contains(obj.searchName)); where = where.And(p => p.name.Contains(obj.searchName));
} }
} }
var orderBy = " isRecommend desc,isHot desc,sort desc";
if (!string.IsNullOrWhiteSpace(entity.order))
{
orderBy += "," + entity.order;
}
//获取数据 //获取数据
var list = await _goodsServices.QueryPageByDTOAsync(where, orderBy, entity.page, entity.limit, true); var list = await _goodsServices.QueryPageByDTOAsync(where, entity.page, entity.limit, true);
//获取品牌 //获取品牌
var brands = await _brandServices.QueryListByClauseAsync(p => p.isShow == true, p => p.sort, OrderByType.Desc, true, true); var brands = await _brandServices.QueryListByClauseAsync(p => p.isShow == true, p => p.sort, OrderByType.Desc, true, true);
@@ -271,7 +266,6 @@ namespace CoreCms.Net.Web.WebApi.Controllers
list.TotalPages, list.TotalPages,
entity.limit, entity.limit,
entity.where, entity.where,
entity.order,
brands brands
}; };
jm.msg = "数据调用成功!"; jm.msg = "数据调用成功!";