bunti/src/main/java/de/ctdo/bunti/web/DevicesController.java

37 lines
1.0 KiB
Java
Raw Normal View History

package de.ctdo.bunti.web;
import de.ctdo.bunti.dao.BuntiDevicesDAO;
import de.ctdo.bunti.model.BuntiDevice;
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 = "/devices")
public class DevicesController {
@Autowired
2012-05-25 23:56:44 +00:00
private BuntiDevicesDAO devicesDAO;
@RequestMapping(value = "", method = RequestMethod.GET)
2012-03-30 15:00:30 +00:00
@ResponseBody
public Collection<BuntiDevice> getAll() {
2012-05-25 23:56:44 +00:00
return devicesDAO.getAllDevices();
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
2012-03-30 15:00:30 +00:00
@ResponseBody
public BuntiDevice getDeviceById(@PathVariable("id") int id) {
2012-05-25 23:56:44 +00:00
return devicesDAO.getDeviceById(id);
}
@RequestMapping(value = "", method = RequestMethod.POST)
2012-03-30 15:00:30 +00:00
@ResponseBody
2012-05-25 23:56:44 +00:00
public String setDevices(@RequestBody BuntiDevice device) {
devicesDAO.addDevice(device);
return "{\"status\":\"OK\"}";
}
}