main #8

Closed
student-18211 wants to merge 22 commits from student-18211/NTO-2025-Backend-TeamTask:main into main
5 changed files with 14 additions and 6 deletions
Showing only changes of commit 46068ca46d - Show all commits

View File

@@ -65,6 +65,11 @@ public class BookingController {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Unexpected error"); 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; package com.example.nto.excepation;
public class EmployeeNotFoundException extends RuntimeException{ public class EmployeeNotFoundException extends RuntimeException{
public EmployeeNotFoundException(String msg) { public EmployeeNotFoundException(String message) {super(message);}
super(msg);
}
} }

View File

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

View File

@@ -7,4 +7,5 @@ import java.util.Map;
public interface BookingService { public interface BookingService {
Map<String, Object> findAvailableBookings(String employeeCode); Map<String, Object> findAvailableBookings(String employeeCode);
String createBooking(String code, Long placeId, String date); 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()); result.put("employeeId", employee.getId());
return "the booking was created successfully"; 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);
}
} }