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 private BuntiDevicesDAO devicesDAO; @RequestMapping(value = "", method = RequestMethod.GET) @ResponseBody public Collection getAll() { return devicesDAO.getAllDevices(); } @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public BuntiDevice getDeviceById(@PathVariable("id") int id) { return devicesDAO.getDeviceById(id); } @RequestMapping(value = "", method = RequestMethod.POST) @ResponseBody public String setDevices(@RequestBody BuntiDevice device) { devicesDAO.addDevice(device); return "{\"status\":\"OK\"}"; } }