- Timestamp:
- 03/03/24 20:56:13 (15 months ago)
- Branches:
- main
- Children:
- a3d63eb
- Parents:
- 3ba01da
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/rezevirajmasa/demo/web/rest/testController.java
r3ba01da r748b7f6 16 16 import java.time.LocalDateTime; 17 17 import java.time.format.DateTimeFormatter; 18 import java.util.ArrayList; 18 19 import java.util.List; 19 20 import java.util.Map; … … 92 93 93 94 @RequestMapping("/api/customers") 94 public ResponseEntity<List<Customer>> getAllCustomers() { 95 return new ResponseEntity<List<Customer>>(customerService.listAll(), HttpStatus.OK); 95 public ResponseEntity<List<CustomerDTO>> getAllCustomers() { 96 List<Customer> customers = customerService.listAll(); 97 List<CustomerDTO> dtos = new ArrayList<>(); 98 for(Customer customer : customers) { 99 CustomerDTO dto = customerService.mapCustomerToDTO(customer); 100 dtos.add(dto); 101 } 102 return new ResponseEntity<List<CustomerDTO>>(dtos, HttpStatus.OK); 96 103 } 97 104 … … 100 107 return new ResponseEntity<Customer>(customerService.findById(id), HttpStatus.OK); 101 108 } 102 103 // @RequestMapping("/api/customers/{id}")104 // public ResponseEntity<CustomerDTO> getCustomerById(@PathVariable Long id) {105 // Customer customer = customerService.findById(id);106 // CustomerDTO customerDTO = new CustomerDTO();107 // customerDTO.setCustomerId(customerDTO.getCustomerId());108 // customerDTO.setAddress(customerDTO.getAddress());109 // customerDTO.setEmail(customerDTO.getEmail());110 // customerDTO.setPhone(customerDTO.getPhone());111 // customerDTO.setRole(customerDTO.getRole());112 // customerDTO.setFirstName(customerDTO.getFirstName());113 // customerDTO.setLastName(customerDTO.getLastName());114 // customerDTO.setMembershipLevel(customerDTO.getMembershipLevel());115 // customerDTO.setRegistrationDate(customerDTO.getRegistrationDate());116 //117 // return ResponseEntity.ok(customerDTO);118 // }119 120 109 @PutMapping("/api/customers/edit/{id}") 121 110 public ResponseEntity<Customer> editCustomerById(@PathVariable Long id, @RequestBody Customer customer) {
Note:
See TracChangeset
for help on using the changeset viewer.