Saskia Tihana Clements is the Founder of The Boldest and Co-Founder of VersaWare Technologies, both positions they have held since 2021.
package com.example.demo.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.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.demo.model.User;
import com.example.demo.service.UserService;
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping("/api")
public class UserController {
@Autowired
private UserService userService;
@GetMapping("/users")
public ResponseEntity<List<User>> getAllUsers(){
List<User> list = userService.getAllUsers();
return new ResponseEntity<List<User>>(list, HttpStatus.OK);
}
@GetMapping("/users/{id}")
public ResponseEntity<User> getUserById(@PathVariable("id") Long id){
User user = userService.getUserById(id);
return new ResponseEntity<User>(user, HttpStatus.OK);
}
@PostMapping("/users")
public ResponseEntity<User> saveUser(@RequestBody User user){
userService.saveUser(user);
return new ResponseEntity<User>(user, HttpStatus.OK);
}
Links
Sign up to view 0 direct reports
Get started