Little changes to Room and dimmableLight classes
This commit is contained in:
parent
4b9944ab0d
commit
1ab4fee6ff
1 changed files with 11 additions and 11 deletions
|
@ -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.DimmableLight;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLightRepository;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
@ -22,27 +22,27 @@ public class DimmableLightController {
|
||||||
@Autowired private DimmableLightRepository dimmableLightService;
|
@Autowired private DimmableLightRepository dimmableLightService;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public List<DimmableLight> getAll() {
|
public Iterable<DimmableLight> findAll() {
|
||||||
return dimmableLightService.getList();
|
return dimmableLightService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public DimmableLight getById(@PathVariable("id") long id) {
|
public Optional<DimmableLight> findById(@PathVariable("id") long id) {
|
||||||
return dimmableLightService.getById();
|
return dimmableLightService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public DimmableLight create(@RequestBody DimmableLight dl) {
|
public DimmableLight save(@RequestBody DimmableLight dl) {
|
||||||
return dimmableLightService.create(dl);
|
return dimmableLightService.save(dl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping
|
||||||
public DimmableLight update(@PathVariable("id") long id, @RequestBody DimmableLight dl) {
|
public DimmableLight update(@RequestBody DimmableLight dl) {
|
||||||
return dimmableLightService.update(id, dl);
|
return dimmableLightService.save(dl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public void delete(@PathVariable("id") long id) {
|
public void delete(@PathVariable("id") long id) {
|
||||||
dimmableLightService.delete(id);
|
dimmableLightService.deleteById(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue