rooms controller

This commit is contained in:
Lucas Pleß 2012-03-21 00:44:55 +01:00
parent 64f90ce109
commit 8b362e1ebc
1 changed files with 38 additions and 0 deletions

View File

@ -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<Room> 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);
}
}