adding new REST controller

This commit is contained in:
Lucas Pleß 2012-03-07 00:41:56 +01:00
parent 40bf50c0f2
commit d5084b1290
2 changed files with 47 additions and 1 deletions

View File

@ -6,7 +6,9 @@ import de.ctdo.bunti.model.*;
public interface BuntiDevicesDAO {
Collection<BuntiDevice> getAllDevices();
Collection<BuntiDMXDevice> getAllDMXDevices();
BuntiDevice getDeviceById(int deviceId);
}

View File

@ -0,0 +1,44 @@
package de.ctdo.bunti.web;
import de.ctdo.bunti.control.BuntiController;
import de.ctdo.bunti.dao.BuntiDevicesDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class RestController {
private BuntiDevicesDAO devicesDAO;
private BuntiController controller;
@Autowired
public final void setDevicesDAO(BuntiDevicesDAO devicesDAO) {
this.devicesDAO = devicesDAO;
}
@Autowired
public final void setController(BuntiController controller) {
this.controller = controller;
}
@RequestMapping(value = "/devices", method = RequestMethod.GET)
public final ModelAndView getAll() {
return new ModelAndView("deviceList", "deviceList", devicesDAO.getAllDevices());
}
@RequestMapping(value = "/devices/{id}", method = RequestMethod.GET)
public final ModelAndView getDeviceById(@PathVariable("id") int id) {
return new ModelAndView("device", "device", devicesDAO.getDeviceById(id));
}
@RequestMapping(value = "/devices/{id}", method = RequestMethod.PUT)
public final ModelAndView setDeviceById(@PathVariable("id") int id) {
//controller.setDevice(id, ... )
return new ModelAndView("device", "device", devicesDAO.getDeviceById(id));
}
}