diff options
| author | Kevin J Hoerr <khoerr@ksmpartners.com> | 2022-01-27 14:12:29 -0500 |
|---|---|---|
| committer | Kevin J Hoerr <khoerr@ksmpartners.com> | 2022-01-27 14:12:29 -0500 |
| commit | 615c8a0fc8d2b35da7df90115456d33444104c41 (patch) | |
| tree | aeab4261b4edaf63905bd008ce6992b0d2490916 /src/main/java/dev/submelon/pantry/ItemController.java | |
| parent | 8d8d8cdd639591c0c4c49b355db1152e310c22d6 (diff) | |
| download | pantry-615c8a0fc8d2b35da7df90115456d33444104c41.tar.gz pantry-615c8a0fc8d2b35da7df90115456d33444104c41.tar.bz2 pantry-615c8a0fc8d2b35da7df90115456d33444104c41.zip | |
Add error handling
Diffstat (limited to 'src/main/java/dev/submelon/pantry/ItemController.java')
| -rw-r--r-- | src/main/java/dev/submelon/pantry/ItemController.java | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/src/main/java/dev/submelon/pantry/ItemController.java b/src/main/java/dev/submelon/pantry/ItemController.java deleted file mode 100644 index 7021f0a..0000000 --- a/src/main/java/dev/submelon/pantry/ItemController.java +++ /dev/null @@ -1,43 +0,0 @@ -package dev.submelon.pantry; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -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.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -@RequestMapping(path="/items") -public class ItemController { - @Autowired - private ItemRepository itemRepository; - - @PostMapping(path="/add") - @ResponseBody - Integer addNewItem(@RequestParam String name, @RequestParam String description, @RequestParam String shortid, @RequestParam double quantity) { - Item item = new Item(); - item.setName(name); - item.setDescription(description); - item.setShortid(shortid); - item.setQuantity(quantity); - - Item updatedItem = itemRepository.save(item); - return updatedItem.getId(); - } - - @GetMapping(path="") - @ResponseBody - Iterable<Item> getAllItems() { - return itemRepository.findAll(); - } - - @GetMapping(path="/{shortid}") - @ResponseBody - Item getByShortid(@PathVariable String shortid) { - return itemRepository.findByShortid(shortid); - } - -} |
