From ba6a9c246898ecf04f40c827db27a1729f1b0f87 Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期四, 14 八月 2025 11:27:24 +0800 Subject: [PATCH] feat:开发 --- FlexJobApi.Core/Models/UserServer/EnterpriseEmployees/Commands/ImportEnterpriseEmployeesCommand.cs | 43 ++++++++++++- FlexJobApi.FlexJobServer.Application/TaskUsers/Queries/TaskUserQueryHandler.cs | 16 +++-- FlexJobApi.Core/FlexJobApi.Core.xml | 40 +++++++++++++ FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs | 22 ++++++- 4 files changed, 106 insertions(+), 15 deletions(-) diff --git a/FlexJobApi.Core/FlexJobApi.Core.xml b/FlexJobApi.Core/FlexJobApi.Core.xml index c1e1607..98aeda5 100644 --- a/FlexJobApi.Core/FlexJobApi.Core.xml +++ b/FlexJobApi.Core/FlexJobApi.Core.xml @@ -5788,6 +5788,11 @@ Excel鍦板潃 </summary> </member> + <member name="T:FlexJobApi.Core.ImportEnterpriseEmployeesCommandModel"> + <summary> + 瀵煎叆鐏靛伐淇℃伅-妯℃澘 + </summary> + </member> <member name="P:FlexJobApi.Core.ImportEnterpriseEmployeesCommandModel.Name"> <summary> 濮撳悕 @@ -5804,6 +5809,41 @@ 韬唤璇佸彿 </summary> </member> + <member name="T:FlexJobApi.Core.ImportEnterpriseEmployeesCommandResult"> + <summary> + 瀵煎叆鐏靛伐淇℃伅-缁撴灉 + </summary> + </member> + <member name="P:FlexJobApi.Core.ImportEnterpriseEmployeesCommandResult.TotalCount"> + <summary> + 鎬绘暟 + </summary> + </member> + <member name="P:FlexJobApi.Core.ImportEnterpriseEmployeesCommandResult.SuccessCount"> + <summary> + 鎴愬姛鏁伴噺 + </summary> + </member> + <member name="P:FlexJobApi.Core.ImportEnterpriseEmployeesCommandResult.FailCount"> + <summary> + 澶辫触鏁伴噺 + </summary> + </member> + <member name="P:FlexJobApi.Core.ImportEnterpriseEmployeesCommandResult.MyProperty"> + <summary> + 閿欒淇℃伅 + </summary> + </member> + <member name="T:FlexJobApi.Core.ImportEnterpriseEmployeesCommandResultError"> + <summary> + 瀵煎叆鐏靛伐淇℃伅-缁撴灉-閿欒淇℃伅 + </summary> + </member> + <member name="P:FlexJobApi.Core.ImportEnterpriseEmployeesCommandResultError.ErrorMessage"> + <summary> + 閿欒淇℃伅 + </summary> + </member> <member name="T:FlexJobApi.Core.GetEnterpriseEmployeeQuery"> <summary> 鏌ヨ鐏靛伐璇︽儏 diff --git a/FlexJobApi.Core/Models/UserServer/EnterpriseEmployees/Commands/ImportEnterpriseEmployeesCommand.cs b/FlexJobApi.Core/Models/UserServer/EnterpriseEmployees/Commands/ImportEnterpriseEmployeesCommand.cs index a9eaa68..713f542 100644 --- a/FlexJobApi.Core/Models/UserServer/EnterpriseEmployees/Commands/ImportEnterpriseEmployeesCommand.cs +++ b/FlexJobApi.Core/Models/UserServer/EnterpriseEmployees/Commands/ImportEnterpriseEmployeesCommand.cs @@ -15,7 +15,7 @@ /// 瀵煎叆鐏靛伐淇℃伅 /// </summary> [Resource([EnumResourceController.EnterpriseEmployee])] - public class ImportEnterpriseEmployeesCommand : IRequest<int> + public class ImportEnterpriseEmployeesCommand : IRequest<ImportEnterpriseEmployeesCommandResult> { /// <summary> /// Excel鍦板潃 @@ -23,26 +23,59 @@ public string ExcelUrl { get; set; } } + /// <summary> + /// 瀵煎叆鐏靛伐淇℃伅-妯℃澘 + /// </summary> public class ImportEnterpriseEmployeesCommandModel { /// <summary> /// 濮撳悕 /// </summary> - [Required] public string Name { get; set; } /// <summary> /// 鎵嬫満鍙� /// </summary> /// <remarks>鑱旂郴鐢佃瘽</remarks> - [MaxLength(11)] - [Required] public string ContactPhoneNumber { get; set; } /// <summary> /// 韬唤璇佸彿 /// </summary> - [Required] public string Identity { get; set; } } + + /// <summary> + /// 瀵煎叆鐏靛伐淇℃伅-缁撴灉 + /// </summary> + public class ImportEnterpriseEmployeesCommandResult + { + /// <summary> + /// 鎬绘暟 + /// </summary> + public int TotalCount { get; set; } + /// <summary> + /// 鎴愬姛鏁伴噺 + /// </summary> + public int SuccessCount { get; set; } + /// <summary> + /// 澶辫触鏁伴噺 + /// </summary> + public int FailCount { get; set; } + /// <summary> + /// 閿欒淇℃伅 + /// </summary> + public List<ImportEnterpriseEmployeesCommandResultError> MyProperty { get; set; } + } + + /// <summary> + /// 瀵煎叆鐏靛伐淇℃伅-缁撴灉-閿欒淇℃伅 + /// </summary> + public class ImportEnterpriseEmployeesCommandResultError : ImportEnterpriseEmployeesCommandModel + { + /// <summary> + /// 閿欒淇℃伅 + /// </summary> + public string ErrorMessage { get; set; } + } } diff --git a/FlexJobApi.FlexJobServer.Application/TaskUsers/Queries/TaskUserQueryHandler.cs b/FlexJobApi.FlexJobServer.Application/TaskUsers/Queries/TaskUserQueryHandler.cs index 77d1e44..bb14f0f 100644 --- a/FlexJobApi.FlexJobServer.Application/TaskUsers/Queries/TaskUserQueryHandler.cs +++ b/FlexJobApi.FlexJobServer.Application/TaskUsers/Queries/TaskUserQueryHandler.cs @@ -141,12 +141,16 @@ { throw Oops.Oh(EnumErrorCodeType.s400, "璇烽�夋嫨鐢ㄦ埛"); } - var model = await q - .Select(it => new GetTaskUserHireStatusQueryResult - { - HireStatus = it.EnterpriseEmployee.HireStatus - }) - .FirstOrDefaultAsync(cancellationToken); + else + { + q = q.Where(it => it.EnterpriseEmployee.UserId == request.UserId); + } + var model = await q + .Select(it => new GetTaskUserHireStatusQueryResult + { + HireStatus = it.EnterpriseEmployee.HireStatus + }) + .FirstOrDefaultAsync(cancellationToken); if (model == null) throw Oops.Oh(EnumErrorCodeType.s404, "璇ユ姤鍚嶄俊鎭�"); return model; } diff --git a/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs b/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs index cd62045..575f837 100644 --- a/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs +++ b/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs @@ -7,10 +7,12 @@ using MediatR; using Microsoft.EntityFrameworkCore; using MiniExcelLibs; +using NetTopologySuite.Index.HPRtree; using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace FlexJobApi.UserServer.Application @@ -21,7 +23,7 @@ public class EnterpriseEmployeesCommandHandler( IRepository<EnterpriseEmployee> rep ) : - IRequestHandler<ImportEnterpriseEmployeesCommand, int>, + IRequestHandler<ImportEnterpriseEmployeesCommand, ImportEnterpriseEmployeesCommandResult>, IRequestHandler<EditEnterpriseEmployeeCommand, Guid> { private readonly IRepository<EnterpriseEmployee> rep = rep; @@ -32,11 +34,23 @@ /// <param name="request"></param> /// <param name="cancellationToken"></param> /// <returns></returns> - public async Task<int> Handle(ImportEnterpriseEmployeesCommand request, CancellationToken cancellationToken) + public async Task<ImportEnterpriseEmployeesCommandResult> Handle(ImportEnterpriseEmployeesCommand request, CancellationToken cancellationToken) { + var result = new ImportEnterpriseEmployeesCommandResult(); var models = await request.ExcelUrl.ImportExcelFromOSS<ImportEnterpriseEmployeesCommandModel>(); - Console.WriteLine(); - throw new NotImplementedException(); + foreach (var model in models) + { + var error = new ImportEnterpriseEmployeesCommandResultError(); + if (model.ContactPhoneNumber.IsNull()) + { + error.ErrorMessage += "璇峰~鍐欐墜鏈哄彿"; + } + else if (!Regex.IsMatch(model.ContactPhoneNumber, @"^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$")) + { + error.ErrorMessage += "鎵嬫満鍙锋牸寮忎笉姝g‘"; + } + } + return result; } /// <summary> -- Gitblit v1.9.1