update:修改学生信息携带

This commit is contained in:
ltx 2026-08-18 10:56:55 +08:00
parent 1c09b2934f
commit a9d1ace2b6
3 changed files with 14 additions and 2 deletions

View File

@ -91,7 +91,7 @@ namespace VOL.Business.IServices.School
/// <param name="classId"></param>
/// <param name="studentNo"></param>
/// <returns></returns>
Task<string> UploadPhoto(IFormFile file, int gradeId, int classId, string studentNo, string studentName);
Task<string> UploadPhoto(IFormFile file, int gradeId, int classId, string studentNo, string? studentName);
/// <summary>
/// 批量导入学生头像

View File

@ -676,7 +676,7 @@ namespace VOL.Business.Services.School
/// <summary>
/// 上传学生头像
/// </summary>
public async Task<string> UploadPhoto(IFormFile file, int gradeId, int classId, string studentNo, string studentName)
public async Task<string> 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<S_Student>()
.AsNoTracking()
.Where(x => x.SchoolCode == UserContext.Current.TenantId && x.StudentNo == studentNo)
.Select(x => x.StudentName)
.FirstOrDefaultAsync();
}
if (string.IsNullOrWhiteSpace(studentName))
throw new Exception("学生姓名不能为空");

View File

@ -179,6 +179,7 @@ namespace VOL.WebApi.Controllers.Business
/// <param name="gradeId">年级Id</param>
/// <param name="classId">班级Id</param>
/// <param name="studentNo">学生学号</param>
/// <param name="studentName">学生姓名;编辑已有学生时可不传</param>
/// <returns></returns>
[HttpPost(nameof(UploadPhoto))]