From ae993b0bab3a2255b367a95ae1f66200c71f0c06 Mon Sep 17 00:00:00 2001 From: omenem Date: Wed, 26 Feb 2020 13:25:38 +0100 Subject: [PATCH] New Controllers --- .../controller/ButtonDimmerController.java | 47 ++++++++++++++++++ .../controller/KnobDimmerController.java | 48 +++++++++++++++++++ .../controller/MotionSensorController.java | 48 +++++++++++++++++++ .../controller/RegularLightController.java | 48 +++++++++++++++++++ 4 files changed, 191 insertions(+) create mode 100644 src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ButtonDimmerController.java create mode 100644 src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/KnobDimmerController.java create mode 100644 src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/MotionSensorController.java create mode 100644 src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RegularLightController.java diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ButtonDimmerController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ButtonDimmerController.java new file mode 100644 index 0000000..1098824 --- /dev/null +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ButtonDimmerController.java @@ -0,0 +1,47 @@ +package ch.usi.inf.sa4.sanmarinoes.smarthut.controller; + +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.ButtonDimmer; +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.ButtonDimmerRepository; +import java.util.Optional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@EnableAutoConfiguration +@RequestMapping("/buttonDimmer") +public class ButtonDimmerController { + @Autowired private ButtonDimmerRepository buttonDimmerService; + + @GetMapping + public Iterable findAll() { + return buttonDimmerService.findAll(); + } + + @GetMapping("/{id}") + public Optional findById(@PathVariable("id") long id) { + return buttonDimmerService.findById(id); + } + + @PostMapping + public ButtonDimmer save(@RequestBody ButtonDimmer bd) { + return buttonDimmerService.save(bd); + } + + @PutMapping + public ButtonDimmer update(@RequestBody ButtonDimmer bd) { + return buttonDimmerService.save(bd); + } + + @DeleteMapping("/{id}") + public void delete(@PathVariable("id") long id) { + buttonDimmerService.deleteById(id); + } +} diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/KnobDimmerController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/KnobDimmerController.java new file mode 100644 index 0000000..0696202 --- /dev/null +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/KnobDimmerController.java @@ -0,0 +1,48 @@ +package ch.usi.inf.sa4.sanmarinoes.smarthut.controller; + +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.KnobDimmer; +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.KnobDimmerRepository; +import java.util.Optional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@EnableAutoConfiguration +@RequestMapping("/knobDimmer") +public class KnobDimmerController { + + @Autowired private KnobDimmerRepository knobDimmerService; + + @GetMapping + public Iterable findAll() { + return knobDimmerService.findAll(); + } + + @GetMapping("/{id}") + public Optional findById(@PathVariable("id") long id) { + return knobDimmerService.findById(id); + } + + @PostMapping + public KnobDimmer save(@RequestBody KnobDimmer kd) { + return knobDimmerService.save(kd); + } + + @PutMapping + public KnobDimmer update(@RequestBody KnobDimmer kd) { + return knobDimmerService.save(kd); + } + + @DeleteMapping("/{id}") + public void delete(@PathVariable("id") long id) { + knobDimmerService.deleteById(id); + } +} diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/MotionSensorController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/MotionSensorController.java new file mode 100644 index 0000000..5ac2612 --- /dev/null +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/MotionSensorController.java @@ -0,0 +1,48 @@ +package ch.usi.inf.sa4.sanmarinoes.smarthut.controller; + +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.MotionSensor; +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.MotionSensorRepository; +import java.util.Optional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@EnableAutoConfiguration +@RequestMapping("/motionSensor") +public class MotionSensorController { + + @Autowired private MotionSensorRepository motionSensorService; + + @GetMapping + public Iterable findAll() { + return motionSensorService.findAll(); + } + + @GetMapping("/{id}") + public Optional findById(@PathVariable("id") long id) { + return motionSensorService.findById(id); + } + + @PostMapping + public MotionSensor save(@RequestBody MotionSensor ms) { + return motionSensorService.save(ms); + } + + @PutMapping + public MotionSensor update(@RequestBody MotionSensor ms) { + return motionSensorService.save(ms); + } + + @DeleteMapping("/{id}") + public void delete(@PathVariable("id") long id) { + motionSensorService.deleteById(id); + } +} diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RegularLightController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RegularLightController.java new file mode 100644 index 0000000..9a97abb --- /dev/null +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RegularLightController.java @@ -0,0 +1,48 @@ +package ch.usi.inf.sa4.sanmarinoes.smarthut.controller; + +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.RegularLight; +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.RegularLightRepository; +import java.util.Optional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@EnableAutoConfiguration +@RequestMapping("/regularLight") +public class RegularLightController { + + @Autowired private RegularLightRepository regularLightService; + + @GetMapping + public Iterable findAll() { + return regularLightService.findAll(); + } + + @GetMapping("/{id}") + public Optional findById(@PathVariable("id") long id) { + return regularLightService.findById(id); + } + + @PostMapping + public RegularLight save(@RequestBody RegularLight rl) { + return regularLightService.save(rl); + } + + @PutMapping + public RegularLight update(@RequestBody RegularLight rl) { + return regularLightService.save(rl); + } + + @DeleteMapping("/{id}") + public void delete(@PathVariable("id") long id) { + regularLightService.deleteById(id); + } +}