using FlexJobApi.Core;
using Furion.DatabaseAccessor;
using MediatR;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FlexJobApi.FlexJobServer.Application
{
///
/// 任务雇佣查询处理器
///
public class TaskUserQueryHandler(
IRepository rep)
: IRequestHandler
{
private readonly IRepository rep = rep;
///
/// B端查询应聘报名分页列表信息
///
///
///
///
public async Task Handle(GetTaskUsersQuery request, CancellationToken cancellationToken)
{
var logier = JwtUtils.GetCurrentLogier();
var q = rep.AsQueryable().AsNoTracking()
.OrderBy(it => it.CreatedTime)
.Where(it => it.TaskInfo.EnterpriseId == logier.EnterpriseId && it.TaskInfoId == request.Id);
var s = q
.Select(it => new GetTaskUsersQueryResultItem
{
Id = it.Id,
Avatar = it.EnterpriseEmployee.User.Avatar,
Name = it.EnterpriseEmployee.User.Name,
Identity = it.EnterpriseEmployee.User.Identity,
ContactPhoneNumber = it.EnterpriseEmployee.User.ContactPhoneNumber,
Gender = it.EnterpriseEmployee.User.Gender,
Age = it.EnterpriseEmployee.User.Age,
IsReal = it.EnterpriseEmployee.User.IsReal,
RealMethod = it.EnterpriseEmployee.User.RealMethod,
PersonalIdentityCode = it.EnterpriseEmployee.User.PersonalIdentityCode,
PersonalIdentityContent = it.EnterpriseEmployee.User.PersonalIdentity.Content,
EducationalBackgroundCode = it.EnterpriseEmployee.User.EducationalBackgroundCode,
EducationalBackgroundContent = it.EnterpriseEmployee.User.EducationalBackground.Content,
TaskCount = it.EnterpriseEmployee.User.TaskInfoUsers.Count(tu => tu.EnterpriseEmployee.HireStatus == EnumTaskUserHireStatus.Pass),
WorkSeniority = it.EnterpriseEmployee.User.WorkSeniority,
WorkExperience = it.EnterpriseEmployee.User.WorkExperience,
HireStatus = it.EnterpriseEmployee.HireStatus
});
return await request.PageModel.GetPagedListAsync(s, cancellationToken);
}
}
}