main #8

Closed
student-18211 wants to merge 22 commits from student-18211/NTO-2025-Backend-TeamTask:main into main
4 changed files with 0 additions and 19 deletions
Showing only changes of commit 9f437b83e2 - Show all commits

View File

@@ -58,7 +58,6 @@ public class BookingController {
@RequestParam String date
) {
try {
// Проверка обязательных параметров
if (placeId == null || date == null || date.isEmpty()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body("Place ID and date must be provided");
@@ -68,15 +67,11 @@ public class BookingController {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
.body("Employee not found");
}
// Получаем место
Place place = placeRepository.findById(placeId).orElse(null);
if (place == null) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body("Place not found");
}
// Парсим дату
LocalDate bookingDate;
try {
bookingDate = LocalDate.parse(date);
@@ -84,8 +79,6 @@ public class BookingController {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body("Invalid date format. Use yyyy-MM-dd");
}
// Проверяем, свободно ли место на эту дату
boolean exists = bookingRepository.findByDateBetween(bookingDate, bookingDate)
.stream()
.anyMatch(b -> b.getPlace().getId() == placeId);
@@ -98,16 +91,12 @@ public class BookingController {
booking.setPlace(place);
booking.setDate(bookingDate);
bookingRepository.save(booking);
// Формируем ответ
Map<String, Object> response = new LinkedHashMap<>();
response.put("id", booking.getId());
response.put("date", booking.getDate());
response.put("placeId", place.getId());
response.put("employeeId", employee.getId());
return ResponseEntity.status(HttpStatus.CREATED).body(response);
} catch (java.lang.IllegalArgumentException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
} catch (Exception e) {

View File

@@ -24,7 +24,6 @@ import java.util.Map;
@RestController
@RequestMapping("/api")
public class EmployeeController {
@Autowired
private EmployeeService employeeService;
@GetMapping("/{code}/auth")
@@ -43,7 +42,6 @@ public class EmployeeController {
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
}
}
@GetMapping("/{code}/info")
public ResponseEntity<?> getEmployeeInfo(@PathVariable String code) {
try {

View File

@@ -2,13 +2,11 @@ package com.example.nto.repository;
import com.example.nto.entity.Booking;
import com.example.nto.entity.Employee;
import com.example.nto.entity.Place;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
/**
* TODO: ДОРАБОТАТЬ в рамках задания

View File

@@ -1,11 +1,7 @@
package com.example.nto.service;
import com.example.nto.entity.Booking;
import com.example.nto.entity.Employee;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* TODO: ДОРАБОТАТЬ в рамках задания
* =================================