ProductService.java
资源名称:shihua.rar [点击查看]
上传用户:zghglow
上传日期:2022-08-09
资源大小:27227k
文件大小:3k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
JavaScript
- package com.chinacannel.xlchemical.service;
- import com.chinacannel.common.TranUtil;
- import com.chinacannel.common.CommonDAO;
- import org.apache.commons.logging.LogFactory;
- import org.apache.commons.logging.Log;
- import com.chinacannel.common.DAOException;
- import com.chinacannel.entity.Admin;
- import com.chinacannel.entity.Product;
- import com.chinacannel.entity.Category;
- import java.util.List;
- import com.chinacannel.common.PageInfo;
- public class ProductService extends TranUtil {
- private CommonDAO dao = new CommonDAO();
- private static Log log = LogFactory.getLog(ProductService.class);
- public boolean AddProduct(Product pro) {
- try {
- return dao.createObject(pro);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return false;
- }
- }
- public boolean UpdateProduct(Product pro) {
- try {
- return dao.updateObject(pro);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return false;
- }
- }
- public boolean DeletePorduct(Product pro) {
- try {
- return dao.removeObject(pro);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return false;
- }
- }
- public Product GetProductById(Long id) {
- try {
- return (Product) dao.loadObject(id, Product.class);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return null;
- }
- }
- public List getProductList(String Language, int start, int top) {
- List list = null;
- String hql = "from Product as pro where pro.pro_Language='" + Language +
- "' order by pro.pro_Time desc";
- try {
- list = dao.loadObjectListBySQL(hql, start, top);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return null;
- }
- return list;
- }
- public int getCount(String Language) {
- try {
- return dao.getCountBySql(
- "select count(*) from Product as pro where pro.pro_Language='" +
- Language + "'");
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return 0;
- }
- }
- public PageInfo getPageInfo(String Language, int pageno) {
- PageInfo pageInfo = new PageInfo(this.getCount(Language), pageno, 10);
- pageInfo.setRows(this.getProductList(Language, pageInfo.getStartRow(),
- pageInfo.getPageSize()));
- return pageInfo;
- }
- }