package cn.im.ptdlfw.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.im.ptdlfw.dao.PtdlfwzDao;

@Service("ptdlfwzService")
public class PtdlfwzService extends BaseService {
	
	private static Log log = LogFactory.getLog(PtdlfwzService.class);
	
	@Autowired
	private PtdlfwzDao ptdlfwzDao;
	
	/**
	 * 保存记录
	 * 
	 * @param
	 * @return
	 */
	public void insert_Ptdlfwz(Map map) throws SQLException{
		CommUtils.addParams(map, false);
		ptdlfwzDao.insert_Ptdlfwz(map);
	}

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

	
	/**
	 * 查询总数
	 * 
	 * @param
	 * @return
	 */
	public Integer count_Ptdlfwz(Map map) throws SQLException{
		return ptdlfwzDao.count_Ptdlfwz(map);
	}
	
	/**
	 * 查询列表记录SELECT
	 * 
	 * @param
	 * @return
	 */
	public List<Map> query_Ptdlfwz(Map map) throws SQLException{
		return ptdlfwzDao.query_Ptdlfwz(map);
	}
	
	/**
	 * 查询一条
	 * 
	 * @param
	 * @return
	 */
	public Map get_Ptdlfwz(Map map) throws SQLException{
		return ptdlfwzDao.get_Ptdlfwz(map);
	}
	
	/**
	 * 导出EXCEL
	 * 
	 * @param
	 * @return
	 */
	public Map exportPtdlfwz(Map map) throws SQLException{
		return this.listPtdlfwzByPage(map);
	}
	
	/**
	 * Ptdlfwz 分页
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	public Map listPtdlfwzByPage(Map map) throws SQLException {
		List<Map> list = ptdlfwzDao.query_Ptdlfwz(map);
		Integer totalCount = ptdlfwzDao.count_Ptdlfwz(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
}
