Исправлена пагинация пакетов

This commit is contained in:
sshkurov
2022-02-06 10:50:32 +03:00
parent 56ed2f5878
commit b48e23fdc5
7 changed files with 52 additions and 42 deletions

View File

@@ -1,12 +1,10 @@
package ru.serega6531.packmate.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import ru.serega6531.packmate.model.Packet;
import ru.serega6531.packmate.model.pojo.PacketDto;
import ru.serega6531.packmate.model.pojo.PacketPagination;
import ru.serega6531.packmate.service.StreamService;
import java.util.List;
@@ -24,8 +22,8 @@ public class PacketController {
}
@PostMapping("/{streamId}")
public List<PacketDto> getPacketsForStream(@PathVariable long streamId) {
List<Packet> packets = streamService.getPackets(streamId);
public List<PacketDto> getPacketsForStream(@PathVariable long streamId, @RequestBody PacketPagination pagination) {
List<Packet> packets = streamService.getPackets(streamId, pagination.getStartingFrom(), pagination.getPageSize());
return packets.stream()
.map(streamService::packetToDto)
.collect(Collectors.toList());