1 package org.springframework.samples.jpetstore.domain.logic; 2 3 import java.util.List ; 4 5 import org.springframework.samples.jpetstore.dao.AccountDao; 6 import org.springframework.samples.jpetstore.dao.CategoryDao; 7 import org.springframework.samples.jpetstore.dao.ItemDao; 8 import org.springframework.samples.jpetstore.dao.OrderDao; 9 import org.springframework.samples.jpetstore.dao.ProductDao; 10 import org.springframework.samples.jpetstore.domain.Account; 11 import org.springframework.samples.jpetstore.domain.Category; 12 import org.springframework.samples.jpetstore.domain.Item; 13 import org.springframework.samples.jpetstore.domain.Order; 14 import org.springframework.samples.jpetstore.domain.Product; 15 16 59 public class PetStoreImpl implements PetStoreFacade, OrderService { 60 61 private AccountDao accountDao; 62 63 private CategoryDao categoryDao; 64 65 private ProductDao productDao; 66 67 private ItemDao itemDao; 68 69 private OrderDao orderDao; 70 71 72 76 public void setAccountDao(AccountDao accountDao) { 77 this.accountDao = accountDao; 78 } 79 80 public void setCategoryDao(CategoryDao categoryDao) { 81 this.categoryDao = categoryDao; 82 } 83 84 public void setProductDao(ProductDao productDao) { 85 this.productDao = productDao; 86 } 87 88 public void setItemDao(ItemDao itemDao) { 89 this.itemDao = itemDao; 90 } 91 92 public void setOrderDao(OrderDao orderDao) { 93 this.orderDao = orderDao; 94 } 95 96 97 101 public Account getAccount(String username) { 102 return this.accountDao.getAccount(username); 103 } 104 105 public Account getAccount(String username, String password) { 106 return this.accountDao.getAccount(username, password); 107 } 108 109 public void insertAccount(Account account) { 110 this.accountDao.insertAccount(account); 111 } 112 113 public void updateAccount(Account account) { 114 this.accountDao.updateAccount(account); 115 } 116 117 public List getUsernameList() { 118 return this.accountDao.getUsernameList(); 119 } 120 121 public List getCategoryList() { 122 return this.categoryDao.getCategoryList(); 123 } 124 125 public Category getCategory(String categoryId) { 126 return this.categoryDao.getCategory(categoryId); 127 } 128 129 public List getProductListByCategory(String categoryId) { 130 return this.productDao.getProductListByCategory(categoryId); 131 } 132 133 public List searchProductList(String keywords) { 134 return this.productDao.searchProductList(keywords); 135 } 136 137 public Product getProduct(String productId) { 138 return this.productDao.getProduct(productId); 139 } 140 141 public List getItemListByProduct(String productId) { 142 return this.itemDao.getItemListByProduct(productId); 143 } 144 145 public Item getItem(String itemId) { 146 return this.itemDao.getItem(itemId); 147 } 148 149 public boolean isItemInStock(String itemId) { 150 return this.itemDao.isItemInStock(itemId); 151 } 152 153 public void insertOrder(Order order) { 154 this.orderDao.insertOrder(order); 155 this.itemDao.updateQuantity(order); 156 } 157 158 public Order getOrder(int orderId) { 159 return this.orderDao.getOrder(orderId); 160 } 161 162 public List getOrdersByUsername(String username) { 163 return this.orderDao.getOrdersByUsername(username); 164 } 165 166 } 167 | Popular Tags |