📄 studentserviceimpl.java
字号:
/* * StudentServiceImpl.java * * Created on 2006年5月20日, 下午5:37 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package enova.service.impl;import java.util.*;import enova.dao.*;import enova.pojo.*;import enova.service.*;/** * * @author vlinux */public class StudentServiceImpl implements StudentService { private StudentDao studentDao; /** Creates a new instance of StudentServiceImpl */ public StudentServiceImpl(StudentDao studentDao) { this.studentDao = studentDao; } /*通过学生ID获取学生*/ public Student get(Integer studentId) throws StoreException{ try{ return studentDao.get(studentId); }catch(DataAccessException dae){ throw new StoreException(); } } /*更新或者创建一个学生*/ public void updateOrCreate(Student student) throws UniqueException, StoreException{ try{ studentDao.updateOrInsert(student); }catch(DataAccessException dae){ throw new StoreException(); }catch(RecordExistException ree){ throw new UniqueException(); } } /*通过学生ID删除学生*/ public void delete(Integer studentId) throws StoreException, NotExistException{ try{ if( this.get(studentId)==null ) throw new NotExistException(); studentDao.delete(studentId); }catch(DataAccessException dae){ throw new StoreException(); } } /*学生登录验证,如果密码错误抛出密码错误异常*/ public Student loginVerify(String number,String password) throws StoreException, PasswordErrorException{ try{ Student student = studentDao.loginVerify(number,password); if( student==null ) throw new PasswordErrorException(); return student; }catch(DataAccessException dae){ throw new StoreException(); } } /*修改密码,抛出密码错误异常*/ public void changePassword(String number,String oldPassword,String newPassword) throws PasswordErrorException, StoreException{ Student student = loginVerify(number,oldPassword); student.setPassword(newPassword); try{ updateOrCreate(student); }catch(UniqueException ue){ // } } /*通过班级ID获取学生,按照学号排序*/ public List getByClassId(Integer classId) throws StoreException{ try{ return studentDao.getByClassIdSortNumber(classId); }catch(DataAccessException dae){ throw new StoreException(); } } public List getByName(String name) throws StoreException{ try{ if( name.length()==0 ) return studentDao.getByName(null); return studentDao.getByName(name); }catch(DataAccessException dae){ throw new StoreException(); } } public List getByClassIdAndName(Integer classId,String name) throws StoreException{ try{ return studentDao.getByClassIdAndName(classId,name); }catch(DataAccessException dae){ throw new StoreException(); } } public List getByNumber(String number) throws StoreException{ try{ return studentDao.getByNumber(number); }catch(DataAccessException dae){ throw new StoreException(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -