From f2057db95362e3daea7aff7885e2e887f898dc2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=82=A5=E7=BE=8A?= <1048382248@qq.com> Date: Mon, 8 Dec 2025 09:39:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E5=AD=A6=E7=A7=91=20=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E5=AD=A6=E7=A7=91=E6=9E=9A=E4=B8=BE=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StudentController.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Learn.Archives.API/Controllers/StudentController.cs b/Learn.Archives.API/Controllers/StudentController.cs index 616ffb8..7ff87b2 100644 --- a/Learn.Archives.API/Controllers/StudentController.cs +++ b/Learn.Archives.API/Controllers/StudentController.cs @@ -424,14 +424,18 @@ namespace Learn.Archives.API.Controllers var subjectArr = row.高考选科.Split(",") .Select(s => s.ToEnum()) .ToArray(); - userCenterUpdate.Add(new User + var upUser = new User { Id = uid, Phone = row.Phone, - GLSubject = (int?)subjectArr[0], - GSubject1 = (int?)subjectArr[1], - GSubject2 = (int?)subjectArr[2], - }); + }; + if (subjectArr.Length > 0) + upUser.GLSubject = (int?)subjectArr[0]; + if (subjectArr.Length > 1) + upUser.GSubject1 = (int?)subjectArr[1]; + if (subjectArr.Length > 2) + upUser.GSubject2 = (int?)subjectArr[2]; + userCenterUpdate.Add(upUser); } }