⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 productserviceimp1.java

📁 老师给的购物车
💻 JAVA
字号:
package com.tarena.shopcart.serviceImp1;

import java.util.List;

import com.tarena.shopcart.entity.Category;
import com.tarena.shopcart.entity.PagesBean;
import com.tarena.shopcart.entity.Product;
import com.tarena.shopcart.entity.dao.IProductDAO;
import com.tarena.shopcart.entity.daoImp1.ProductDAOImp1;
import com.tarena.shopcart.service.IProductService;

public class ProductServiceImp1 implements IProductService {
	IProductDAO dao = new ProductDAOImp1();

	public Product findProductById(int pid) {
		return dao.findProductById(pid);
	}

	public List getAllProduct() {
		return dao.getAllProduct();
	}

	public List getAllCategory() {
		return dao.getAllCategory();
	}

	public Category findCategoryById(int cid) {
		return dao.findCategoryById(cid);
	}

	public boolean addProduct(Product product) {
		return dao.addProduct(product);
	}

	public List getProducts(String p) {
		PagesBean page = this.getPage(p);
		return dao.getProducts(page);
	}

	public PagesBean getPage(String p) {
		PagesBean pages = new PagesBean();
		pages.setMaxCount(dao.getProductCount());
		pages
				.setMaxPage(pages.getMaxCount() % pages.getPageCount() == 0 ? pages
						.getMaxCount()
						/ pages.getPageCount()
						: pages.getMaxCount() / pages.getPageCount() + 1);
		if (p != null) {
			int pa = Integer.parseInt(p);
			if (pa < 1) {
				pa = 1;
			}
			if (pa > pages.getMaxPage()) {
				pa = pages.getMaxPage();
			}
			pages.setCurrentIndex(pa);
		}
		return pages;
	}

	public boolean deleteProduct(int pid) {
		return dao.deleteProduct(pid);
	}

	public List getProductsLikeName(String name) {
		return dao.getProductsLikeName(name);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -