mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 19:13:26 +08:00
【新增】WebApi文章Controller新增【获取最新文章】【获取文章栏目】两个接口
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.IRepository;
|
||||
@@ -128,5 +129,41 @@ namespace CoreCms.Net.Repository
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 重写根据条件查询分页数据
|
||||
|
||||
/// <summary>
|
||||
/// 重写根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsArticle>> QueryListAsync(Expression<Func<CoreCmsArticle, bool>> predicate,
|
||||
Expression<Func<CoreCmsArticle, object>> orderByExpression, OrderByType orderByType,int take)
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsArticle>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsArticle
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
brief = p.brief,
|
||||
coverImage = p.coverImage,
|
||||
typeId = p.typeId,
|
||||
sort = p.sort,
|
||||
isPub = p.isPub,
|
||||
isDel = p.isDel,
|
||||
pv = p.pv,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime
|
||||
}).Take(take).ToListAsync();
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user