From c215e40a9155b80a760f0c594462ce9b2e647c01 Mon Sep 17 00:00:00 2001 From: johnniang <1340692778@qq.com> Date: Tue, 19 Feb 2019 20:57:57 +0800 Subject: [PATCH] Add BaseRepository --- .../halo/repository/base/BaseRepository.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/java/cc/ryanc/halo/repository/base/BaseRepository.java diff --git a/src/main/java/cc/ryanc/halo/repository/base/BaseRepository.java b/src/main/java/cc/ryanc/halo/repository/base/BaseRepository.java new file mode 100644 index 000000000..c1b3c4a3b --- /dev/null +++ b/src/main/java/cc/ryanc/halo/repository/base/BaseRepository.java @@ -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 doamin type + * @param id type + * @author johnniang + */ +@NoRepositoryBean +public interface BaseRepository extends JpaRepository { + + /** + * 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 findAllByIdIn(@NonNull Iterable 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 ids); +}