📄 rootserviceimpl.java
字号:
/* * RootServiceImpl.java * * Created on 2006年5月20日, 下午4:27 * * 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 RootServiceImpl implements RootService { private RootDao rootDao; /** Creates a new instance of RootServiceImpl */ public RootServiceImpl(RootDao rootDao) { this.rootDao = rootDao; } /*通过ID获取管理员*/ public Root get(Integer rootId) throws StoreException{ try{ return rootDao.get(rootId); }catch(DataAccessException dae){ throw new StoreException(); } } /*更新或者创建一个管理员,如果管理员帐号出现重复则抛出重复异常*/ public void updateOrCreate(Root root) throws UniqueException, StoreException{ try{ rootDao.updateOrInsert(root); }catch(DataAccessException dae){ throw new StoreException(); }catch(RecordExistException ree){ throw new UniqueException(); } } /*通过管理员ID删除一个管理员*/ public void delete(Integer rootId) throws NotExistException, StoreException{ try{ if( rootDao.get(rootId)==null ) throw new NotExistException(); rootDao.delete(rootId); }catch(DataAccessException dae){ throw new StoreException(); } } /*获取所有管理员*/ public List getAll() throws StoreException{ try{ return rootDao.getAll(); }catch(DataAccessException dae){ throw new StoreException(); } } /*通过管理员帐号获取管理员*/ public List getByUsername(String username) throws StoreException{ try{ return rootDao.getByUsername(username); }catch(DataAccessException dae){ throw new StoreException(); } } /*管理员登录验证,抛出密码错误异常*/ public Root loginVerify(String username,String password) throws PasswordErrorException, StoreException{ try{ Root root = rootDao.loginVerify(username,password); if( root==null ) throw new PasswordErrorException(); return root; }catch(DataAccessException dae){ throw new StoreException(); } } /*管理员修改密码,如果原来密码错误则抛出密码错误异常*/ public void changePassword(String username,String oldPassword,String newPassword) throws PasswordErrorException, StoreException{ try{ Root root = loginVerify(username,oldPassword); root.setPassword(newPassword); updateOrCreate(root); }catch(UniqueException ue){ //不可能发生的事情... } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -