BaseService.java 1.69 KB
package com.bsth.service;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.io.Serializable;
import java.util.Collection;
import java.util.Map;

/**
 * 
 * @ClassName: BaseService 
 * @Description: TODO(基础的Service接口) 
 * @author PanZhao 
 * @date 2016年3月17日 下午12:48:43 
 * 
 * @param <T>
 * @param <ID>
 */
public interface BaseService<T, ID extends Serializable> {
	/**
	 * 根据主键获取单个对象
	 * @param id
	 * @return
	 */
	T findById(ID id);
	
	/**
	 * 保存
	 * @param t
	 * @return
	 */
	Map<String, Object> save(T t);
	
	/**
	 * 
	 * @Title: list 
	 * @Description: TODO(多条件分页查询) 
	 * @param @param map 查询条件
	 * @param @param pageable 分页对象
	 * @throws
	 */
	Page<T> list(Map<String, Object> map, Pageable pageable);
	
	/**
	 * 
	 * @Title: list 
	 * @Description: TODO(多条件查询) 
	 * @throws
	 */
	Iterable<T> list(Map<String, Object> map);
	
	/**
	 * 获取所有
	 * @return
	 */
	Iterable<T> findAll();
	
	/**
	 * 
	 * @Title: deleteById 
	 * @Description: TODO(根据主键删除对象) 
	 * @param @param id
	 * @throws
	 */
	Map<String, Object> delete(ID id);

    /**
     * 后端验证查询数据是否重复。
     * @param params 查询条件
     * @return {status:状态编码,msg:错误描述},状态编码 @see com.bsth.common.ResponseCode
     */
    Map<String, Object> validateEquale(Map<String, Object> params);

    /**
     * 批量保存。
     * @param entities 实体列表
     * @return 保存后的entities
     */
    <S extends T> Collection<S> bulkSave(Collection<S> entities);
}