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

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.BatchLabelDal;
import cn.net.cpzslibs.prot.handset.bean.req.Prot20002ReqBatchBean;

public class BatchLabelBll {
	private BatchLabelDal dal;
	
	public BatchLabelBll(Context context) {
		ConfigDBCreateService service = new ConfigDBCreateService();
		dal = service.createBatchLabeDal(new CacheGet(), context);
//		dal = new CommonBatchLabelDal(context);
	}
	
	/**
	 * 根据批量数据Id修改批量数据
	 * @param id
	 * @param reqBatchBean
	 */
	public void updateBatchLabelById(int id, Prot20002ReqBatchBean reqBatchBean){
		if (dal == null) {
			return;
		}
		dal.updateBatchLabelById(id, reqBatchBean);
	}
	/**
	 * 删除所有的批量数据
	 */
	public void deleteAllBatch(){
		if (dal == null) {
			return;
		}
		dal.deleteAllBatch();
	}
	
	/**
	 * 删除某种操作的所有批量数据
	 */
	public void deleteBatchByType(int option_type){
		if (dal == null) {
			return;
		}
		dal.deleteBatchByType(option_type);
	}
	
	/**
	 * 根据id和操作类型删除某条批量操作的数据
	 */
	public void deleteBatchById(int option_type,int option_id){
		if (dal == null) {
			return;
		}
		dal.deleteBatchById(option_type, option_id);
	}
	/**
	 * 根据操作类型和操作id查询批量数据个数
	 * @param option_type
	 * @param option_id
	 * @return
	 */
	public int queryBatchCountById(int option_type,int option_id){
		if (dal == null) {
			return -1;
		}
		return dal.queryBatchCountById(option_type, option_id);
	}
	/**
	 * 根据操作类型和操作id查询批量数据
	 * @param option_type
	 * @param option_id
	 * @return
	 */
	public Prot20002ReqBatchBean queryBatchBeanById(int option_type,int option_id){
		if (dal == null) {
			return null;
		}
		return dal.queryBatchBeanById(option_type, option_id);
	}

	/**
	 * 插入批量激活信息到数据库
	 * @param option_type
	 * @param option_id
	 * @param reqBatchBean
	 * @return
	 */
	public int insertBatch(int option_type,int option_id, Prot20002ReqBatchBean reqBatchBean){
		if (dal == null) {
			return -1;
		}
		return dal.insertBatch(option_type, option_id, reqBatchBean);
	}
	/**
	 * 检测某个标签段是否已经存在在激活表中
	 * 
	 * @param labelId
	 * @return
	 */
	public boolean hasExistBatchLabel(String startLabel,String endLabel,int option_type,int optionId) {
		if (dal == null) {
			return false;
		}
		return dal.hasExistBatchLabel(startLabel, endLabel, option_type,optionId);
	}
	
	/**
	 * 检测某个标签段是否已经存在在激活表中
	 * 
	 * @param labelId
	 * @return
	 */
	public boolean hasExistBatchLabelInTwoType(String startLabel, String endLabel, int current_option_type, int other_option_type,int optionId){
		if (dal == null) {
			return false;
		}
		return dal.hasExistBatchLabelInTwoType(startLabel, endLabel, current_option_type, other_option_type, optionId);
	}
}
