Добавлены DTO для всех entity
This commit is contained in:
@@ -5,13 +5,14 @@ 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 ru.serega6531.packmate.model.Packet;
|
||||
import ru.serega6531.packmate.model.Stream;
|
||||
import ru.serega6531.packmate.model.pojo.PacketDto;
|
||||
import ru.serega6531.packmate.service.StreamService;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/packet/")
|
||||
@@ -25,10 +26,12 @@ public class PacketController {
|
||||
}
|
||||
|
||||
@PostMapping("/{streamId}")
|
||||
public List<Packet> getPacketsForStream(@PathVariable long streamId) {
|
||||
public List<PacketDto> getPacketsForStream(@PathVariable long streamId) {
|
||||
final Optional<Stream> stream = streamService.find(streamId);
|
||||
if (stream.isPresent()) {
|
||||
return stream.get().getPackets();
|
||||
return stream.get().getPackets().stream()
|
||||
.map(streamService::packetToDto)
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user