From 8b362e1ebc931dae1f91f906bb2ecde36e7b29f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Wed, 21 Mar 2012 00:44:55 +0100 Subject: [PATCH] rooms controller --- .../de/ctdo/bunti/web/RoomsController.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/de/ctdo/bunti/web/RoomsController.java diff --git a/src/main/java/de/ctdo/bunti/web/RoomsController.java b/src/main/java/de/ctdo/bunti/web/RoomsController.java new file mode 100644 index 0000000..5928cf1 --- /dev/null +++ b/src/main/java/de/ctdo/bunti/web/RoomsController.java @@ -0,0 +1,38 @@ +package de.ctdo.bunti.web; + +import de.ctdo.bunti.control.BuntiController; +import de.ctdo.bunti.model.Room; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import java.util.Collection; + +@Controller +@RequestMapping(value = "/rooms") +public class RoomsController { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomsController.class); + private BuntiController controller; + + + @Autowired + public final void setController(BuntiController controller) { + this.controller = controller; + } + + @RequestMapping(value = "/", method = RequestMethod.GET) + public @ResponseBody Collection getAll() { + LOGGER.info("handle GET /rooms/" + " request"); + return controller.getAllRooms(); + } + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + public @ResponseBody + Room getDeviceById(@PathVariable("id") int id) { + LOGGER.info("handle GET /rooms/id" + id + " request"); + return controller.getRoomById(id); + } + +}