SHARE
TWEET

Untitled

a guest Jan 17th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.psk_project.car_rental.controllers;
  2.  
  3. import com.psk_project.car_rental.db.Customer;
  4. import com.psk_project.car_rental.services.CustomerService;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.http.HttpStatus;
  7. import org.springframework.web.bind.annotation.*;
  8.  
  9. import java.util.List;
  10. @RestController
  11. @RequestMapping("/customer")
  12. public class CustomerController {
  13.     @Autowired
  14.     private CustomerService customerService;
  15.     @RequestMapping(method = RequestMethod.GET, value = "/")
  16.     public List<Customer> getCustomers() {
  17.         return customerService.getCustomerList();
  18.     }
  19.     @RequestMapping(value="/", method= RequestMethod.PUT)
  20.     public String putCustomer(@RequestBody Customer input ) {
  21.         customerService.addCustomer(input);
  22.         return "OK";
  23.     }
  24.     @RequestMapping(value="/{ID}" ,method=RequestMethod.PATCH)
  25.     public String updateCustomers(@PathVariable(value="ID") int id, @RequestBody Customer input) {
  26.         input.setCustomerId(id);
  27.         customerService.updateCustomer(input);
  28.         return "OK";
  29.     }
  30.     @RequestMapping(value="/{ID}",method=RequestMethod.DELETE)
  31.     public String deleteCustomers(@PathVariable(value="ID") int id) {
  32.         customerService.deleteCustomer(id);
  33.         return "OK";
  34.     }
  35.     @RequestMapping(value="/{ID}",method=RequestMethod.GET)
  36.     public Customer getSingleCustomer(@PathVariable(value="ID") int id) {
  37.         return customerService.getCustomer(id);
  38.     }
  39. }
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