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

📄 customerserviceimpl.java

📁 一个J2EE 做的 网上图书销售管理系统
💻 JAVA
字号:
package com.briup.service.imp;

import com.briup.bean.RegisterForm;
import com.briup.common.BeanFactory;
import com.briup.dao.ICustomerDao;
import com.briup.service.ICustomerService;
import com.briup.common.exception.CustomerServiceException;
import com.briup.common.transaction.HibernateTransaction;

public class CustomerServiceImpl implements ICustomerService {
	private ICustomerDao customerDao = 
				(ICustomerDao)BeanFactory.getBean(BeanFactory.FcustomerDao);
	
	public RegisterForm login(String name, String password)
			throws CustomerServiceException {
		// TODO Auto-generated method stub
		HibernateTransaction ht = new HibernateTransaction();
		try {
			ht.beginTransaction();
			RegisterForm customer = customerDao.findCustomerByName(name);
			if(customer == null){
				throw new Exception("用户名不正确");
			}else if(!customer.getPassword().equals(password)){
				throw new Exception("密码不正确");
			}
			ht.commit();
			return customer;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			ht.rollback();
			throw new CustomerServiceException(e.getMessage(),e);
		}
		
	}

	public void register(RegisterForm customer) throws CustomerServiceException {
		// TODO Auto-generated method stub
		HibernateTransaction ht = new HibernateTransaction();
		try {
			ht.beginTransaction();
			System.out.println(customer.getName()+"&&&&");
			RegisterForm c = customerDao.findCustomerByName(customer.getName());
	
			if(c != null)
				throw new Exception("该用户名已经存在");
		
			customerDao.saveOrupdateCustomer(customer);
	
			ht.commit();
		
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			ht.rollback();
			throw new CustomerServiceException(e.getMessage(),e);
		}
	}

	public void update(RegisterForm customer) throws CustomerServiceException {
		// TODO Auto-generated method stub
		HibernateTransaction ht = new HibernateTransaction();
		try {
			ht.beginTransaction();
			customerDao.saveOrupdateCustomer(customer);
			ht.commit();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			ht.rollback();
			throw new CustomerServiceException(e.getMessage(),e);
		}
	}

}

⌨️ 快捷键说明

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