diff --git a/VOL.Business/IServices/School/IS_StudentService.cs b/VOL.Business/IServices/School/IS_StudentService.cs
index a649615..2a4b248 100644
--- a/VOL.Business/IServices/School/IS_StudentService.cs
+++ b/VOL.Business/IServices/School/IS_StudentService.cs
@@ -91,7 +91,7 @@ namespace VOL.Business.IServices.School
///
///
///
- Task UploadPhoto(IFormFile file, int gradeId, int classId, string studentNo, string studentName);
+ Task UploadPhoto(IFormFile file, int gradeId, int classId, string studentNo, string? studentName);
///
/// 批量导入学生头像
diff --git a/VOL.Business/Services/School/S_StudentService.cs b/VOL.Business/Services/School/S_StudentService.cs
index 8602f10..2093ec2 100644
--- a/VOL.Business/Services/School/S_StudentService.cs
+++ b/VOL.Business/Services/School/S_StudentService.cs
@@ -676,7 +676,7 @@ namespace VOL.Business.Services.School
///
/// 上传学生头像
///
- public async Task UploadPhoto(IFormFile file, int gradeId, int classId, string studentNo, string studentName)
+ public async Task UploadPhoto(IFormFile file, int gradeId, int classId, string studentNo, string? studentName)
{
const long maxFileSize = 2 * 1024 * 1024;
@@ -686,6 +686,17 @@ namespace VOL.Business.Services.School
throw new Exception("单张人脸照片大小不能超过2MB");
if (string.IsNullOrWhiteSpace(studentNo))
throw new Exception("学生学号不能为空");
+
+ // 编辑时上传组件可能只传文件和学号,此时使用当前学校已有的学生姓名。
+ // 新增学生尚未入库,仍需要客户端显式传入姓名。
+ if (string.IsNullOrWhiteSpace(studentName))
+ {
+ studentName = await _studentRepository.DbContext.Set()
+ .AsNoTracking()
+ .Where(x => x.SchoolCode == UserContext.Current.TenantId && x.StudentNo == studentNo)
+ .Select(x => x.StudentName)
+ .FirstOrDefaultAsync();
+ }
if (string.IsNullOrWhiteSpace(studentName))
throw new Exception("学生姓名不能为空");
diff --git a/VOL.WebApi/Controllers/Business/StudentController.cs b/VOL.WebApi/Controllers/Business/StudentController.cs
index 1d1a7ba..8fb19b9 100644
--- a/VOL.WebApi/Controllers/Business/StudentController.cs
+++ b/VOL.WebApi/Controllers/Business/StudentController.cs
@@ -179,6 +179,7 @@ namespace VOL.WebApi.Controllers.Business
/// 年级Id
/// 班级Id
/// 学生学号
+ /// 学生姓名;编辑已有学生时可不传
///
[HttpPost(nameof(UploadPhoto))]