Skip to content

Commit

Permalink
#27 adicionando controller de atualizaçao de item
Browse files Browse the repository at this point in the history
  • Loading branch information
joanasoaresd committed Nov 11, 2021
1 parent ae6a803 commit 1023c13
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/br/ufpb/edoe/controller/ItemController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import br.ufpb.edoe.dto.ItemDTO;
import br.ufpb.edoe.dto.UpdateItemRequestDTO;
import br.ufpb.edoe.entity.Item;
import br.ufpb.edoe.service.ItemService;

Expand All @@ -23,7 +25,7 @@ public class ItemController {
@Autowired
private ItemService service;

@GetMapping("/items/{id}")
@GetMapping("/items/descriptors/{id}")
public ResponseEntity<List<ItemDTO>> getItemsByDescriptorId(@PathVariable int id) {
return new ResponseEntity<>(service.getItemsByDescriptorId(id), HttpStatus.OK);
}
Expand All @@ -37,4 +39,9 @@ public ResponseEntity<ItemDTO> addItem(@RequestBody Item item, @RequestHeader("A
public ResponseEntity<ItemDTO> removeItem(@PathVariable Integer id, @RequestHeader("Authorization") String token) {
return new ResponseEntity<>(service.removeItem(id, token), HttpStatus.OK);
}

@PatchMapping("/items/{id}")
public ResponseEntity<ItemDTO> updateItem(@PathVariable Integer id, @RequestBody UpdateItemRequestDTO dto, @RequestHeader("Authorization") String token) {
return new ResponseEntity<>(service.updateItem(id, dto, token), HttpStatus.OK);
}
}

0 comments on commit 1023c13

Please sign in to comment.