diff --git a/Src/CodeSpirit.ExamApi/Dtos/Student/StudentBatchImportDto.cs b/Src/CodeSpirit.ExamApi/Dtos/Student/StudentBatchImportDto.cs index be3bc72042ff717158179bee6800001ee1312914..854936806c7577ad027fc24a36fb22358de82ae8 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 7a6a89a4bb9e9d76065e3597cc7e7628a7703dd4..8df0b42b5dd325f1ece65e47e71d2a4f12d31586 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}'已存在");