Little changes to Room and dimmableLight classes

This commit is contained in:
omenem 2020-02-26 18:56:47 +01:00
parent 4b9944ab0d
commit 1ab4fee6ff

View file

@ -2,7 +2,7 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.controller;
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight;
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLightRepository;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.DeleteMapping;
@ -22,27 +22,27 @@ public class DimmableLightController {
@Autowired private DimmableLightRepository dimmableLightService;
@GetMapping
public List<DimmableLight> getAll() {
return dimmableLightService.getList();
public Iterable<DimmableLight> findAll() {
return dimmableLightService.findAll();
}
@GetMapping("/{id}")
public DimmableLight getById(@PathVariable("id") long id) {
return dimmableLightService.getById();
public Optional<DimmableLight> findById(@PathVariable("id") long id) {
return dimmableLightService.findById(id);
}
@PostMapping
public DimmableLight create(@RequestBody DimmableLight dl) {
return dimmableLightService.create(dl);
public DimmableLight save(@RequestBody DimmableLight dl) {
return dimmableLightService.save(dl);
}
@PutMapping("/{id}")
public DimmableLight update(@PathVariable("id") long id, @RequestBody DimmableLight dl) {
return dimmableLightService.update(id, dl);
@PutMapping
public DimmableLight update(@RequestBody DimmableLight dl) {
return dimmableLightService.save(dl);
}
@DeleteMapping("/{id}")
public void delete(@PathVariable("id") long id) {
dimmableLightService.delete(id);
dimmableLightService.deleteById(id);
}
}