package fr.zng.xxzx.common.dao.impl;

import java.util.List;

import fr.zng.xxzx.common.dao.StoreDao;
import fr.zng.xxzx.common.dao.base.BaseDao;
import fr.zng.xxzx.common.entity.EquipEntity;
import fr.zng.xxzx.common.entity.StoreEntity;
import fr.zng.xxzx.util.StringUtil;

public class StoreDaoImpl extends BaseDao implements StoreDao{

	public List<StoreEntity> search(StoreEntity en) {
		List<StoreEntity> result = null;
		try {
			makeSession();
			result = session.selectList("Store.search", en);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			close();
		}
        return result;
	}

	public int getCount(StoreEntity en) {
		Integer cnt = 0;
		try {
			makeSession();
			cnt = session.selectOne("Store.getCount", en);
	        if (StringUtil.isEmpty(cnt)) {
	        	cnt = 0;
	        }
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			close();
		}
        return cnt;
	}

	public StoreEntity getDetailByPk(String pk) {
		List<StoreEntity> result = null;
		try {
			makeSession();
			result = session.selectList("Store.getDetailByPk", pk);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			close();
		}
		if(result.size()>0){
			return result.get(0);
		}else{
			return new StoreEntity();
		}
	}

}
