package cn.yw.videosyncchannel.dao;
import cn.base.dao.BaseSqlMapDAO;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientCallback;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapExecutor;

@Repository("ywvideosyncchannelDao")
public class YwvideosyncchannelDao  extends BaseSqlMapDAO{

	/**
	 * 增加记录
	 */
	public void insert_Ywvideosyncchannel(Map map) throws SQLException{
		this.insert("insert_Ywvideosyncchannel",map);
	}
	
	/**
	 * 批处理增加记录
	 */
	/*
	public void batch_insert_Ywvideosyncchannel(List batch) throws SQLException{
		this.insert("batch_insert_Ywvideosyncchannel",batch);
	}
	*/
	 
	/**
	 * 修改记录
	 */
	public Integer update_Ywvideosyncchannel(Map map) throws SQLException{
		return this.update("update_Ywvideosyncchannel",map);
	}
	
	/**
	 * 删除记录
	 */
	public Integer delete_Ywvideosyncchannel(Map map) throws SQLException{
		return this.delete("delete_Ywvideosyncchannel",map);
	}

	/**
	 * 批量新增
	 */
	public void batch_insert_Ywvideosyncchannel(final List<Map> params) throws SQLException{
//		this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
//			
//			@Override
//			public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
//				// TODO Auto-generated method stub
//				executor.startBatch();
//				for(Map map : params) {
//					executor.insert("insert_Ywvideosyncchannel", map);
//				}
//				executor.executeBatch();
//				return null;
//			}
//		});
		try {
			this.getSqlMapClient().startTransaction();
			this.getSqlMapClient().startBatch();
			for (int i = 0; i < params.size(); i++) {
				this.getSqlMapClient().insert("insert_Ywvideosyncchannel",params.get(i));
			}
			this.getSqlMapClient().executeBatch();
			this.getSqlMapClient().commitTransaction();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			this.getSqlMapClient().endTransaction();
		}
	}
	
	/**
	 * 批处理删除记录
	 */
	
	/*
	public Integer batch_delete_Ywvideosyncchannel(Map map) throws SQLException{
		return this.delete("batch_delete_Ywvideosyncchannel",map);
	}
	*/
	
	/**
	 * 查询总数
	 */
	public Integer count_Ywvideosyncchannel(Map map) throws SQLException{
		return (Integer)this.queryForObject("count_Ywvideosyncchannel",map);
	}
	
	/**
	 * 查询列表记录
	 */
	public List<Map> query_Ywvideosyncchannel(Map map) throws SQLException{
		return this.queryForPage("query_Ywvideosyncchannel",map);
	}
	
	/**
	 * 查询列表记录
	 */
	public Map get_Ywvideosyncchannel(Map map) throws SQLException{
		return (Map) this.queryForObject("query_Ywvideosyncchannel",map);
	}
}
