From 1ab4fee6ff2fc60b1ddbf506e6af41816294adf3 Mon Sep 17 00:00:00 2001 From: omenem Date: Wed, 26 Feb 2020 18:56:47 +0100 Subject: [PATCH] Little changes to Room and dimmableLight classes --- .../controller/DimmableLightController.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/DimmableLightController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/DimmableLightController.java index 0cd1144..32faf36 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/DimmableLightController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/DimmableLightController.java @@ -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 getAll() { - return dimmableLightService.getList(); + public Iterable findAll() { + return dimmableLightService.findAll(); } @GetMapping("/{id}") - public DimmableLight getById(@PathVariable("id") long id) { - return dimmableLightService.getById(); + public Optional 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); } }