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