NewsService.cs
2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
{
/// <summary>
/// 新闻服务实现
/// </summary>
public class NewsService : YiCrudAppService<TestNewAggregateRoot, NewsGetOutputDto, NewsGetListOutputDto, Guid,
NewsGetListInputVo, NewsCreateInputVo, NewsUpdateInputVo>,
INewsService
{
private ISqlSugarRepository<TestNewAggregateRoot, Guid> _repository;
public NewsService(ISqlSugarRepository<TestNewAggregateRoot, Guid> repository) : base(repository)
{
_repository = repository;
}
/// <summary>
/// 多查(分页查询)
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<PagedResultDto<NewsGetListOutputDto>> GetListAsync(NewsGetListInputVo input)
{
RefAsync<int> 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<NewsGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
}
}
}