package nc.impl.ws.esb;

import java.util.ArrayList;

import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.itf.ws.esb.IEsbDAO;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.BeanProcessor;
import nc.vo.ws.esb.CertificateVO;
import nc.vo.ws.esb.EsbinfoVO;

/**
 * @author 廖声豪  2018-02-04 ESB安全信息获取实现类
 */
public class EsbDAOImpl implements IEsbDAO {
	
	private BaseDAO DAO;

	@Override
	public EsbinfoVO[] findESB(String where) {//获取esb配置
		ArrayList<EsbinfoVO> list=null;
		try {
			list=(ArrayList<EsbinfoVO>) getDAO().executeQuery("select * from bgy_esbinfo where "+where
					, new BeanListProcessor(EsbinfoVO.class));
		} catch (DAOException e) {
			e.printStackTrace();
		}
		return list!=null && list.size()>0 ? list.toArray(new EsbinfoVO[list.size()]) : null;
	}
	
	@Override
	public CertificateVO findByPkCode(String pkcode) {//获取esb认证
		CertificateVO typevo=null;
		try {
//			typevo=(CertificateVO) getDAO().retrieveByPK(CertificateVO.class, pkcode);
			String sql ="select * from bgy_certificate where pk_code='"+pkcode+"'"; 
			typevo = (CertificateVO) getDAO().executeQuery(sql, new BeanProcessor(CertificateVO.class));
		} catch (DAOException e) {
			e.printStackTrace();
		}
		return typevo;
	}
	
	public BaseDAO getDAO(){
		if(DAO==null)
			DAO=new BaseDAO();
		return DAO;
	}

}
