TbCfgEventDao.java 2.02 KB
package com.sitech.database.dao;

import java.util.HashMap;
import java.util.List;

import com.sitech.database.domain.TbCfgEvent;
import com.sitech.ismp.app.event.ExpressionHelper;


public class TbCfgEventDao extends BaseDao{	
	@SuppressWarnings("unchecked")
	public List<TbCfgEvent> queryEventCfgByUnitId(String unitId) {
		String condition = ExpressionHelper.genCondition(unitId);
		String sql = "select * from TB_CFG_EVENT where ENABLE=1 and (" + condition + ")";

		try {
			return sqlmapClient.queryForList("queryEventCfgByUnitId", sql);
		} catch (Exception e) {
			error.error("Exception while queryEventCfgByUnitId("+unitId+")", e);
			return null;
		}		
	}
	
	@SuppressWarnings("unchecked")
	public List<TbCfgEvent> queryEventCfgByKpiId(String kpiId) {
		String sql = "select * from TB_CFG_EVENT where ENABLE=1 and KPI_ID='"
				+ kpiId + "'";

		try {
			return sqlmapClient.queryForList("queryEventCfgByKpiId", sql);
		} catch (Exception e) {
			error.error("Exception while queryEventCfgByKpiId("+kpiId+")", e);
			return null;
		}		
	}

	@SuppressWarnings("unchecked")
	public List<TbCfgEvent> queryEventCfgAll(){		
		try {
			return (List<TbCfgEvent>) sqlmapClient.queryForList("queryEventCfgAll", null);
		} catch (Exception e) {
			error.error("Exception while queryEventCfgAll.", e);
			return null;
		}
	}



	public int deleteTbCfgEvent(String[] guid) {
		HashMap<String, String[]> params = new HashMap<String, String[]>();
		params.put("GUID", guid);

		try {
			return sqlmapClient.delete("deleteTbCfgEvent", params);
		} catch (Exception e) {
			error.error("Exception while deleteTbCfgEvent.", e);
			return -1;
		}		
	}
	
	public int deleteTbCfgEventAll() {
		try {
			return sqlmapClient.delete("deleteTbCfgEventAll", null);
		} catch (Exception e) {
			error.error("Exception while deleteTbCfgEvent.", e);
			return -1;
		}		
	}
	
	public void insertTbCfgEvent(TbCfgEvent tbCfgEvent) {
		try {
			sqlmapClient.insert("insertTbCfgEvent", tbCfgEvent);
		} catch (Exception e) {
			error.error("Exception while insertTbCfgEvent.", e);
		}
	}



}