added User controller, renamed DeviceController
This commit is contained in:
parent
2681806091
commit
e26f5976c6
2 changed files with 43 additions and 2 deletions
|
@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
@RestController
|
@RestController
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@RequestMapping("/dimmableLight")
|
@RequestMapping("/dimmableLight")
|
||||||
public class DeviceController {
|
public class DimmableLightController {
|
||||||
|
|
||||||
@Autowired private DimmableLightRepository dimmableLightService;
|
@Autowired private DimmableLightRepository dimmableLightService;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class DeviceController {
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public DimmableLight getById(@PathVariable("id") long id) {
|
public DimmableLight getById(@PathVariable("id") long id) {
|
||||||
return dimmableLightService.getList();
|
return dimmableLightService.getById();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
|
@ -0,0 +1,41 @@
|
||||||
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.controller;
|
||||||
|
|
||||||
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.*;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@EnableAutoConfiguration
|
||||||
|
@Controller
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
@Autowired private UserRepository userRepository;
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public List<User> getAll() {
|
||||||
|
return userRepository.getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public User getById(@PathVariable("id") long id) {
|
||||||
|
return userRepository.getById();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public User create(@RequestBody User u) {
|
||||||
|
return userRepository.create(u);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public User update(@PathVariable("id") long id, @RequestBody User u) {
|
||||||
|
return userRepository.update(id, u);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public void delete(@PathVariable("id") long id) {
|
||||||
|
userRepository.delete(id);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue