using FlexJobApi.Core;
|
using MediatR;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace FlexJobApi.User.Application
|
{
|
/// <summary>
|
/// 企业查询处理器
|
/// </summary>
|
public class EnterprisesQueryHandler
|
: IRequestHandler<GetEnterprisesQuery, PagedListQueryResult<GetEnterprisesQueryResultItem>>
|
{
|
/// <summary>
|
/// 查询企业信息分页列表数据
|
/// </summary>
|
/// <param name="request"></param>
|
/// <param name="cancellationToken"></param>
|
/// <returns></returns>
|
public Task<PagedListQueryResult<GetEnterprisesQueryResultItem>> Handle(GetEnterprisesQuery request, CancellationToken cancellationToken)
|
{
|
return request.PageModel.GetPagedListAsync<Enterprise, GetEnterprisesQueryResultItem>(
|
q =>
|
{
|
if (request.Keywords.IsNotNull())
|
{
|
q = q.Where(it =>
|
it.EnterpriseAuth.EnterpriseName.Contains(request.Keywords)
|
|| it.EnterpriseAuth.LegalPerson.Contains(request.Keywords)
|
|| it.Contacts.Contains(request.Keywords));
|
}
|
if (request.IsConfigured.HasValue)
|
{
|
q = q.Where(it => (it.IsCheckedBankCard && it.RealAccess.HasValue && it.SmsAccess.HasValue) == request.IsConfigured);
|
}
|
return q;
|
}, cancellationToken: cancellationToken);
|
}
|
}
|
}
|