delet
Some checks failed
Android Test / validate-and-test (pull_request) Has been cancelled

This commit is contained in:
Bhumi Shah
2025-12-07 12:19:53 +03:00
parent 65d3dd56cd
commit 46068ca46d
5 changed files with 14 additions and 6 deletions

View File

@@ -65,6 +65,11 @@ public class BookingController {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Unexpected error");
}
}
@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteBooking(@PathVariable Long id) {
bookingService.deleteBooking(id);
return ResponseEntity.noContent().build();
}
}

View File

@@ -1,7 +1,5 @@
package com.example.nto.excepation;
public class EmployeeNotFoundException extends RuntimeException{
public EmployeeNotFoundException(String msg) {
super(msg);
}
public EmployeeNotFoundException(String message) {super(message);}
}

View File

@@ -13,6 +13,4 @@ import java.util.Optional;
* НЕЛЬЗЯ: Изменять название класса и пакета
*/
@Repository
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
Optional<Employee> findByCode(String code);
}
public interface EmployeeRepository extends JpaRepository<Employee, Long> {Optional<Employee> findByCode(String code);}

View File

@@ -7,4 +7,5 @@ import java.util.Map;
public interface BookingService {
Map<String, Object> findAvailableBookings(String employeeCode);
String createBooking(String code, Long placeId, String date);
void deleteBooking(long id);
}

View File

@@ -87,6 +87,12 @@ public class BookingServiceImpl implements BookingService {
result.put("employeeId", employee.getId());
return "the booking was created successfully";
}
public void deleteBooking(long id) {
if (!bookingRepository.existsById(id)) {
throw new IllegalArgumentException("Booking not found with id: " + id);
}
bookingRepository.deleteById(id);
}
}