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); +}