39 lines
1.1 KiB
Java
39 lines
1.1 KiB
Java
|
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 {
|
||
|
private BuntiDevicesDAO devicesDAO;
|
||
|
|
||
|
@Autowired
|
||
|
public void setDevicesDAO(BuntiDevicesDAO devicesDAO) {
|
||
|
this.devicesDAO = devicesDAO;
|
||
|
}
|
||
|
|
||
|
@RequestMapping(value = "", method = RequestMethod.GET)
|
||
|
public @ResponseBody Collection<BuntiDevice> getAll() {
|
||
|
return devicesDAO.getAllDevices();
|
||
|
}
|
||
|
|
||
|
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||
|
public @ResponseBody BuntiDevice getDeviceById(@PathVariable("id") int id) {
|
||
|
return devicesDAO.getDeviceById(id);
|
||
|
}
|
||
|
|
||
|
@RequestMapping(value = "", method = RequestMethod.POST)
|
||
|
public @ResponseBody BuntiDevice setDevices(@RequestBody BuntiDevice device) {
|
||
|
devicesDAO.addDevice(device);
|
||
|
return device;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|