package cn.bsystem.ptuserrole.service;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.base.bean.BaseService;
import cn.base.util.CommUtils;
import cn.bsystem.ptuserrole.dao.SbtdtpqxDao;

@Service("sbtdtpqxService")
public class SbtdtpqxService extends BaseService {
	
	private static Log log = LogFactory.getLog(SbtdtpqxService.class);
	
	@Autowired
	private SbtdtpqxDao sbtdtpqxDao;
	
	/**
	 * 保存记录
	 * 
	 * @param
	 * @return
	 */
	public void insert_Sbtdtpqx(Map map) throws SQLException{
		CommUtils.addParams(map, false);
		sbtdtpqxDao.insert_Sbtdtpqx(map);
	}

	
	/**
	 * 修改记录
	 * 
	 * @param
	 * @return
	 */
	public Integer update_Sbtdtpqx(Map map) throws SQLException{
		CommUtils.validateUpdateParams(map);
		CommUtils.addParams(map, true);
		return sbtdtpqxDao.update_Sbtdtpqx(map);
	}
	
	/**
	 * 删除记录
	 * 
	 * @param
	 * @return
	 */
	public Integer delete_Sbtdtpqx(Map map) throws SQLException{
		CommUtils.validateDeleteParams(map);
		return sbtdtpqxDao.delete_Sbtdtpqx(map);
	}
	
	/**
	 * 批处理删除记录
	 * 
	 * @param
	 */
	public Integer batch_delete_Sbtdtpqx(Map map) throws SQLException{
		return sbtdtpqxDao.batch_delete_Sbtdtpqx(map);
	}

	
	/**
	 * 查询总数
	 * 
	 * @param
	 * @return
	 */
	public Integer count_Sbtdtpqx(Map map) throws SQLException{
		return sbtdtpqxDao.count_Sbtdtpqx(map);
	}
	
	/**
	 * 查询列表记录SELECT
	 * 
	 * @param
	 * @return
	 */
	public List<Map> query_Sbtdtpqx(Map map) throws SQLException{
		return sbtdtpqxDao.query_Sbtdtpqx(map);
	}
	
	/**
	 * 查询一条
	 * 
	 * @param
	 * @return
	 */
	public Map get_Sbtdtpqx(Map map) throws SQLException{
		return sbtdtpqxDao.get_Sbtdtpqx(map);
	}
	
	/**
	 * 导出EXCEL
	 * 
	 * @param
	 * @return
	 */
	public Map exportSbtdtpqx(Map map) throws SQLException{
		return this.listSbtdtpqxByPage(map);
	}
	
	/**
	 * Sbtdtpqx 分页
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	public Map listSbtdtpqxByPage(Map map) throws SQLException {
		List<Map> list = sbtdtpqxDao.query_Sbtdtpqx(map);
		Integer totalCount = sbtdtpqxDao.count_Sbtdtpqx(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
}
