package dao;

import java.util.List;

import javax.annotation.Resource;
import model.industry_type;
import model.seller;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

@Repository("infoManagementDaoImp")
public class InfoManagementDaoImp implements InfoManagementDao {
	// 声明sessionFactory
	@Resource(name = "sessionFactory")
	private SessionFactory sessionFactory;
	private Session session;
	// 获取当前session的方法
	private Session getSession() {

		if (session == null) {
			session = sessionFactory.openSession();
		} else {
			session = sessionFactory.getCurrentSession();
		}
		return session;
	}

	@Override
	public List<industry_type> getIndustryInfo() {
		String hql = "from industry_type";
		Query query = getSession().createQuery(hql);
		List<industry_type> industry_type_list = query.list();
		return industry_type_list;
	}
	
	@Override
	public List<seller> getSellerInfoByIndustryID(String id){
		String hql = "from seller where IndustryType_id=:IndustryType_id";
		Query query = getSession().createQuery(hql);
		query.setInteger("IndustryType_id", Integer.parseInt(id));
		query.setFirstResult(0);
		query.setMaxResults(5);
		List<seller> seller_list = query.list();
		return seller_list;
	}
	@Override
	public List<seller> getSellerInfo(){
		String hql = "from seller";
		Query query = getSession().createQuery(hql);
		query.setFirstResult(0);
		query.setMaxResults(5);
		List<seller> seller_list = query.list();
		return seller_list;
	}

}

@@ -66,24 +66,26 @@
 .Resource;%0D%0A
+%0D%0A
 import model
@@ -1348,255 +1348,869 @@
 %7D%0D%0A%09
-@Override%0D%0A%09public List%3Cseller%3E getSellerInfo()%7B%0D%0A%09%09String hql = %22from seller%22;%0D%0A%09%09Query query = getSession().createQuery(hql);%0D%0A%09%09query.setFirstResult(0);%0D%0A%09%09query.setMaxResults(5);%0D%0A%09%09List%3Cseller%3E seller_list = query.list();%0D%0A%09%09return seller_lis
+%0D%0A%09@Override%0D%0A%09public List%3Cseller%3E getSellerInfoByKeyWord(String keyword)%7B%0D%0A%09%09String hql = %22from seller where Seller_Name like '%25%22+keyword+%22%25'%22;%0D%0A%09%09Query query = getSession().createQuery(hql);%0D%0A%09%09query.setFirstResult(0);%0D%0A%09%09query.setMaxResults(5);%0D%0A%09%09List%3Cseller%3E seller_list = query.list();%0D%0A%09%09return seller_list;%0D%0A%09%7D%0D%0A%09%0D%0A%09@Override%0D%0A%09public List%3Cseller%3E getSellerInfo()%7B%0D%0A%09%09String hql = %22from seller%22;%0D%0A%09%09Query query = getSession().createQuery(hql);%0D%0A%09%09query.setFirstResult(0);%0D%0A%09%09query.setMaxResults(5);%0D%0A%09%09List%3Cseller%3E seller_list = query.list();%0D%0A%09%09return seller_list;%0D%0A%09%7D%0D%0A%09%0D%0A%09@Override%0D%0A%09public seller getCompanyDetail(String id)%7B%0D%0A%09%09String hql = %22from seller where Seller_id =:Seller_id%22;%0D%0A%09%09Query query = getSession().createQuery(hql);%0D%0A%09%09query.setString(%22Seller_id%22, id);%0D%0A%09%09seller seller_result = (seller) query.uniqueResult();%0D%0A%09%09return seller_resul
 t;%0D%0A

Update InfoManagementDaoImp.java