From adddcf678a593a08383a081024681a76c164ee24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=8D=E6=BD=9C?= <1620556043@qq.com> Date: Wed, 26 Mar 2025 10:18:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=80=83=E7=94=9F=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/Student/StudentBatchImportDto.cs | 4 ++-- .../Services/Implementations/StudentService.cs | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Src/CodeSpirit.ExamApi/Dtos/Student/StudentBatchImportDto.cs b/Src/CodeSpirit.ExamApi/Dtos/Student/StudentBatchImportDto.cs index be3bc72..8549368 100644 --- a/Src/CodeSpirit.ExamApi/Dtos/Student/StudentBatchImportDto.cs +++ b/Src/CodeSpirit.ExamApi/Dtos/Student/StudentBatchImportDto.cs @@ -29,8 +29,8 @@ public class StudentBatchImportDto /// /// 手机号码 /// - [Required(ErrorMessage = "手机号码不能为空")] - [Phone(ErrorMessage = "手机号码格式不正确")] + //[Required(ErrorMessage = "手机号码不能为空")] + //[Phone(ErrorMessage = "手机号码格式不正确")] [DisplayName("手机号码")] [JsonProperty("手机号码")] public string PhoneNumber { get; set; } = string.Empty; diff --git a/Src/CodeSpirit.ExamApi/Services/Implementations/StudentService.cs b/Src/CodeSpirit.ExamApi/Services/Implementations/StudentService.cs index 7a6a89a..8df0b42 100644 --- a/Src/CodeSpirit.ExamApi/Services/Implementations/StudentService.cs +++ b/Src/CodeSpirit.ExamApi/Services/Implementations/StudentService.cs @@ -17,6 +17,8 @@ using Microsoft.Extensions.Logging; using System.Linq; using System.Linq.Expressions; using CodeSpirit.Core.Extensions; +using System.Text.RegularExpressions; +using Microsoft.AspNetCore.Components.Forms; namespace CodeSpirit.ExamApi.Services.Implementations; @@ -346,6 +348,8 @@ public class StudentService : BaseCRUDIService(); + importData.ForEach(s => s.IdNo = s.IdNo.Trim()); + var studentNumberRepetition = importList.Where(s => !s.StudentNumber.IsNullOrWhiteSpace()).GroupBy(x => x.StudentNumber).Select(s => new { studentNumber = s.Key, count = s.Count() }); if (studentNumberRepetition.Any(x => x.count > 1)) { @@ -374,6 +378,12 @@ public class StudentService : BaseCRUDIService x.IdNo == item.IdNo)) { failedItems.Add($"{item.IdNo}「传入的身份证'{item.IdNo}'已存在"); -- Gitee