Добавлено редактирование сервисов

This commit is contained in:
serega6531
2019-04-26 03:26:28 +03:00
parent f3e69c2d2c
commit 66c366df02
9 changed files with 124 additions and 3 deletions

View File

@@ -0,0 +1,37 @@
package ru.serega6531.packmate.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ru.serega6531.packmate.model.Service;
import ru.serega6531.packmate.repository.ServiceRepository;
import java.util.List;
@RestController
@RequestMapping("/api/service/manage")
public class ServicesController {
private final ServiceRepository repository;
@Autowired
public ServicesController(ServiceRepository repository) {
this.repository = repository;
}
@GetMapping
public List<Service> getServices() {
return repository.findAll();
}
@DeleteMapping("/{port}")
public void deleteService(@PathVariable int port) {
repository.deleteById(port);
}
@PostMapping
public List<Service> addService(@RequestBody Service service) {
repository.save(service);
return getServices();
}
}

View File

@@ -0,0 +1,26 @@
package ru.serega6531.packmate.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ru.serega6531.packmate.model.Stream;
import java.util.Collections;
import java.util.List;
@RestController
@RequestMapping("/api/service/")
public class StreamsController {
@GetMapping("/all")
public List<Stream> getStreams() {
return Collections.emptyList();
}
@GetMapping("/{port}")
public List<Stream> getStreams(@PathVariable int port) {
return Collections.emptyList();
}
}