package cn.net.caoyao.cpzshandset.service.bll;

import java.util.List;

import android.content.Context;
import cn.net.caoyao.cpzshandset.common.config.ConfigDBCreateService;
import cn.net.caoyao.cpzshandset.common.util.CacheGet;
import cn.net.caoyao.cpzshandset.db.presenter.SheepDealerDal;
import cn.net.cpzslibs.prot.handset.bean.res.DealerBean;

public class SheepDealerBll {
	private SheepDealerDal dal;
	public SheepDealerBll(Context context) {
		ConfigDBCreateService service = new ConfigDBCreateService();
		dal = service.createSheepDealerDal(new CacheGet(), context);	
		}
	/**
	 * 插入一条经销商信息
	 * @param b
	 */
	public void insertDealer(DealerBean b){
		if(dal == null || b == null) return;
		dal.insertDealer(b);
	}
	/**
	 * 插入一组经销商信息
	 */
	public void insertDealerList(List<DealerBean> dealers){
		if(dal == null || dealers == null) return;
		dal.insertDealerList(dealers);
	}
	/**
	 * 删除所有的经销商信息
	 */
	public void deleteAllDealer(){
		if(dal == null) return;
		dal.deleteAllDealer();
	}
	/**
	 * 通过经销商的code码查询经销的信息
	 * @param code
	 * @return
	 */
	public DealerBean queryDealerByCode(String code){
		if(dal == null) return null;
		return dal.queryDealerByCode(code);
	}
	/**
	 * 通过经销商的id查询经销的信息
	 * @param id
	 * @return
	 */
	public DealerBean queryDealerById(long id){
		if(dal == null) return null;
		return dal.queryDealerById(id);
	}
	public List<DealerBean> searchDealerByCondition(String condition) {
		if (dal == null || condition == null) return null;
		return dal.searchDealerByCondition(condition);
	}

	public List<DealerBean> queryAllDealer() {
		if (dal == null) return null;
		return dal.queryAllDealer();
	}
}
