species service validation (#317)
* fix species-service validation * add grooming for hamster, other * expand reptile and other services
This commit is contained in:
@@ -127,8 +127,6 @@ public class AppointmentService {
|
||||
}
|
||||
}
|
||||
|
||||
validateSpeciesServiceCompatibility(pet, service);
|
||||
|
||||
validateStoreAccess(store.getStoreId(), authenticatedUser);
|
||||
validatePetServiceCompatibility(pet, service);
|
||||
validateAvailability(employee, service, request.getAppointmentDate(), request.getAppointmentTime(), null);
|
||||
@@ -387,32 +385,6 @@ public class AppointmentService {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void validateSpeciesServiceCompatibility(Pet pet, com.petshop.backend.entity.Service service) {
|
||||
if (pet == null || service == null) return;
|
||||
String species = pet.getPetSpecies();
|
||||
if (species == null) return;
|
||||
String serviceName = service.getServiceName().toLowerCase();
|
||||
|
||||
switch (species.toLowerCase()) {
|
||||
case "bird":
|
||||
if (!serviceName.contains("wing clipping") && !serviceName.contains("beak and nail")) {
|
||||
throw new IllegalArgumentException(
|
||||
"Service '" + service.getServiceName() + "' is not available for birds. " +
|
||||
"Allowed services: Wing Clipping, Beak and Nail Care.");
|
||||
}
|
||||
break;
|
||||
case "fish":
|
||||
if (!serviceName.contains("aquarium health")) {
|
||||
throw new IllegalArgumentException(
|
||||
"Service '" + service.getServiceName() + "' is not available for fish. " +
|
||||
"Allowed service: Aquarium Health Check.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void validateStoreAccess(Long requestedStoreId, User user) {
|
||||
if (user.getRole() != User.Role.STAFF) {
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
DELETE FROM service_species WHERE serviceId = 2 AND species = 'Bird';
|
||||
|
||||
INSERT INTO service_species (serviceId, species) VALUES
|
||||
(1, 'Guinea Pig'),
|
||||
(1, 'Hamster'),
|
||||
(1, 'Other'),
|
||||
(2, 'Reptile'),
|
||||
(2, 'Other'),
|
||||
(3, 'Reptile'),
|
||||
(3, 'Other'),
|
||||
(4, 'Reptile'),
|
||||
(4, 'Other'),
|
||||
(5, 'Reptile'),
|
||||
(5, 'Other');
|
||||
Reference in New Issue
Block a user