1 package com.ibatis.jpetstore.service; 2 3 import com.ibatis.dao.client.DaoManager; 4 import com.ibatis.jpetstore.domain.Account; 5 import com.ibatis.jpetstore.persistence.DaoConfig; 6 import com.ibatis.jpetstore.persistence.iface.AccountDao; 7 8 import java.util.List ; 9 10 16 public class AccountService { 17 18 19 20 private static final AccountService instance = new AccountService(); 21 22 23 24 private DaoManager daoManager = DaoConfig.getDaomanager(); 25 26 private AccountDao accountDao; 27 28 29 30 public AccountService() { 31 accountDao = (AccountDao) daoManager.getDao(AccountDao.class); 32 } 33 34 35 36 public static AccountService getInstance() { 37 return instance; 38 } 39 40 41 42 public Account getAccount(String username) { 43 return accountDao.getAccount(username); 44 } 45 46 public Account getAccount(String username, String password) { 47 return accountDao.getAccount(username, password); 48 } 49 50 public void insertAccount(Account account) { 51 accountDao.insertAccount(account); 52 } 53 54 public void updateAccount(Account account) { 55 accountDao.updateAccount(account); 56 } 57 58 public List getUsernameList() { 59 return accountDao.getUsernameList(); 60 } 61 62 } 63 | Popular Tags |