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