Add BaseRepository

pull/98/head
johnniang 2019-02-19 20:57:57 +08:00
parent d0167dcc64
commit c215e40a91
1 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,37 @@
package cc.ryanc.halo.repository.base;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.lang.NonNull;
import java.util.List;
/**
* Base repository interface contains some common methods.
*
* @param <DOMAIN> doamin type
* @param <ID> id type
* @author johnniang
*/
@NoRepositoryBean
public interface BaseRepository<DOMAIN, ID> extends JpaRepository<DOMAIN, ID> {
/**
* Finds all domain by id list and the specified sort.
*
* @param ids id list of domain must not be null
* @param sort the specified sort must not be null
* @return a list of domains
*/
@NonNull
List<DOMAIN> findAllByIdIn(@NonNull Iterable<ID> ids, @NonNull Sort sort);
/**
* Deletes by id list.
*
* @param ids id list of domain must not be null
* @return number of rows affected
*/
long deleteByIdIn(@NonNull Iterable<ID> ids);
}