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

import java.util.List;

import android.content.Context;

import cn.net.caoyao.cpzshandset.bean.UnpackBean;
import cn.net.caoyao.cpzshandset.common.config.ConfigCreateService;
import cn.net.caoyao.cpzshandset.common.util.CacheGet;
import cn.net.caoyao.cpzshandset.db.presenter.UnPackDal;

public class UnPackBll{
	private UnPackDal dal;

	public UnPackBll(Context context) {
		ConfigCreateService service = new ConfigCreateService();
		dal = service.createUnPackDal(new CacheGet(), context);
	}

	/**
	 * 查询所有的拆包信息，并按照降序的顺序排序
	 */
	
	public List<UnpackBean> queryAllUnPackList() {
		if (dal == null) {
			return null;
		}
		return dal.queryAllUnPackList();
	}

	/**
	 * 查询所有的拆包信息，并按照降序的升序排序
	 */
	
	public List<UnpackBean> queryAllUnPackListASC() {
		if (dal == null) {
			return null;
		}
		return dal.queryAllUnPackListASC();
	}


	/**
	 * 根据拆包id，修改提交状态
	 * 
	 * @param status
	 * @param errorCode
	 * @param id
	 */
	
	public void updateUnpackStatusById(int status, int errorCode, int id) {
		if (dal == null) {
			return;
		}
		dal.updateUnpackStatusById(status, errorCode, id);
	}

	/**
	 * 通过激活id删除拆包信息
	 * 
	 * @param uBean
	 */
	
	public void deleteUnpackById(UnpackBean uBean) {
		if (dal == null) {
			return;
		}
		dal.deleteUnpackById(uBean);
	}

	/**
	 * 插入拆包信息
	 * 
	 * @param uBean
	 * @return
	 */
	
	public int insertUnpack(UnpackBean uBean) {
		if (dal == null) {
			return -1;
		}
		
		return dal.insertUnpack(uBean);
	}
	/**
	 * 拆包列表中已经存在该标签
	 * @param labelId
	 * @return
	 */
	public boolean hasExistUnpackLabel(String labelId){
		if (dal == null) {
			return false;
		}
		return dal.hasExistUnpackLabel(labelId);
	}
}
