update:学生信息修改

This commit is contained in:
ltx 2026-08-18 11:49:48 +08:00
parent a9d1ace2b6
commit bfea00c64f

View File

@ -294,13 +294,20 @@ namespace VOL.Business.Services.School
public async Task AddStudent(AddStudentParam paramDto) public async Task AddStudent(AddStudentParam paramDto)
{ {
var stuExists = await _studentRepository.ExistsAsync(x => x.StudentNo == paramDto.StudentNo); if (paramDto == null || string.IsNullOrWhiteSpace(paramDto.StudentNo))
throw new ArgumentNullException("学生学号必填");
var tenantId = UserContext.Current.TenantId;
paramDto.StudentNo = paramDto.StudentNo.Trim();
var stuExists = await _studentRepository.ExistsAsync(x =>
x.SchoolCode == tenantId && x.StudentNo == paramDto.StudentNo);
if (stuExists) if (stuExists)
throw new Exception($"学号{paramDto.StudentNo}的学生已存在!"); throw new Exception($"学号{paramDto.StudentNo}的学生已存在!");
var studentEntity = _mapper.Map<S_Student>(paramDto); var studentEntity = _mapper.Map<S_Student>(paramDto);
studentEntity.StudentStatus = StudentStatus.Normal; studentEntity.StudentStatus = StudentStatus.Normal;
studentEntity.SchoolCode = UserContext.Current.TenantId; studentEntity.SchoolCode = tenantId;
studentEntity.Creator = UserContext.Current.UserId; studentEntity.Creator = UserContext.Current.UserId;
studentEntity.CreateDate = DateTime.Now; studentEntity.CreateDate = DateTime.Now;
@ -324,16 +331,23 @@ namespace VOL.Business.Services.School
} }
public async Task ModifyStudent(AddStudentParam paramDto) public async Task ModifyStudent(AddStudentParam paramDto)
{ {
if (paramDto == null || string.IsNullOrEmpty(paramDto.StudentNo)) if (paramDto == null || string.IsNullOrWhiteSpace(paramDto.StudentNo))
{ {
throw new ArgumentNullException("学生学号必填"); throw new ArgumentNullException("学生学号必填");
} }
var student = await _studentRepository.FindAsyncFirst(x => x.Id == paramDto.Id); var tenantId = UserContext.Current.TenantId;
paramDto.StudentNo = paramDto.StudentNo.Trim();
var student = await _studentRepository.FindAsyncFirst(x =>
x.Id == paramDto.Id && x.SchoolCode == tenantId);
if (student == null) if (student == null)
throw new ArgumentNullException("未找到要更新的数据"); throw new ArgumentNullException("未找到要更新的数据");
var stuExists = await _studentRepository.ExistsAsync(x => x.StudentNo == paramDto.StudentNo && x.Id != student.Id); var stuExists = await _studentRepository.ExistsAsync(x =>
x.SchoolCode == tenantId &&
x.StudentNo == paramDto.StudentNo &&
x.Id != student.Id);
if (stuExists) if (stuExists)
throw new Exception($"学号{paramDto.StudentNo}的学生已存在!"); throw new Exception($"学号{paramDto.StudentNo}的学生已存在!");