Ignore:
Timestamp:
05/06/25 00:44:02 (12 days ago)
Author:
Aleksandar Panovski <apano77@…>
Branches:
main
Children:
e48199a
Parents:
142c0f8
Message:

Normalization needed to continue, till here done

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/rezevirajmasa/demo/web/rest/testController.java

    r142c0f8 rb67dfd3  
    3232public class testController {
    3333    private final RestaurantService restaurantService;
    34     private final CustomerService customerService;
    3534    private final UserService userService;
    3635    private final ReservationService reservationService;
     
    4039    private final UserMapper userMapper;
    4140    private final TokenService tokenService;
    42     public testController(RestaurantService restaurantService, CustomerService customerService, UserService userService, ReservationService reservationService, ReservationHistoryService reservationHistoryService, TableService tableService, MenuService menuService, UserMapper userMapper, TokenService tokenService) {
     41    public testController(RestaurantService restaurantService, UserService userService, ReservationService reservationService, ReservationHistoryService reservationHistoryService, TableService tableService, MenuService menuService, UserMapper userMapper, TokenService tokenService) {
    4342        this.restaurantService = restaurantService;
    44         this.customerService = customerService;
    4543        this.userService = userService;
    4644        this.reservationService = reservationService;
     
    115113    }
    116114
    117 //    Customer CALLS
    118 
    119     @GetMapping("/api/customers")
    120     public ResponseEntity<List<CustomerDTO>> getAllCustomers() {
    121         List<Customer> customers = customerService.listAll();
    122         List<CustomerDTO> dtos = new ArrayList<>();
    123         for(Customer customer : customers) {
    124             CustomerDTO dto = customerService.mapCustomerToDTO(customer);
    125             dtos.add(dto);
    126         }
    127         return new ResponseEntity<List<CustomerDTO>>(dtos, HttpStatus.OK);
    128     }
    129 
    130     @GetMapping("/api/customers/{id}")
    131     public ResponseEntity<Customer> getCustomerById(@PathVariable Long id) {
    132         return new ResponseEntity<Customer>(customerService.findById(id), HttpStatus.OK);
    133     }
    134     @PutMapping("/api/customers/edit/{id}")
    135     public ResponseEntity<Customer> editCustomerById(@PathVariable Long id, @RequestBody Customer customer) {
    136         return new ResponseEntity<Customer>(
    137                 customerService.updateCustomer(id, customer.getFirstName(), customer.getLastName(), customer.getEmail(), customer.getPassword(), customer.getPhone(), customer.getAddress(), customer.getMembershipLevel()),
    138                 HttpStatus.OK
    139         );
    140     }
    141 
    142     @PostMapping("/api/customers")
    143     public ResponseEntity<Customer> saveCustomer(@RequestBody Customer customer) {
    144         // Ensure that the role is set to ROLE_USER by default
    145         customer.setRole(Role.ROLE_USER);
    146         return new ResponseEntity<Customer>(
    147                 customerService.registration(customer),
    148                 HttpStatus.OK
    149         );
    150     }
    151 
    152     @DeleteMapping("/api/customers/delete/{customerId}")
    153     public ResponseEntity<Response> deleteCustomer(@PathVariable Long customerId) {
    154         boolean deleted = customerService.deleteById(customerId);
    155         if(deleted) {
    156             return ResponseEntity.ok().build();
    157         } else {
    158             return ResponseEntity.notFound().build();
    159         }
    160     }
    161 
    162115//    Reservation Calls
    163116
Note: See TracChangeset for help on using the changeset viewer.