| | |
| | | using FlexJobApi.Core; |
| | | using Furion.DatabaseAccessor; |
| | | using Mapster; |
| | | using MediatR; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | |
| | | /// <summary> |
| | | /// 获取字典数据分页列表 |
| | | /// </summary> |
| | | public class GetDictionaryDatasQueryHandler : IRequestHandler<GetDictionaryDatasQuery, PagedListQueryResult<GetDictionaryDatasQueryResultItem>> |
| | | public class GetDictionaryDatasQueryHandler( |
| | | IRepository<DictionaryData> rep |
| | | ) : IRequestHandler<GetDictionaryDatasQuery, PagedListQueryResult<GetDictionaryDatasQueryResultItem>> |
| | | { |
| | | public Task<PagedListQueryResult<GetDictionaryDatasQueryResultItem>> Handle(GetDictionaryDatasQuery request, CancellationToken cancellationToken) |
| | | private readonly IRepository<DictionaryData> rep = rep; |
| | | |
| | | public async Task<PagedListQueryResult<GetDictionaryDatasQueryResultItem>> Handle(GetDictionaryDatasQuery request, CancellationToken cancellationToken) |
| | | { |
| | | throw new NotImplementedException(); |
| | | var q = rep.AsQueryable().AsNoTracking() |
| | | .OrderBy(it => it.Sort).ThenByDescending(it => it.CreatedTime) |
| | | .Where(it => it.CategoryId == request.CategoryId); |
| | | if (request.Keywords.IsNotNull()) |
| | | { |
| | | q = q.Where(it => |
| | | it.Code.Contains(request.Keywords) |
| | | || it.Content.Contains(request.Keywords) |
| | | || it.Field1.Contains(request.Keywords) |
| | | || it.Field2.Contains(request.Keywords) |
| | | || it.Field3.Contains(request.Keywords) |
| | | || it.Field4.Contains(request.Keywords) |
| | | || it.Field5.Contains(request.Keywords)); |
| | | } |
| | | var result = await q |
| | | .ProjectToType<GetDictionaryDatasQueryResultItem>() |
| | | .ToPagedListAsync(request.PageModel, cancellationToken); |
| | | return result; |
| | | } |
| | | } |
| | | } |