Добавлено api пакетов
This commit is contained in:
@@ -3,30 +3,36 @@ package ru.serega6531.packmate.controller;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.serega6531.packmate.model.Packet;
|
||||
import ru.serega6531.packmate.model.Pagination;
|
||||
import ru.serega6531.packmate.model.Stream;
|
||||
import ru.serega6531.packmate.service.PacketService;
|
||||
import ru.serega6531.packmate.service.StreamService;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/packet/")
|
||||
public class PacketController {
|
||||
|
||||
private final PacketService service;
|
||||
private final StreamService streamService;
|
||||
private final PacketService packetService;
|
||||
|
||||
@Autowired
|
||||
public PacketController(PacketService service) {
|
||||
this.service = service;
|
||||
public PacketController(StreamService streamService, PacketService packetService) {
|
||||
this.streamService = streamService;
|
||||
this.packetService = packetService;
|
||||
}
|
||||
|
||||
@PostMapping("/all")
|
||||
public List<Packet> getPackets() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@PostMapping("/{stream}")
|
||||
public List<Packet> getStreams(@PathVariable int stream) {
|
||||
return Collections.emptyList();
|
||||
@PostMapping("/{streamId}")
|
||||
public List<Packet> getPacketsForStream(@PathVariable int streamId, @RequestBody Pagination pagination) {
|
||||
final Optional<Stream> stream = streamService.find(streamId);
|
||||
if(stream.isPresent()) {
|
||||
return packetService.getPacketsForStream(pagination, stream.get());
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user