First Controller
This commit is contained in:
parent
d9348bb6da
commit
2681806091
5 changed files with 58 additions and 7 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
|||
**/.DS_Store
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="12" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="11.0.3" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -13,6 +13,8 @@ if [ "$NO_VERIFY" ]; then
|
|||
fi
|
||||
|
||||
# list all added/copied/modified/renamed java files
|
||||
git diff --staged --name-only --diff-filter=ACMR | egrep -a '.java$' | tr "\n" "\0" |
|
||||
# run google-java-format on each file and re-stage any new changes
|
||||
xargs -0 -I % echo "$format_cmd --aosp -i '%'; git add -f '%'" | sh
|
||||
files="`git diff --staged --name-only --diff-filter=ACMR | egrep -a '.java$' | tr \"\\n\" \" \"`"
|
||||
for f in $files; do
|
||||
$format_cmd --aosp -i "$f"
|
||||
git add -f "$f"
|
||||
done
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package ch.usi.inf.sa4.sanmarinoes.smarthut.controller;
|
||||
|
||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight;
|
||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLightRepository;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@EnableAutoConfiguration
|
||||
@RequestMapping("/dimmableLight")
|
||||
public class DeviceController {
|
||||
|
||||
@Autowired private DimmableLightRepository dimmableLightService;
|
||||
|
||||
@GetMapping
|
||||
public List<DimmableLight> getAll() {
|
||||
return dimmableLightService.getList();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public DimmableLight getById(@PathVariable("id") long id) {
|
||||
return dimmableLightService.getList();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public DimmableLight create(@RequestBody DimmableLight dl) {
|
||||
return dimmableLightService.create(dl);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public DimmableLight update(@PathVariable("id") long id, @RequestBody DimmableLight dl) {
|
||||
return dimmableLightService.update(id, dl);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public void delete(@PathVariable("id") long id) {
|
||||
dimmableLightService.delete(id);
|
||||
}
|
||||
}
|
|
@ -3,15 +3,14 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.controller;
|
|||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.*;
|
||||
import java.util.*;
|
||||
import org.springframework.boot.autoconfigure.*;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@EnableAutoConfiguration
|
||||
@Controller
|
||||
// @Mapping("/light")
|
||||
public class WelcomeController {
|
||||
|
||||
@GetMapping("/")
|
||||
@GetMapping
|
||||
List<Device> testDevices() {
|
||||
return Arrays.asList(
|
||||
new KnobDimmer(),
|
||||
|
|
Loading…
Reference in a new issue