fix: 新增学生时班级不回显 - StudentCreateRequest 支持 classId,创建时分配班级
Made-with: Cursor
This commit is contained in:
parent
1783706d63
commit
1d23f617d5
@ -492,6 +492,10 @@ const resetForm = () => {
|
|||||||
const showAddModal = () => {
|
const showAddModal = () => {
|
||||||
isEdit.value = false;
|
isEdit.value = false;
|
||||||
resetForm();
|
resetForm();
|
||||||
|
// 若当前筛选了班级,预填班级选择
|
||||||
|
if (selectedClassId.value) {
|
||||||
|
formState.classId = selectedClassId.value;
|
||||||
|
}
|
||||||
modalVisible.value = true;
|
modalVisible.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,9 @@ public class SchoolStudentController {
|
|||||||
public Result<StudentResponse> createStudent(@Valid @RequestBody StudentCreateRequest request) {
|
public Result<StudentResponse> createStudent(@Valid @RequestBody StudentCreateRequest request) {
|
||||||
Long tenantId = SecurityUtils.getCurrentTenantId();
|
Long tenantId = SecurityUtils.getCurrentTenantId();
|
||||||
Student student = studentService.createStudent(tenantId, request);
|
Student student = studentService.createStudent(tenantId, request);
|
||||||
return Result.success(studentMapper.toVO(student));
|
StudentResponse vo = studentMapper.toVO(student);
|
||||||
|
vo.setClassId(request.getClassId());
|
||||||
|
return Result.success(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "Update student")
|
@Operation(summary = "Update student")
|
||||||
|
|||||||
@ -35,4 +35,7 @@ public class StudentCreateRequest {
|
|||||||
@Schema(description = "备注")
|
@Schema(description = "备注")
|
||||||
private String notes;
|
private String notes;
|
||||||
|
|
||||||
|
@Schema(description = "所在班级 ID,创建后分配到该班级")
|
||||||
|
private Long classId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,6 +58,10 @@ public class StudentServiceImpl extends com.baomidou.mybatisplus.extension.servi
|
|||||||
|
|
||||||
studentMapper.insert(student);
|
studentMapper.insert(student);
|
||||||
|
|
||||||
|
if (request.getClassId() != null) {
|
||||||
|
classService.assignStudentToClass(student.getId(), request.getClassId(), tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
log.info("学生创建成功,ID: {}", student.getId());
|
log.info("学生创建成功,ID: {}", student.getId());
|
||||||
return student;
|
return student;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user