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); } }