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

📄 customerserviceimpl.java

📁 SSH示范
💻 JAVA
字号:
package com.iplan.portal.order.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.iplan.portal.framework.base.BaseService;
import com.iplan.portal.order.pojo.Customer;

/**
 * http://www.hao-se.cn
 * 
 * @author ws
 */
public class CustomerServiceImpl extends BaseService implements
		ICustomerService {
	/**
	 * 根据id获得pojo
	 * 
	 * @param id id
	 * @return
	 */
	public Customer getCustomerById(String id) {
		return (Customer) this.getCommonDAO().get(Customer.class, id);
	}

	/**
	 * 根据customerName获得pojo
	 * 
	 * @param areaId
	 * @param userId
	 * @param customerName
	 * @return
	 */
	public Customer getCustomerByName(String areaId, String userId, String customerName) {
		
		DetachedCriteria dc=DetachedCriteria.forClass(Customer.class);
		dc.add(Restrictions.eq("areaid",areaId));
		dc.add(Restrictions.eq("userId",userId));
		dc.add(Restrictions.eq("customerName",customerName));
		
		List list=this.getCommonDAO().findByCriteria(dc);
		if (list!=null && !list.isEmpty()) {
			return (Customer)list.get(0);
		} 
		
		return null;
	}
	
	/**
	 * 获得pojo的list
	 * 
	 * @param areaId
	 * @param userId
	 * @return
	 */
	public List getCustomerList(String areaId, String userId) {
		StringBuffer sql = new StringBuffer();
		sql.append("select * from CUSTOMER where areaid = ? and userid = ? order by CREATETIME DESC");
		List list = this.getCommonDAO().findBySQL(sql.toString(),
				new Object[] { areaId, userId }).getRows();

		return list;
	}
	
	/**
	 * 获得pojo的list
	 * 
	 * @param userId
	 * @param customerName
	 * @return
	 */
	public List getCustomerListByUser(String userId, String customerName) {
		StringBuffer sql = new StringBuffer();
		sql.append("select * from CUSTOMER where userid = '" + userId + "' ");
		if (customerName != null && !"".equals(customerName)) {
			sql.append("and customername like '%" + customerName + "%' ");
		}
		sql.append("order by CREATETIME DESC");

		List list = this.getCommonDAO().findBySQL(sql.toString()).getRows();

		return list;	
	}
	
	/**
	 * 获得pojo的list
	 * 
	 * @param areaId
	 * @param userId
	 * @param customerName
	 * @return
	 */
	public List getCustomerListByCusName(String areaId, String userId, String customerName){
		StringBuffer sql = new StringBuffer();
		sql.append("select * from CUSTOMER where userid = '" + userId + "' ");
		if (areaId != null && !"".equals(areaId)) {
			sql.append("and areaId = '" + areaId + "' ");
		}		
		if (customerName != null && !"".equals(customerName)) {
			sql.append("and customername like '%" + customerName + "%' ");
		}
		sql.append("order by CREATETIME DESC");
		
		
//		sql.append("select * from CUSTOMER where areaid = '");
//		sql.append(areaId + "' and userid = '" + userId + "' ");
//		sql.append("and customerName like '%" + customerName + "%' ");
//		sql.append("order by CREATETIME DESC");
		
		List list = this.getCommonDAO().findBySQL(sql.toString()).getRows();

		return list;
	}
	
	/**
	 * 保存pojo
	 * 
	 * @param customer
	 */
	public void saveCustomer(Customer customer) {
		this.getCommonDAO().save(customer);
	}

	/**
	 * 修改pojo
	 * 
	 * @param customer
	 */
	public void updateCustomer(Customer customer) {
		this.getCommonDAO().update(customer);
	}

	/**
	 * 删除pojo
	 * 
	 * @param customer
	 */
	public void deleteCustomer(Customer customer) {
		this.getCommonDAO().delete(customer);
	}
}

⌨️ 快捷键说明

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