20a38b1bd31e1a9d2dae4ffdd3a715d25f7c4063.svn-base 3.0 KB
package com.espeed.service.impl;

import java.util.List;
import com.espeed.dao.YxySendFilterAddressDao;
import com.espeed.dao.YxySendFilterDao;
import com.espeed.pojo.YxySendFilter;
import com.espeed.service.YxySendFilterService;
/**
 * 程序名称:    	EspeedMail_时速邮箱
 * 程序版本:    	V1.0
 * 作    者:    	深圳市科飞时速网络技术有限公司(0755-88843776)
 * 版权所有:    	深圳市科飞时速网络技术有限公司
 * 技术支持:    	Tech@21gmail.com
 * 单元名称:     发送过滤分组Service接口实现类
 * 开始时间:    	2013.12.09
 * 程 序 员:    	谢勇
 * 最后修改:    
 * 备    注:		如需修改请通知程序员    
 */
public class YxySendFilterServiceImpl implements YxySendFilterService{

	/**查询发送过滤分组所有类别*/
	public List<YxySendFilter> findUserFilter(String loginid, String domain)throws Exception {
		String hql="from YxySendFilter where filterloginid='"+loginid+"' and filterdomain='"+domain+"'";	
		return yxysendfilterdao.findByHql(hql);
	}
	
	/**添加编辑过滤分组类别*/
	public void addEditFilter(YxySendFilter o) throws Exception {
		if(o.getFilterid()>0){//编辑
			yxysendfilterdao.updatePojo(o);
		}else{//添加
			yxysendfilterdao.addPojo(o);
		}
	}
	
	/**删除过滤分组*/
	public void delFilter(String loginid,String domain,int filterid,int operation) throws Exception {
		if(operation==1){//删除地址
			//删除地址
			String hql1="delete YxySendFilterAddress where filterid="+filterid;
			yxysendfilteraddressdao.updateByHql(hql1);
		}else{//地址修改为默认过滤分组
			String hql2="update YxySendFilterAddress set filterid=0 where filterid="+filterid;
			yxysendfilteraddressdao.updateByHql(hql2);
		}
		String hql="delete YxySendFilter where id="+filterid;
		yxysendfilterdao.updateByHql(hql);
	}
	
	/**清空过滤分组*/
	public void delFilterData(int filterid) throws Exception {
		//删除地址
		String hql1="delete YxySendFilterAddress where filterid="+filterid;
		yxysendfilteraddressdao.updateByHql(hql1);
	}
	
	/**过滤分组是否存在*/
	public int findisExits(String name,String loginid,String domain)throws Exception{
		String hql="select count(*) from YxySendFilter where filtername='"+name+"' and filterloginid='"+loginid+"' and filterdomain='"+domain+"'";
		int count=yxysendfilterdao.findByHqlCount(hql);
		if(count>0){
			return 0;
		}else{
			return 1;
		}
	}
	
	private YxySendFilterDao yxysendfilterdao;//过滤分组类别Dao
	private YxySendFilterAddressDao yxysendfilteraddressdao;//过滤地址dao
	
	public YxySendFilterDao getYxysendfilterdao() {
		return yxysendfilterdao;
	}

	public void setYxysendfilterdao(YxySendFilterDao yxysendfilterdao) {
		this.yxysendfilterdao = yxysendfilterdao;
	}

	public YxySendFilterAddressDao getYxysendfilteraddressdao() {
		return yxysendfilteraddressdao;
	}

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

	
	
}