StudentServiceImp.java
上传用户:nbxinmin
上传日期:2021-10-09
资源大小:46k
文件大小:2k
源码类别:

Internet/IE编程

开发平台:

Java

  1. package com.xdf.exams.bo.service;
  2. import java.util.List;
  3. import com.xdf.exams.bean.Result;
  4. import com.xdf.exams.bean.Student;
  5. import com.xdf.exams.bo.IStudentService;
  6. import com.xdf.exams.dao.IExamrecordDAO;
  7. import com.xdf.exams.dao.IResultDAO;
  8. import com.xdf.exams.dao.IStudentDAO;
  9. public class StudentServiceImp extends BaseService implements IStudentService{
  10. private IExamrecordDAO examrecorddao = null;
  11. private IResultDAO resultdao = null;
  12. private IStudentDAO studentdao = null;
  13. public IExamrecordDAO getExamrecorddao() {
  14. return examrecorddao;
  15. }
  16. public void setExamrecorddao(IExamrecordDAO examrecorddao) {
  17. this.examrecorddao = examrecorddao;
  18. }
  19. public IResultDAO getResultdao() {
  20. return resultdao;
  21. }
  22. public void setResultdao(IResultDAO resultdao) {
  23. this.resultdao = resultdao;
  24. }
  25. public IStudentDAO getStudentdao() {
  26. return studentdao;
  27. }
  28. public void setStudentdao(IStudentDAO studentdao) {
  29. this.studentdao = studentdao;
  30. }
  31. public void addStudent(Student s) {
  32. beginTransaction();
  33. studentdao.add(s);
  34. commitTransaction();
  35. }
  36. public void deleteStudent(Student s) {
  37. try {
  38. beginTransaction();
  39. List list = resultdao.findResultByUserid(s.getStudentid());
  40. for (int i=0;i<list.size();i++) {
  41. Result r = (Result)list.get(i);
  42. examrecorddao.deleteExamrecordbyResult(r.getResultid());
  43. }
  44. resultdao.deleteResultbyStudent(s.getStudentid());
  45. studentdao.delete(s);
  46. commitTransaction();
  47. } catch (RuntimeException e) {
  48. rollbackTransaction();
  49. e.printStackTrace();
  50. throw e;
  51. }
  52. }
  53. public List findAllStudent() {
  54. return studentdao.findAllStudent();
  55. }
  56. public List findAllStudent(int pageno,int pagesize ) {
  57. return studentdao.findAllStudent(pageno,pagesize);
  58. }
  59. public Student findStudent(Long id) {
  60. return (Student)studentdao.load(Student.class,id);
  61. }
  62. public List findStudentByName(String name, int pageno, int pagesize) {
  63. return studentdao.findStudentByName(name,pageno,pagesize);
  64. }
  65. public int findStudentnum() {
  66. return studentdao.findStudentnum();
  67. }
  68. public int findStudentnumByName(String name) {
  69. return studentdao.findStudentnumByName(name);
  70. }
  71. public void updateStudent(Student s) {
  72. beginTransaction();
  73. studentdao.update(s);
  74. commitTransaction();
  75. }
  76. public boolean checkStudentNameExists(String name,Long id) {
  77. return studentdao.checkStudentNameExists(name,id);
  78. }
  79. }