From 295f9f543d9a7224eacf91e8fadfbf1a89a2ddad Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期三, 13 八月 2025 15:56:07 +0800
Subject: [PATCH] feat:开发

---
 FlexJobApi.UserServer.Application/EnterpriseEmployees/Queries/EnterpriseEmployeeQueryHandler.cs |   65 ++++++++++++++++++++++++++++++--
 1 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/FlexJobApi.UserServer.Application/EnterpriseEmployees/Queries/EnterpriseEmployeeQueryHandler.cs b/FlexJobApi.UserServer.Application/EnterpriseEmployees/Queries/EnterpriseEmployeeQueryHandler.cs
index d559f19..f59f0f7 100644
--- a/FlexJobApi.UserServer.Application/EnterpriseEmployees/Queries/EnterpriseEmployeeQueryHandler.cs
+++ b/FlexJobApi.UserServer.Application/EnterpriseEmployees/Queries/EnterpriseEmployeeQueryHandler.cs
@@ -17,7 +17,8 @@
     public class EnterpriseEmployeeQueryHandler(
             IRepository<EnterpriseEmployee> rep
         ) :
-        IRequestHandler<GetEnterpriseEmployeesQuery, GetEnterpriseEmployeesQueryResult>
+        IRequestHandler<GetEnterpriseEmployeesQuery, GetEnterpriseEmployeesQueryResult>,
+        IRequestHandler<GetEnterpriseEmployeeQuery, GetEnterpriseEmployeeQueryResult>
     {
         private readonly IRepository<EnterpriseEmployee> rep = rep;
 
@@ -32,12 +33,12 @@
             var logier = JwtUtils.GetCurrentLogier();
             var q = rep.AsQueryable().AsNoTracking()
                 .OrderBy(it => it.CreatedTime)
-                .Where(it => it.EnterpriseId == logier.Id);
+                .Where(it => it.EnterpriseId == logier.EnterpriseId);
             if (request.Keywords.IsNotNull())
             {
                 q = q.Where(it =>
                     it.Name.Contains(request.Keywords)
-                    || it.PhoneNumber.Contains(request.Keywords)
+                    || it.ContactPhoneNumber.Contains(request.Keywords)
                     || it.Identity.Contains(request.Keywords));
             }
             if (request.CreatedTimeStart.HasValue && request.CreatedTimeEnd.HasValue)
@@ -70,8 +71,64 @@
             {
                 q = q.Where(it => it.EnterpriseSignContractStatus == request.EnterpriseSignContractStatus);
             }
-            var s = q.ProjectToType<GetEnterpriseEmployeesQueryResultItem>();
+            var s = q.Select(it => new GetEnterpriseEmployeesQueryResultItem
+            {
+                Id = it.Id,
+                Avatar = it.User.Avatar,
+                Name = it.Name,
+                Identity = it.Identity,
+                Gender = it.Gender,
+                Age = it.Age,
+                ContactPhoneNumber = it.ContactPhoneNumber,
+                UserIsReal = it.User.IsReal,
+                RealMethod = it.User.RealMethod,
+                PersonalIdentityCode = it.User.PersonalIdentityCode,
+                PersonalIdentityContent = it.User.PersonalIdentity.Content,
+                EducationalBackgroundCode = it.User.EducationalBackgroundCode,
+                EducationalBackgroundContent = it.User.EducationalBackground.Content,
+                TaskCount = it.User.EnterpriseEmployees.Where(ee => ee.HireStatus == EnumTaskUserHireStatus.Pass).Sum(ee => ee.TaskInfoUsers.Count()),
+                WorkSeniority = it.User.WorkSeniority,
+                WorkExperience = it.User.WorkExperience,
+                HireStatus = it.HireStatus,
+                UserSignContractStatus = it.UserSignContractStatus,
+                HireTime = it.HireTime,
+                UserRealTime = it.User.RealTime,
+                UserSignContractTime = it.UserSignContractTime,
+                EnterpriseSignContractStatus = it.EnterpriseSignContractStatus,
+                EnterpriseSignContractTime = it.EnterpriseSignContractTime
+            });
             return await request.PageModel.GetPagedListAsync<GetEnterpriseEmployeesQueryResult, GetEnterpriseEmployeesQueryResultItem>(s, cancellationToken);
         }
+
+        /// <summary>
+        /// 鏌ヨ鐏靛伐璇︽儏
+        /// </summary>
+        /// <param name="request"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<GetEnterpriseEmployeeQueryResult> Handle(GetEnterpriseEmployeeQuery request, CancellationToken cancellationToken)
+        {
+            var logier = JwtUtils.GetCurrentLogier();
+            var model = await rep.AsQueryable().AsNoTracking()
+                .Where(it => it.Id == request.Id)
+                .GetDetail<EnterpriseEmployee, GetEnterpriseEmployeeQueryResult>(cancellationToken);
+            if (request.TaskInfoId.HasValue)
+            {
+                model.ApplyTime = await rep.Change<TaskInfoUser>().AsQueryable().AsNoTracking()
+                    .Where(it => it.TaskInfoId == request.TaskInfoId && it.EnterpriseEmployeeId == request.Id)
+                    .Select(it => it.CreatedTime as DateTimeOffset?)
+                    .FirstOrDefaultAsync(cancellationToken);
+            }
+            else if (logier.Type == EnumUserType.Enterprise)
+            {
+                model.ApplyTime = await rep.Change<TaskInfoUser>().AsQueryable().AsNoTracking()
+                    .OrderBy(it => it.CreatedTime)
+                    .Where(it => it.TaskInfo.EnterpriseId == logier.EnterpriseId && it.EnterpriseEmployeeId == request.Id)
+                    .Select(it => it.CreatedTime as DateTimeOffset?)
+                    .FirstOrDefaultAsync(cancellationToken);
+            }
+            
+            return model;
+        }
     }
 }

--
Gitblit v1.9.1