diff --git a/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAO.java b/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAO.java index 78fa900..13bd25c 100644 --- a/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAO.java +++ b/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAO.java @@ -6,7 +6,9 @@ import de.ctdo.bunti.model.*; public interface BuntiDevicesDAO { + Collection getAllDevices(); Collection getAllDMXDevices(); BuntiDevice getDeviceById(int deviceId); - + + } diff --git a/src/main/java/de/ctdo/bunti/web/RestController.java b/src/main/java/de/ctdo/bunti/web/RestController.java new file mode 100644 index 0000000..37f2907 --- /dev/null +++ b/src/main/java/de/ctdo/bunti/web/RestController.java @@ -0,0 +1,44 @@ +package de.ctdo.bunti.web; + +import de.ctdo.bunti.control.BuntiController; +import de.ctdo.bunti.dao.BuntiDevicesDAO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class RestController { + + private BuntiDevicesDAO devicesDAO; + private BuntiController controller; + + @Autowired + public final void setDevicesDAO(BuntiDevicesDAO devicesDAO) { + this.devicesDAO = devicesDAO; + } + + @Autowired + public final void setController(BuntiController controller) { + this.controller = controller; + } + + @RequestMapping(value = "/devices", method = RequestMethod.GET) + public final ModelAndView getAll() { + return new ModelAndView("deviceList", "deviceList", devicesDAO.getAllDevices()); + } + + @RequestMapping(value = "/devices/{id}", method = RequestMethod.GET) + public final ModelAndView getDeviceById(@PathVariable("id") int id) { + return new ModelAndView("device", "device", devicesDAO.getDeviceById(id)); + } + + @RequestMapping(value = "/devices/{id}", method = RequestMethod.PUT) + public final ModelAndView setDeviceById(@PathVariable("id") int id) { + //controller.setDevice(id, ... ) + return new ModelAndView("device", "device", devicesDAO.getDeviceById(id)); + } + +}