New Controllers

This commit is contained in:
omenem 2020-02-26 13:25:38 +01:00
parent 4818929dad
commit ae993b0bab
4 changed files with 191 additions and 0 deletions

View file

@ -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<ButtonDimmer> findAll() {
return buttonDimmerService.findAll();
}
@GetMapping("/{id}")
public Optional<ButtonDimmer> 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);
}
}

View file

@ -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<KnobDimmer> findAll() {
return knobDimmerService.findAll();
}
@GetMapping("/{id}")
public Optional<KnobDimmer> 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);
}
}

View file

@ -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<MotionSensor> findAll() {
return motionSensorService.findAll();
}
@GetMapping("/{id}")
public Optional<MotionSensor> 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);
}
}

View file

@ -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<RegularLight> findAll() {
return regularLightService.findAll();
}
@GetMapping("/{id}")
public Optional<RegularLight> 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);
}
}