CMS/Yuebon.CMS.Services/ArticlenewsService.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
namespace Yuebon.CMS.Services
{
/// <summary>
/// 文章服务接口实现
/// </summary>
public class ArticlenewsService : BaseService<Articlenews, ArticlenewsOutputDto>, IArticlenewsService
{
private readonly IArticlecategoryRepository _articlecategoryRepository;
public ArticlenewsService(IArticlenewsRepository _repository, IArticlecategoryRepository articlecategoryRepository)
{
repository = _repository;
_articlecategoryRepository = articlecategoryRepository;
}
/// <summary>
/// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
/// </summary>
/// <param name="search">查询的条件</param>
/// <returns>指定对象的集合</returns>
public override async Task<PageResult<ArticlenewsOutputDto>> FindWithPagerAsync(SearchInputDto<Articlenews> search)
{
bool order = search.Order == "asc" ? false : true;
string where = GetDataPrivilege();
if (search.Keywords is { Length: > 0 })
{
where += string.Format(" and Title like '%{0}%'", search.Keywords);
};
PagerInfo pagerInfo = new PagerInfo
{
CurrenetPageIndex = search.CurrenetPageIndex,
PageSize = search.PageSize
};
List<Articlenews> list = await repository.FindWithPagerAsync(where, pagerInfo, search.Sort, order);
PageResult<ArticlenewsOutputDto> pageResult = new PageResult<ArticlenewsOutputDto>
{
CurrentPage = pagerInfo.CurrenetPageIndex,
Items = list.MapTo<ArticlenewsOutputDto>(),
ItemsPerPage = pagerInfo.PageSize,
TotalItems = pagerInfo.RecordCount
};
return pageResult;
}
/// <summary>
/// 根据用户角色获取分类及该分类的文章
/// </summary>
/// <returns></returns>
public async Task<List<CategoryArticleOutputDto>> GetCategoryArticleList()
{
string where = "ParentId='2021013118255576392825'";
IEnumerable<Articlecategory> list = await _articlecategoryRepository.GetAllByIsNotDeleteAndEnabledMarkAsync(where);
List<CategoryArticleOutputDto> resultList = new List<CategoryArticleOutputDto>();
foreach (Articlecategory item in list)
{
CategoryArticleOutputDto categoryArticleOutputDto = new CategoryArticleOutputDto();
categoryArticleOutputDto.Id = item.Id;
categoryArticleOutputDto.Title = item.Title;
categoryArticleOutputDto.SubTitle = item.SeoTitle;
后面还有 20 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。