Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. package com.example.myPortfolio.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.CrossOrigin;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.RequestBody;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RestController;
  14.  
  15. import com.example.myPortfolio.Entity.PortfolioEntity;
  16. import com.example.myPortfolio.Service.PortfolioService;
  17.  
  18. @CrossOrigin(origins="https://localhost:8080")
  19. @RestController
  20. @RequestMapping("/aboutMe")
  21. public class PortfolioController {
  22.  
  23. @Autowired
  24. private PortfolioService portfolioService;
  25.  
  26. @GetMapping
  27. public ResponseEntity<List<PortfolioEntity>> getPersonalDetails(){
  28.  
  29. List<PortfolioEntity> portfolio = portfolioService.getAllPersonalDetails();
  30.  
  31. return ResponseEntity.ok(portfolio);
  32.  
  33. }
  34. @PostMapping
  35. public ResponseEntity<PortfolioEntity> addPersonalDetails(@RequestBody PortfolioEntity portfolio){
  36.  
  37. PortfolioEntity portFolioEntity = portfolioService.addPersonalDetails(portfolio);
  38. return new ResponseEntity<>(portFolioEntity,HttpStatus.CREATED);
  39.  
  40. }
  41.  
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement