Ещё раз исправлена ошибка
This commit is contained in:
@@ -9,8 +9,6 @@ import java.util.List;
|
||||
|
||||
public interface PacketRepository extends JpaRepository<Packet, Long> {
|
||||
|
||||
List<Packet> findAllByStream(Stream stream, Pageable pageable);
|
||||
|
||||
List<Packet> findAllByStreamAndIdGreaterThan(Stream stream, long packetId, Pageable pageable);
|
||||
|
||||
List<Packet> findAllByStreamAndIdLessThan(Stream stream, long packetId, Pageable pageable);
|
||||
|
||||
@@ -24,14 +24,10 @@ public class PacketService {
|
||||
public List<Packet> getPacketsForStream(Pagination pagination, Stream stream) {
|
||||
PageRequest page = PageRequest.of(0, pagination.getPageSize(), pagination.getDirection(), "id");
|
||||
|
||||
if(pagination.isFetchLatest()) { // последние пакеты
|
||||
return repository.findAllByStream(stream, page);
|
||||
} else {
|
||||
if (pagination.getDirection() == Sort.Direction.ASC) { // более новые пакеты
|
||||
return repository.findAllByStreamAndIdGreaterThan(stream, pagination.getStartingFrom(), page);
|
||||
} else { // более старые пакеты
|
||||
return repository.findAllByStreamAndIdLessThan(stream, pagination.getStartingFrom(), page);
|
||||
}
|
||||
if (pagination.getDirection() == Sort.Direction.ASC) { // более новые пакеты
|
||||
return repository.findAllByStreamAndIdGreaterThan(stream, pagination.getStartingFrom(), page);
|
||||
} else { // более старые пакеты
|
||||
return repository.findAllByStreamAndIdLessThan(stream, pagination.getStartingFrom(), page);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user