88c4a6ad2e9139adee418b925a2fa31a41b46200.svn-base 3.7 KB
package com.espeed.service.impl;

import java.util.List;

import com.espeed.dao.YxySendFilterAddressDao;
import com.espeed.pojo.YxySendFilterAddress;
import com.espeed.service.YxySendFilterAddressService;
import com.espeed.vo.PageBean;

public class YxySendFilterAddressServiceImpl implements YxySendFilterAddressService{

	/**条件查询过滤地址*/
	public List<YxySendFilterAddress> findByCondition(String loginid,String domain, int condition, String conditionvalue, PageBean pb)throws Exception {
		String hql="from YxySendFilterAddress where 1=1";
		String hqlcount="select count(*) from YxySendFilterAddress where 1=1";
		if(condition==0){
			hql+=" and filteraddrloginid='"+loginid+"' and filteraddrdomain='"+domain+"'";
			hqlcount+=" and filteraddrloginid='"+loginid+"' and filteraddrdomain='"+domain+"'";
		}else if(condition==1){//分类查询
			hql+=" and filteraddrloginid='"+loginid+"' and filteraddrdomain='"+domain+"' and filterid="+conditionvalue;
			hqlcount+=" and filteraddrloginid='"+loginid+"' and filteraddrdomain='"+domain+"' and filterid="+conditionvalue;
		}else if(condition==2){//条件模糊查询
			hql+=" and filteraddrloginid='"+loginid+"' and filteraddrdomain='"+domain+"' and filteraddress like'%"+conditionvalue+"%'";
			hqlcount+=" and filteraddrloginid='"+loginid+"' and filteraddrdomain='"+domain+"' and filteraddress like'%"+conditionvalue+"%'";
		}
		return yxysendfilteraddressdao.findByHqlPage(hql, hqlcount, pb);
	}
	
	/**查询已存在的地址*/
	public List<Object> findIsExits(String loginid, String domain)throws Exception {
		String sql="select filteraddress from yxy_send_filter_address where filteraddrloginid='"+loginid+"' and filteraddrdomain='"+domain+"'";
		return yxysendfilteraddressdao.findBySqlQuery(sql);
	}
	
	/**循环插入过滤地址*/
	public void addFilterAddressPi(List<YxySendFilterAddress> list)throws Exception {
		yxysendfilteraddressdao.addPojoPi(list);
	}
	
	/**删除所选过滤地址*/
	public void delFilterAddress(String addressstr) throws Exception {
		String hql="delete YxySendFilterAddress where filteraddrid in("+addressstr+")";
		yxysendfilteraddressdao.updateByHql(hql);
	}

	/**根据类别ID查询过滤地址*/
	public List<YxySendFilterAddress> findByTypeId(int typeid) throws Exception {
		String hql="form YxySendFilterAddress where filterid="+typeid;
		return yxysendfilteraddressdao.findByHql(hql);
	}
	
	/**根据类别ID查询过滤地址*/
	public List<Object> findByTypeidAddress(int typeid)throws Exception{
		String sql="select filteraddress from yxy_send_filter_address where filterid="+typeid;
		return yxysendfilteraddressdao.findBySqlQuery(sql);
	}
	
	/**过滤地址是否存在*/
	public int findIsExits(String loginid, String domain,String address) throws Exception {
		String sql="select count(*) from yxy_send_filter_address where filteraddrloginid='"+loginid+"' and filteraddrdomain='"+domain+"' and filteraddress='"+address+"'";
		List<Object> list=yxysendfilteraddressdao.findBySqlQuery(sql);
		if(Integer.parseInt(list.get(0).toString())>0){
			return 0;
		}else{
			return 1;
		}
	}
	
	/**编辑过滤地址*/
	public void updateFilterAddress(YxySendFilterAddress o) throws Exception {
		String hql="update YxySendFilterAddress set filterid="+o.getFilterid()+", filteraddrreason='"+o.getFilteraddrreason()+"',filteraddress='"+o.getFilteraddress()+"' where filteraddrid="+o.getFilteraddrid();
		yxysendfilteraddressdao.updateByHql(hql);
	}

	
	
	private YxySendFilterAddressDao yxysendfilteraddressdao;//过滤地址dao

	public YxySendFilterAddressDao getYxysendfilteraddressdao() {
		return yxysendfilteraddressdao;
	}

	public void setYxysendfilteraddressdao(
			YxySendFilterAddressDao yxysendfilteraddressdao) {
		this.yxysendfilteraddressdao = yxysendfilteraddressdao;
	}

	
	

	

	
	

	

	
	
}