package cn.orm.abs;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import cn.common.exception.BusinessException;
import cn.orm.sqltoy.model.Page;

public interface ISqlToySamExt extends SqlToyHelperDao 
{
	/**通用方法：是否存在满足查询条件的至少一条记录：参数whereMap不含有区间条件*/
	Boolean ifExistRecord(String tableName,Map<String, Object> whereMap);
	
	/**辅助方法*/
	Page<?> getPage(Map<String, Object> pageMap);
	Page<?> getPage(Integer pageNo,Integer pageSize);
	/**数据库分页查询 参数 pageMap不含有区间条件*/
	Page<?> getPage(String tableName,Map<String, Object> pageMap) throws BusinessException;
	/**分页获取*/
	Page<?> getPage(String tableName,Map<String, Object> pageMap,String rangeField) throws BusinessException;
    Page<?> getPageBySql(String sqlId,Map<String, Object> pageMap);
	
	/**查询结果可以转换为某个实体类*/
	List<?> getEntityListBySql(String sqlId,Map<String, Object> whereMap, Class<?> voClass);
	List<?> getEntityList(String sqlId, Class<?> voClass);
	List<?> getEntityList(String tableName,Map<String, Object> whereMap, Class<?> voClass);
	List<?> getEntityTop(String tableName,Serializable entity,Map<String, Object> queryParam,double size);
		
	/**返回满足条件记录数：参数paramsMap不含有区间条件*/	
	Long getRecordNum(String tableName,Map<String, Object> whereMap);
	
	
	/**查询结果保持次序不变*/
	List<Map<String, Object>> getList_order(String tableName,String item,Map<String, Object> whereMap);
	List<Map<String, Object>> getList_order(String tableName,String item,Map<String, Object> paramMap,String rangeField);
	List<Map<String, Object>> getList_order(String tableName,String item,String where);
	List<Map<String, Object>> getListBySql_order(String sql);
	List<Map<String, Object>> getListBySql_order(String sql,Map<String, Object> paramsMap);
	List<Map<String, Object>> getListByPage_order(String tableName,Map<String, Object> pageMap,String rangeField);
	
	/**数据库查询 参数whereMap不含有区间条件*/
	List<Map<String, Object>> getListByPage(String tableName,Map<String, Object> pageMap,String rangeField);
	
	/**一次获取全部满足条件的信息*/
	List<Map<String, Object>> getList(String tableName,Map<String, Object> whereParam);
	
	List<Map<String, Object>> getList(String tableName);
	/**获取指定表中的某些字段，字段用,分割, 未指定查询所有字段*/
	List<Map<String, Object>> getList(String tableName,String item);
	List<Map<String, Object>> getList(String tableName,String item,String where);
	List<Map<String, Object>> getList(String tableName,String item,String rField,String where);
	List<Map<String, Object>> getList(String tableName,String item,Map<String, Object> whereMap);
	List<Map<String, Object>> getList(String tableName,String item,List<?> paramList);
		
	List<Map<String, Object>> getListBySql(String sql);
	List<Map<String, Object>> getListBySql(String sql,Map<String, Object> queryParam);
	
	
	List<Map<String, Object>> getListBySql_w(String sql,Map<String, Object> whereParam);
	List<Map<String, Object>> getList_or(String tableName,Map<String, Object> whereParam);
	
	/**获取全部满足条件的信息, 最多一条记录*/
	Map<String,Object> getMap(String tableName,Map<String, Object> whereMap);
	Map<String,Object> getMap(String tableName,String item,Map<String, Object> whereMap);
	Map<String,Object> getMapBySql(String sql,Map<String, Object> where);
	/*将满足条件的某个字段field以","拼接字符串作为结果返回*/ 
	Map<String, Object> getFieldByGroup(String tableName,String field,Map<String, Object> whereMap);
		
	Boolean deleteByBean(Class<?> pojo, Object[] longIds);
	/**单表：删除一条记录 */
	Boolean delById(String tableName,Map<String, Object> whereParam) throws BusinessException;
	/**单表：删除一条记录 */
	Boolean delById(String tableName,String id) throws BusinessException;
	/**单表：单一主键对象的批量删除 */
	Boolean delByIds(String tableName,String field,Object[] longIds);
	/**单表：批量删除 */
	Boolean delBatch(String tableName,List<String> idList) throws BusinessException;
	/**单表：删除所有记录 */
	Boolean removeAll(String tableName) throws BusinessException;
	/**单表：先删除满足条件的记录，然后进行插入 */
	Boolean delInsert(String tableName, Map<String,Object> jsonArray)throws BusinessException; 
	/**多表: 批量删除记录 删除条件一样*/
	Boolean delBatch_where(String tableName,Map<String, Object> whereParam) throws BusinessException;

	/**单表：批量更新某些字段keyParam：key|value */
	Boolean updateBatch_where(String tableName,String keyParam,Map<String,Object> setMap) throws BusinessException;
	/**单表：批量更新某些字段 */
	Boolean updateBatch(String tableName,List<String> idList,Map<String,Object> paramMap) throws BusinessException;
	/**单表：更新一条记录的某些字段 */
	Boolean update(String tableName,String id,Map<String,Object> paramMap) throws BusinessException;
	/**单表：更新一条记录*/
	Boolean update(String tableName, Map<String, Object> mapRecord) throws BusinessException;
	/**对单个对象的某个属性进行更新，属性值为空的不进行更新*/
	Boolean updateFieldByBean(Class<?> entityClass,Map<String,Object> updateMap,Map<String,Object> whereMap);
	
	/**单表：插入一条记录*/
	Boolean insert(String tableName, Map<String, Object> mapRecord) throws BusinessException;
	/**单表：插入一条记录。genKey:true系统自动产生主键*/
	Boolean insert(String tableName, Map<String, Object> mapRecord,Boolean genKey) throws BusinessException;
}
