Merge branch 'maint/lp'
This commit is contained in:
commit
351f1b1816
src/main/java/de/ctdo/bunti
|
@ -1,6 +1,7 @@
|
|||
package de.ctdo.bunti.control;
|
||||
|
||||
import de.ctdo.bunti.model.BuntiDevice;
|
||||
import de.ctdo.bunti.model.Room;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
@ -12,4 +13,7 @@ public interface BuntiController {
|
|||
|
||||
boolean updateDeviceData(int deviceId, Map<String, Object> options);
|
||||
|
||||
Collection<Room> getAllRooms();
|
||||
Room getRoomById(int roomId);
|
||||
|
||||
}
|
||||
|
|
|
@ -54,6 +54,16 @@ public class BuntiControllerImpl implements BuntiController, ApplicationEventPub
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Room> getAllRooms() {
|
||||
return roomsDAO.getRooms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Room getRoomById(int roomId) {
|
||||
return roomsDAO.getRoom(roomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BuntiDevice> getAllDevices() {
|
||||
return devicesDAO.getAllDevices();
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Validator;
|
||||
import java.util.*;
|
||||
|
||||
@Controller
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue