adding new REST controller
This commit is contained in:
parent
40bf50c0f2
commit
d5084b1290
|
@ -6,7 +6,9 @@ import de.ctdo.bunti.model.*;
|
|||
|
||||
public interface BuntiDevicesDAO {
|
||||
|
||||
Collection<BuntiDevice> getAllDevices();
|
||||
Collection<BuntiDMXDevice> getAllDMXDevices();
|
||||
BuntiDevice getDeviceById(int deviceId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue