|
|
|
@ -13,10 +13,7 @@ import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Description:
|
|
|
|
|
*
|
|
|
|
|
* @Date: 2020/2/17 14:22
|
|
|
|
|
* @Author: PeiChen
|
|
|
|
|
* StudentServiceImpl类实现了StudentService接口,提供学生信息的管理功能。
|
|
|
|
|
*/
|
|
|
|
|
@Service("studentService")
|
|
|
|
|
public class StudentServiceImpl implements StudentService {
|
|
|
|
@ -29,20 +26,23 @@ public class StudentServiceImpl implements StudentService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询所有学生信息
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* 查询所有学生信息,支持分页。
|
|
|
|
|
* @param page 当前页码
|
|
|
|
|
* @param size 每页显示的记录数
|
|
|
|
|
* @return 学生列表
|
|
|
|
|
* @throws Exception 异常处理
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Student> findAll(int page,int size) throws Exception {
|
|
|
|
|
PageHelper.startPage(page,size);
|
|
|
|
|
public List<Student> findAll(int page, int size) throws Exception {
|
|
|
|
|
PageHelper.startPage(page, size);
|
|
|
|
|
return studentDao.findAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过学号sno查询学生信息
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* 根据学号查询学生信息。
|
|
|
|
|
* @param sno 学号
|
|
|
|
|
* @return 学生对象
|
|
|
|
|
* @throws Exception 异常处理
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Student findBySno(String sno) throws Exception {
|
|
|
|
@ -50,26 +50,30 @@ public class StudentServiceImpl implements StudentService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 模糊查询学生信息
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* 模糊查询学生信息,支持分页。
|
|
|
|
|
* @param page 当前页码
|
|
|
|
|
* @param size 每页显示的记录数
|
|
|
|
|
* @param keyword 查询关键字
|
|
|
|
|
* @return 学生列表
|
|
|
|
|
* @throws Exception 异常处理
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Student> search(int page, int size, String keyword) throws Exception {
|
|
|
|
|
PageHelper.startPage(page,size);
|
|
|
|
|
PageHelper.startPage(page, size);
|
|
|
|
|
return studentDao.search(keyword);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加学生信息
|
|
|
|
|
* @param student
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* 添加学生信息。
|
|
|
|
|
* @param student 学生对象
|
|
|
|
|
* @return 是否添加成功
|
|
|
|
|
* @throws Exception 异常处理
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public boolean add(Student student) throws Exception {
|
|
|
|
|
if (student == null || student.getName() == null || student.getSex() == null || student.getSno() == null
|
|
|
|
|
|| student.getPhone() == null || student.getPlace() == null || student.getDorm_id() == null
|
|
|
|
|
|| student.getTeacher() == null || student.getStu_class() == null || student.getStatus() == null) {
|
|
|
|
|
|| student.getTeacher() == null || student.getStu_class() == null || student.getStatus() == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
studentDao.add(student);
|
|
|
|
@ -77,9 +81,9 @@ public class StudentServiceImpl implements StudentService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据学号删除学生
|
|
|
|
|
* @param sno
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* 根据学号删除学生信息。
|
|
|
|
|
* @param sno 学号
|
|
|
|
|
* @throws Exception 异常处理
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(String sno) throws Exception {
|
|
|
|
@ -87,9 +91,9 @@ public class StudentServiceImpl implements StudentService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改学生信息
|
|
|
|
|
* @param student
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* 修改学生信息。
|
|
|
|
|
* @param student 学生对象
|
|
|
|
|
* @throws Exception 异常处理
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void update(Student student) throws Exception {
|
|
|
|
@ -97,14 +101,14 @@ public class StudentServiceImpl implements StudentService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出学生信息
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* 导出学生信息到Excel文件。
|
|
|
|
|
* @return 输入流,用于读取生成的Excel文件
|
|
|
|
|
* @throws Exception 异常处理
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public InputStream getInputStream() throws Exception {
|
|
|
|
|
//Excel中的每列列名,依次对应数据库的字段
|
|
|
|
|
String[] title = new String[]{"姓名","性别","学号","班级","联系方式","家庭住址","宿舍号","育人导师","状态"};
|
|
|
|
|
// Excel中的每列列名,依次对应数据库的字段
|
|
|
|
|
String[] title = new String[]{"姓名", "性别", "学号", "班级", "联系方式", "家庭住址", "宿舍号", "育人导师", "状态"};
|
|
|
|
|
List<Student> students = studentDao.findAll();
|
|
|
|
|
List<Object[]> datalist = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < students.size(); i++) {
|
|
|
|
@ -120,17 +124,16 @@ public class StudentServiceImpl implements StudentService {
|
|
|
|
|
obj[8] = students.get(i).getStatus();
|
|
|
|
|
datalist.add(obj);
|
|
|
|
|
}
|
|
|
|
|
WriteExcel excel = new WriteExcel(title,datalist);
|
|
|
|
|
|
|
|
|
|
WriteExcel excel = new WriteExcel(title, datalist);
|
|
|
|
|
return excel.export();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据宿舍号查询状态为status的学生
|
|
|
|
|
* @param dorm_id
|
|
|
|
|
* @param status
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* 根据宿舍号查询状态为status的学生。
|
|
|
|
|
* @param dorm_id 宿舍号
|
|
|
|
|
* @param status 状态值
|
|
|
|
|
* @return 学生列表
|
|
|
|
|
* @throws Exception 异常处理
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Student> findByDormId(String dorm_id, Integer status) throws Exception {
|
|
|
|
@ -138,20 +141,31 @@ public class StudentServiceImpl implements StudentService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询育人导师为teacher的学生集合
|
|
|
|
|
* @param teacher
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* 查询育人导师为teacher的学生集合,支持分页。
|
|
|
|
|
* @param page 当前页码
|
|
|
|
|
* @param size 每页显示的记录数
|
|
|
|
|
* @param teacher 育人导师名称
|
|
|
|
|
* @return 学生列表
|
|
|
|
|
* @throws Exception 异常处理
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Student> findByTeacher(int page,int size,String teacher) throws Exception {
|
|
|
|
|
PageHelper.startPage(page,size);
|
|
|
|
|
public List<Student> findByTeacher(int page, int size, String teacher) throws Exception {
|
|
|
|
|
PageHelper.startPage(page, size);
|
|
|
|
|
return studentDao.findByTeacher(teacher);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据育人导师和关键字模糊查询学生信息,支持分页。
|
|
|
|
|
* @param page 当前页码
|
|
|
|
|
* @param size 每页显示的记录数
|
|
|
|
|
* @param teacher 育人导师名称
|
|
|
|
|
* @param keyword 查询关键字
|
|
|
|
|
* @return 学生列表
|
|
|
|
|
* @throws Exception 异常处理
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Student> searchStudent(int page, int size, String teacher, String keyword) throws Exception {
|
|
|
|
|
PageHelper.startPage(page,size);
|
|
|
|
|
return studentDao.searchStudent(teacher,keyword);
|
|
|
|
|
PageHelper.startPage(page, size);
|
|
|
|
|
return studentDao.searchStudent(teacher, keyword);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|