CMS/Yuebon.CMS.Services/ArticlecategoryService.cs

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

namespace Yuebon.CMS.Services;

/// <summary>
/// 文章分类服务接口实现
/// </summary>
public class ArticlecategoryService: BaseService<Articlecategory,ArticlecategoryOutputDto>, IArticlecategoryService
{
    private readonly IArticlenewsRepository _articleRepository;
    public ArticlecategoryService(IArticlecategoryRepository arepository, IArticlenewsRepository articleRepository) 
    {
        repository = arepository;
        _articleRepository = articleRepository;
    }

    /// <summary>
    /// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
    /// </summary>
    /// <param name="search">查询的条件</param>
    /// <returns>指定对象的集合</returns>
    public override async Task<PageResult<ArticlecategoryOutputDto>> FindWithPagerAsync(SearchInputDto<Articlecategory> search)
    {
        bool order = search.Order == "asc" ? false : true;
        string where = GetDataPrivilege();
        if (search.Keywords is { Length: > 0 })
        {
            where += string.Format(" and  Title '%{0}%'", search.Keywords);
        };
        PagerInfo pagerInfo = new PagerInfo
        {
            CurrenetPageIndex = search.CurrenetPageIndex,
            PageSize = search.PageSize
        };
        List<Articlecategory> list = await repository.FindWithPagerAsync(where, pagerInfo, search.Sort, order);
        PageResult<ArticlecategoryOutputDto> pageResult = new PageResult<ArticlecategoryOutputDto>
        {
            CurrentPage = pagerInfo.CurrenetPageIndex,
            Items = list.MapTo<ArticlecategoryOutputDto>(),
            ItemsPerPage = pagerInfo.PageSize,
            TotalItems = pagerInfo.RecordCount
        };
        return pageResult;
    }


    /// <summary>
    /// 获取分类适用于Vue 树形列表,关键词为空时获取所有
    /// </summary>
    /// <param name="keyword">名称关键词</param>
    /// <returns></returns>
    public async Task<List<ArticlecategoryOutputDto>> GetAllArticlecategoryTreeTable(string keyword)
    {
        List<ArticlecategoryOutputDto> reslist = new List<ArticlecategoryOutputDto>();
        string where = "1=1";
        if(keyword is { Length: > 0 })
        {
            where = string.Format("Title like '%{0}%'", keyword);
        }
        where += " order by ClassLayer,SortCode";
        IEnumerable<Articlecategory> elist = await repository.GetListWhereAsync(where);
        if (elist.Count() >0)
后面还有 114 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。