| | |
| | | public class DictionaryDatasQueryHandler( |
| | | IRepository<DictionaryData> rep |
| | | ) : IRequestHandler<GetDictionaryDatasQuery, PagedListQueryResult<GetDictionaryDatasQueryResultItem>>, |
| | | IRequestHandler<GetDictionaryDataSelectQuery, List<SelectQueryResultOption<Guid, GetDictionaryDataSelectQueryResultOption>>> |
| | | IRequestHandler<GetDictionaryDataSelectQuery, List<SelectOption<Guid, GetDictionaryDataSelectQueryResultOption>>> |
| | | { |
| | | private readonly IRepository<DictionaryData> rep = rep; |
| | | |
| | |
| | | { |
| | | throw Oops.Oh(EnumErrorCodeType.s400, "请填写类别Id或编号"); |
| | | } |
| | | if (request.ParentId.HasValue) |
| | | { |
| | | q = q.Where(it => it.ParentId == request.ParentId); |
| | | } |
| | | if (request.Keywords.IsNotNull()) |
| | | { |
| | | q = q.Where(it => |
| | |
| | | /// <param name="request"></param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | public Task<List<SelectQueryResultOption<Guid, GetDictionaryDataSelectQueryResultOption>>> Handle(GetDictionaryDataSelectQuery request, CancellationToken cancellationToken) |
| | | public Task<List<SelectOption<Guid, GetDictionaryDataSelectQueryResultOption>>> Handle(GetDictionaryDataSelectQuery request, CancellationToken cancellationToken) |
| | | { |
| | | return request.GetSelect<DictionaryData, Guid, GetDictionaryDataSelectQueryResultOption>( |
| | | it => it.Id, |
| | |
| | | { |
| | | q = q |
| | | .OrderBy(it => it.Sort).ThenBy(it => it.CreatedTime) |
| | | .Where(it => |
| | | it.ParentId == request.ParentId |
| | | && !it.IsDisabled); |
| | | .Where(it => !it.IsDisabled); |
| | | if (!request.All) |
| | | { |
| | | q = q.Where(it => it.ParentId == request.ParentId); |
| | | } |
| | | 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)); |
| | | } |
| | | if (request.CategoryId.HasValue) |
| | | { |
| | | q = q.Where(it => it.CategoryId == request.CategoryId); |