mirror of
https://github.com/Av0idD4rk/packmate.git
synced 2026-10-23 16:31:01 +00:00
Ещё раз исправлена ошибка
This commit is contained in:
parent
042d9b6c3b
commit
ceb8009742
@ -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,16 +24,12 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Packet save(Packet packet) {
|
||||
return repository.save(packet);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user