branch_shen
shen 3 months ago
parent 64d272d9a9
commit 0e97a6ac63

@ -13,10 +13,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* Description:
*
* @Date: 2020/2/17 14:22
* @Author: PeiChen
* StudentServiceImplStudentService
*/
@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);
}
}

Loading…
Cancel
Save