|
|
@@ -0,0 +1,45 @@
|
|
|
+package name.tflucke.ieat2.controllers;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+
|
|
|
+import name.tflucke.ieat2.models.Weight;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Provides APIs for reading USDA Weight objects.
|
|
|
+ *
|
|
|
+ * @author Thomas Flucke
|
|
|
+ * @since 2.0.0
|
|
|
+ */
|
|
|
+@RestController("/usda/weight")
|
|
|
+public class WeightController extends AbstractController<Weight> {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates a new controller
|
|
|
+ */
|
|
|
+ public WeightController() {
|
|
|
+ super(Weight.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ //@Override
|
|
|
+ @GetMapping("/usda/weight/{ndbno}")
|
|
|
+ public List<Weight> list(@PathVariable("ndbno") final String ndbno) {
|
|
|
+ return db.find(Weight.class).field("ndb_no").equal(ndbno).asList();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @GetMapping("/usda/weight")
|
|
|
+ public List<Weight> list() {
|
|
|
+ return super.list();
|
|
|
+ }
|
|
|
+}
|