using Antis.Erp.Application.Contracts.Dtos.News;
using Antis.Erp.Application.Contracts.IServices;
using Antis.Erp.Domain.Entities;
using SqlSugar;
using Volo.Abp.Application.Dtos;
using Yi.Framework.Ddd.Application;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Antis.Erp.Application.Services
{
///
/// 新闻服务实现
///
public class NewsService : YiCrudAppService,
INewsService
{
private ISqlSugarRepository _repository;
public NewsService(ISqlSugarRepository repository) : base(repository)
{
_repository = repository;
}
///
/// 多查(分页查询)
///
///
///
public override async Task> GetListAsync(NewsGetListInputVo input)
{
RefAsync total = 0;
var entities = await _repository._DbQueryable
.WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title!))
.WhereIF(!string.IsNullOrEmpty(input.Author), x => x.Author != null && x.Author.Contains(input.Author!))
.WhereIF(!string.IsNullOrEmpty(input.Category), x => x.Category == input.Category)
.WhereIF(input.State is not null, x => x.State == input.State)
.WhereIF(input.StartTime is not null && input.EndTime is not null,
x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
.OrderByDescending(x => x.CreationTime)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto(total, await MapToGetListOutputDtosAsync(entities));
}
}
}