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.SbtdjqqxDao;

@Service("sbtdjqqxService")
public class SbtdjqqxService extends BaseService {
	
	private static Log log = LogFactory.getLog(SbtdjqqxService.class);
	
	@Autowired
	private SbtdjqqxDao sbtdjqqxDao;
	
	/**
	 * 保存记录
	 * 
	 * @param
	 * @return
	 */
	public void insert_Sbtdjqqx(Map map) throws SQLException{
		CommUtils.addParams(map, false);
		sbtdjqqxDao.insert_Sbtdjqqx(map);
	}

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

	
	/**
	 * 查询总数
	 * 
	 * @param
	 * @return
	 */
	public Integer count_Sbtdjqqx(Map map) throws SQLException{
		return sbtdjqqxDao.count_Sbtdjqqx(map);
	}
	
	/**
	 * 查询列表记录SELECT
	 * 
	 * @param
	 * @return
	 */
	public List<Map> query_Sbtdjqqx(Map map) throws SQLException{
		return sbtdjqqxDao.query_Sbtdjqqx(map);
	}
	
	/**
	 * 查询一条
	 * 
	 * @param
	 * @return
	 */
	public Map get_Sbtdjqqx(Map map) throws SQLException{
		return sbtdjqqxDao.get_Sbtdjqqx(map);
	}
	
	/**
	 * 导出EXCEL
	 * 
	 * @param
	 * @return
	 */
	public Map exportSbtdjqqx(Map map) throws SQLException{
		return this.listSbtdjqqxByPage(map);
	}
	
	/**
	 * Sbtdjqqx 分页
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	public Map listSbtdjqqxByPage(Map map) throws SQLException {
		List<Map> list = sbtdjqqxDao.query_Sbtdjqqx(map);
		Integer totalCount = sbtdjqqxDao.count_Sbtdjqqx(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
	
	
	/**
	 * listSbtdjqqx_ByUserRolePage 分页
	 * @param map
	 * @return 
	 * @throws SQLException
	 */
	public Map listSbtdjqqx_ByUserRolePage(Map map) throws SQLException {
		List<Map> list = sbtdjqqxDao.query_Sbtdjqqx_ByUserRolePage(map);
		Integer totalCount = sbtdjqqxDao.count_Sbtdjqqx_ByUserRolePage(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
	
	public Integer count_Sbtdjqqx_bybmbh(Map map) throws SQLException{
		return sbtdjqqxDao.count_Sbtdjqqx_bybmbh(map);
	}
	
	public Integer update_bmbh_Sbtdjqqx_bysbtd(Map map) throws SQLException{
		CommUtils.addParams(map, true);
		return sbtdjqqxDao.update_bmbh_Sbtdjqqx_bysbtd(map);
	}
	
	public Integer update_Sbtdjqqx_qx(Map map) throws SQLException{
		CommUtils.validateUpdateParams(map);
		CommUtils.addParams(map, true);
		return sbtdjqqxDao.update_Sbtdjqqx_qx(map);
	}
	
	/**
	 * 查询客户通配权限
	 * 
	 * @param
	 * @return
	 */
	public List<Map> query_Xtkhtptdqx(Map map) throws SQLException{
		return sbtdjqqxDao.query_Xtkhtptdqx(map);
	}
	
	/**
	 * listSbtdjqqx_ByUserRolePage 分页
	 * @param map
	 * @return 
	 * @throws SQLException
	 */
	public Map list_kh_jqtd_right_ByPage(Map map) throws SQLException {
		List<Map> list = sbtdjqqxDao.query_kh_jqtd_right(map);
		Integer totalCount = sbtdjqqxDao.count_kh_jqtd_right(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
	

	/**
	 * listSbtdjqqx_ByUserRolePage 分页
	 * @param map
	 * @return 
	 * @throws SQLException
	 */
	public Map list_jg_jqtd_right_ByPage(Map map) throws SQLException {
		List<Map> list = sbtdjqqxDao.query_jg_jqtd_right(map);
		Integer totalCount = sbtdjqqxDao.count_jg_jqtd_right(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
}
