Advertisement
andersonalmada2

Untitled

Jul 30th, 2022
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. package br.ufc.mandacaru5.controller;
  2.  
  3. import java.util.List;
  4.  
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.http.HttpStatus;
  7. import org.springframework.http.ResponseEntity;
  8. import org.springframework.web.bind.annotation.DeleteMapping;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PathVariable;
  11. import org.springframework.web.bind.annotation.PostMapping;
  12. import org.springframework.web.bind.annotation.PutMapping;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16.  
  17. import br.ufc.mandacaru5.model.Feedback;
  18. import br.ufc.mandacaru5.service.FeedbackService;
  19.  
  20. @RestController
  21. @RequestMapping(path = "/api")
  22. public class FeedbackController {
  23.  
  24.     @Autowired
  25.     FeedbackService service;
  26.  
  27.     @GetMapping("/products/{id}/feedbacks")
  28.     public ResponseEntity<List<Feedback>> findAll(@PathVariable(value = "id") int id) {
  29.         return new ResponseEntity<List<Feedback>>(service.findAll(id), HttpStatus.OK);
  30.     }
  31.  
  32.     @GetMapping("/feedbacks/{id}")
  33.     public ResponseEntity<Feedback> find(@PathVariable("id") int id) {
  34.         return new ResponseEntity<Feedback>(service.find(id), HttpStatus.OK);
  35.     }
  36.  
  37.     @PostMapping("/products/{id}/feedbacks")
  38.     public void save(@PathVariable("id") int product_id, @RequestBody Feedback feedback) {
  39.         service.save(product_id, feedback);
  40.     }
  41.  
  42.     @PutMapping("/feedbacks/{id}")
  43.     public void update(@PathVariable("id") int id, @RequestBody Feedback feedback) {
  44.         service.update(id, feedback);
  45.     }
  46.  
  47.     @DeleteMapping("/feedbacks/{id}")
  48.     public void delete(@PathVariable("id") int id) {
  49.         service.delete(id);
  50.     }
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement