📄 customerserviceimpl.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 + -