getlist und lilsts im cotnroller implementiert
This commit is contained in:
1 parent
d373ecce2b
commit
0ac781114f
1 file changed
+18
-3
@@ -1,10 +1,12 @@
|
||||
package de.timaldinger.einkaufsliste.Controller;
|
||||
|
||||
import de.timaldinger.einkaufsliste.Dto.Get.*;
|
||||
import de.timaldinger.einkaufsliste.Dto.Patch.ShoppingListPatchDTO;
|
||||
import de.timaldinger.einkaufsliste.Dto.Post.ShoppingListPostDTO;
|
||||
import de.timaldinger.einkaufsliste.Dto.Response.ShoppingListResponseDTO;
|
||||
import de.timaldinger.einkaufsliste.Exceptions.ResourceNotFoundException;
|
||||
import de.timaldinger.einkaufsliste.Models.ShoppingItem;
|
||||
import de.timaldinger.einkaufsliste.Mapper.ShoppingCategoryMapper;
|
||||
import de.timaldinger.einkaufsliste.Mapper.ShoppingItemMapper;
|
||||
import de.timaldinger.einkaufsliste.Models.ShoppingList;
|
||||
import de.timaldinger.einkaufsliste.Repository.ShoppingCategoryRepository;
|
||||
import de.timaldinger.einkaufsliste.Repository.ShoppingItemRepository;
|
||||
@@ -12,10 +14,8 @@ import de.timaldinger.einkaufsliste.Repository.ShoppingListRepository;
|
||||
import de.timaldinger.einkaufsliste.Service.ShoppingListService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
|
||||
|
||||
import java.net.URI;
|
||||
@@ -34,6 +34,21 @@ public class ShoppingListController {
|
||||
@Autowired
|
||||
private ShoppingListService shoppingListService;
|
||||
|
||||
@Autowired
|
||||
private ShoppingItemMapper shoppingItemMapper;
|
||||
@Autowired
|
||||
private ShoppingCategoryMapper shoppingCategoryMapper;
|
||||
|
||||
@GetMapping("/api/lists")
|
||||
public ResponseEntity<List<ShoppingListsGetDTO>> getLists(){
|
||||
return ResponseEntity.ok().body(shoppingListService.getLists());
|
||||
}
|
||||
|
||||
@GetMapping("/api/lists/{listID}")
|
||||
public ResponseEntity<ShoppingListGetDTO> getList(@PathVariable UUID listID){
|
||||
return ResponseEntity.ok().body(shoppingListService.getList(listID));
|
||||
}
|
||||
|
||||
@PostMapping("/api/lists")
|
||||
public ResponseEntity<ShoppingListResponseDTO> addList(@Valid @RequestBody ShoppingListPostDTO newList){
|
||||
ShoppingList list = new ShoppingList(newList.listName(), null, null, 0, 0);
|
||||
|
||||
Reference in new issue
Block a user