SHARE
TWEET

Untitled

a guest Aug 23rd, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.audelia.first.controlers;
  2.  
  3. import com.audelia.first.Domain.UserDTO;
  4. import com.audelia.first.Services.UserServices;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.*;
  7.  
  8. import java.util.List;
  9.  
  10. @RestController
  11. @RequestMapping("/user")
  12.  
  13. public class User {
  14.  
  15.     @Autowired
  16.     private UserServices userServices;
  17.  
  18.     @GetMapping("/all")
  19.     public List<UserDTO> allUsers(){
  20.        return userServices.findAllUsers();    }
  21.  
  22.  
  23.        @PostMapping("/add")
  24.     public String addUser(@RequestBody UserDTO userdata){
  25.         return userServices.saveUser(userdata);
  26.  
  27.        }
  28.  
  29.        @PutMapping("/update")
  30.     public String updateUser(@RequestBody UserDTO newUserData){
  31.         return userServices.updateUser(newUserData);
  32.        }
  33.    
  34.        @GetMapping("/find/{id}")
  35.    public UserDTO getUserById(@PathVariable Integer id){
  36.        return userServices.findById(id);
  37.       }
  38.  
  39.  
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top