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

📄 orderserviceimpl.java

📁 网上售书电子商务网站
💻 JAVA
字号:
package com.briup.service.impl;

import java.util.Map;

import com.briup.bean.Book;
import com.briup.bean.Orderform;
import com.briup.common.BeanFactory;
import com.briup.common.exception.OrderServiceException;
import com.briup.common.transaction.HibernateTransaction;
import com.briup.dao.IOrderDao;
import com.briup.service.IOrderService;

public class OrderServiceImpl implements IOrderService {
	private IOrderDao orderDao = 
					(IOrderDao)BeanFactory.getBean(BeanFactory.ORDERDAO);
	
	public void delOrder(Long orderid) throws OrderServiceException {
		// TODO Auto-generated method stub

		HibernateTransaction ht = new HibernateTransaction();
		try {
			ht.beginTransaction();
			orderDao.deleteOrder(orderid);
			ht.commit();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			ht.rollback();
			throw new OrderServiceException("删除订单失败",e);
		}

	}

	public Orderform findOrderById(Long orderid) throws OrderServiceException {
		// TODO Auto-generated method stub
		HibernateTransaction ht = new HibernateTransaction();
		try {
			ht.beginTransaction();
			Orderform order = orderDao.findOrderById(orderid);
			ht.commit();
			return order;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			ht.rollback();
			throw new OrderServiceException("查看订单明细失败",e);
		}

	}

	public Map<Long,Orderform> listAllOrder(Long customerid) throws OrderServiceException {
		// TODO Auto-generated method stub
		HibernateTransaction ht = new HibernateTransaction();
		try {
			ht.beginTransaction();
			Map<Long,Orderform>	map = orderDao.findAllOrder(customerid);
			ht.commit();
			return map;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			ht.rollback();
			throw new OrderServiceException("查找订单失败",e);
		}

	}

	public void saveOrder(Orderform order) throws OrderServiceException {
		// TODO Auto-generated method stub
		HibernateTransaction ht = new HibernateTransaction();
		try {
			ht.beginTransaction();
			if(order.getOrderlines().size() == 0)
				throw new Exception("订单为空,请继续定购");
			orderDao.saveOrder(order);
			ht.commit();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			ht.rollback();
			throw new OrderServiceException(e.getMessage(),e);
		}

	}

	public Map<Long,Book> listAllBook() throws OrderServiceException {
		// TODO Auto-generated method stub
		HibernateTransaction ht = new HibernateTransaction();
		try {
			ht.beginTransaction();
			Map<Long,Book> map = orderDao.findAllBook();
			ht.commit();
			return map;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			ht.rollback();
			throw new OrderServiceException("查找Book失败",e);
		}
	}

}

⌨️ 快捷键说明

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