parent
af9c2d7580
commit
ea43ca93ad
@ -0,0 +1,29 @@
|
||||
package com.example.attendance.listener;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.example.attendance.dto.StudentExcelDTO;
|
||||
import com.example.attendance.entity.Student;
|
||||
import com.example.attendance.mapper.StudentMapper;
|
||||
|
||||
public class StudentExcelListener extends AnalysisEventListener<StudentExcelDTO> {
|
||||
private final StudentMapper studentMapper;
|
||||
|
||||
public StudentExcelListener(StudentMapper studentMapper) {
|
||||
this.studentMapper = studentMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(StudentExcelDTO data, AnalysisContext context) {
|
||||
Student student = new Student();
|
||||
student.setName(data.getName());
|
||||
student.setId(Long.valueOf(data.getStudentId()));
|
||||
student.setCurrentPoints(0); // 初始积分为0
|
||||
studentMapper.insertStudent(student);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
// 处理完成后的操作
|
||||
}
|
||||
}
|
Loading…
Reference in new issue