Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.myPortfolio.Controller;
- import java.util.List;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.HttpStatus;
- import org.springframework.http.ResponseEntity;
- import org.springframework.web.bind.annotation.CrossOrigin;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import com.example.myPortfolio.Entity.PortfolioEntity;
- import com.example.myPortfolio.Service.PortfolioService;
- @CrossOrigin(origins="https://localhost:8080")
- @RestController
- @RequestMapping("/aboutMe")
- public class PortfolioController {
- @Autowired
- private PortfolioService portfolioService;
- @GetMapping
- public ResponseEntity<List<PortfolioEntity>> getPersonalDetails(){
- List<PortfolioEntity> portfolio = portfolioService.getAllPersonalDetails();
- return ResponseEntity.ok(portfolio);
- }
- @PostMapping
- public ResponseEntity<PortfolioEntity> addPersonalDetails(@RequestBody PortfolioEntity portfolio){
- PortfolioEntity portFolioEntity = portfolioService.addPersonalDetails(portfolio);
- return new ResponseEntity<>(portFolioEntity,HttpStatus.CREATED);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement