Update Postman collection

This commit is contained in:
2026-04-06 13:26:55 -06:00
parent 18407f8328
commit 6f8c0674c2
13 changed files with 135 additions and 79 deletions

View File

@@ -2069,6 +2069,37 @@
{
"name": "Appointments",
"item": [
{
"name": "Get Appointment Customers Dropdown",
"request": {
"method": "GET",
"url": "{{baseUrl}}/api/v1/dropdowns/appointment-customers",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{staffToken}}",
"type": "text"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
},
{
"name": "Check Appointment Availability",
"request": {
@@ -2180,7 +2211,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"customerId\": 1,\n \"storeId\": 1,\n \"serviceId\": 1,\n \"appointmentDate\": \"2026-12-20\",\n \"appointmentTime\": \"10:00:00\",\n \"appointmentStatus\": \"Booked\",\n \"petIds\": [1]\n}",
"raw": "{\n \"customerId\": 1,\n \"storeId\": 1,\n \"serviceId\": 1,\n \"appointmentDate\": \"2026-12-20\",\n \"appointmentTime\": \"10:00:00\",\n \"appointmentStatus\": \"Booked\",\n \"petIds\": [\n 1\n ],\n \"employeeId\": 1\n}",
"options": {
"raw": {
"language": "json"
@@ -2222,7 +2253,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"customerId\": 1,\n \"storeId\": 1,\n \"serviceId\": 1,\n \"appointmentDate\": \"2026-12-20\",\n \"appointmentTime\": \"11:00:00\",\n \"appointmentStatus\": \"Booked\",\n \"petIds\": [1]\n}",
"raw": "{\n \"customerId\": 1,\n \"storeId\": 1,\n \"serviceId\": 1,\n \"appointmentDate\": \"2026-12-20\",\n \"appointmentTime\": \"11:00:00\",\n \"appointmentStatus\": \"Booked\",\n \"petIds\": [\n 1\n ],\n \"employeeId\": 1\n}",
"options": {
"raw": {
"language": "json"
@@ -2315,6 +2346,37 @@
{
"name": "Adoptions",
"item": [
{
"name": "Get Adoption Pets Dropdown",
"request": {
"method": "GET",
"url": "{{baseUrl}}/api/v1/dropdowns/adoption-pets",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{staffToken}}",
"type": "text"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
},
{
"name": "List Adoptions",
"request": {
@@ -2395,7 +2457,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"petId\": 3,\n \"customerId\": 1,\n \"adoptionDate\": \"2026-12-21\",\n \"adoptionStatus\": \"Pending\"\n}",
"raw": "{\n \"petId\": 3,\n \"customerId\": 1,\n \"adoptionDate\": \"2026-12-21\",\n \"adoptionStatus\": \"Pending\",\n \"employeeId\": 1\n}",
"options": {
"raw": {
"language": "json"
@@ -2437,7 +2499,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"petId\": 3,\n \"customerId\": 1,\n \"adoptionDate\": \"2026-12-22\",\n \"adoptionStatus\": \"Completed\"\n}",
"raw": "{\n \"petId\": 3,\n \"customerId\": 1,\n \"adoptionDate\": \"2026-12-22\",\n \"adoptionStatus\": \"Completed\",\n \"employeeId\": 1\n}",
"options": {
"raw": {
"language": "json"
@@ -3719,6 +3781,68 @@
}
]
},
{
"name": "Get Store Employees Dropdown",
"request": {
"method": "GET",
"url": "{{baseUrl}}/api/v1/dropdowns/stores/{{storeId}}/employees",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{staffToken}}",
"type": "text"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
},
{
"name": "Get All Employees Dropdown",
"request": {
"method": "GET",
"url": "{{baseUrl}}/api/v1/dropdowns/employees",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{staffToken}}",
"type": "text"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
},
{
"name": "List Stores",
"request": {

View File

@@ -218,7 +218,6 @@ public class AppointmentService {
List<Long> employeeIds = assignableEmployees.stream().map(Employee::getEmployeeId).collect(Collectors.toList());
List<Appointment> allAppointments = appointmentRepository.findByEmployeeEmployeeIdInAndAppointmentDate(employeeIds, date);
// Group by employee for faster lookup in the loop
java.util.Map<Long, List<Appointment>> appointmentsByEmployee = allAppointments.stream()
.collect(Collectors.groupingBy(a -> a.getEmployee().getEmployeeId()));
@@ -350,7 +349,6 @@ public class AppointmentService {
.isPresent();
}
//------------------------------------
private void validateAvailability(Employee employee, com.petshop.backend.entity.Service service, LocalDate date, LocalTime time, Long appointmentIdToIgnore) {
List<Appointment> existingAppointments = appointmentRepository
.findByEmployeeEmployeeIdAndAppointmentDate(employee.getEmployeeId(), date);
@@ -359,8 +357,6 @@ public class AppointmentService {
}
}
//------------------------------------------------
private boolean isSlotAvailable(List<Appointment> existingAppointments, com.petshop.backend.entity.Service requestedService, LocalTime requestedStart, Long appointmentIdToIgnore) {
LocalTime requestedEnd = requestedStart.plusMinutes(requestedService.getServiceDuration());
for (Appointment existingAppointment : existingAppointments) {

View File

@@ -1,4 +1,3 @@
-- Activate all employees in the users table so they appear in dropdowns
UPDATE users u
SET u.active = TRUE
WHERE u.role IN ('STAFF', 'ADMIN')

View File

@@ -1,7 +1,3 @@
-- V17: Normalize legacy appointmentPet data into customer_pet and appointment_customer_pet
-- Step 1: Ensure a customer_pet exists for every pet linked in appointmentPet
-- Note: pet species and breed might be null in pet table, but we copy them over if present
INSERT INTO customer_pet (customer_id, pet_name, species, breed)
SELECT DISTINCT a.customerId, p.petName, p.petSpecies, p.petBreed
FROM appointmentPet ap
@@ -12,7 +8,6 @@ WHERE NOT EXISTS (
WHERE cp.customer_id = a.customerId AND cp.pet_name = p.petName
);
-- Step 2: Link the appointment to the customer_pet
INSERT INTO appointment_customer_pet (appointment_id, customer_pet_id)
SELECT ap.appointmentId, cp.customer_pet_id
FROM appointmentPet ap
@@ -24,5 +19,4 @@ WHERE NOT EXISTS (
WHERE acp.appointment_id = ap.appointmentId AND acp.customer_pet_id = cp.customer_pet_id
);
-- Step 3: Remove the old legacy relationships so it strictly uses the new ones
DELETE FROM appointmentPet;

View File

@@ -1,7 +1,3 @@
-- V18: Normalize past appointments and resolve initial employee double-bookings
-- Part 1: Normalize past appointments.
-- Any appointment that is still 'Booked' but the date/time has passed should be marked as 'Missed'.
UPDATE appointment
SET appointmentStatus = 'Missed'
WHERE LOWER(appointmentStatus) = 'booked'
@@ -10,8 +6,6 @@ WHERE LOWER(appointmentStatus) = 'booked'
OR (appointmentDate = CURRENT_DATE AND appointmentTime < CURRENT_TIME)
);
-- Part 2: Resolve potential double-bookings caused by V15's simple backfill.
-- MySQL Error 1093 workaround: wrap same-table subqueries in derived tables.
UPDATE appointment a1
JOIN (
SELECT a3.appointmentId

View File

@@ -90,7 +90,7 @@ class AdoptionServiceTest {
void createAdoptionAutoAssignsFirstStaffEmployee() {
when(petRepository.findById(1L)).thenReturn(Optional.of(pet));
when(customerRepository.findById(1L)).thenReturn(Optional.of(customer));
// resolveAdoptionEmployee filters for staff
when(employeeRepository.findAllByIsActiveTrueOrderByEmployeeIdAsc()).thenReturn(List.of(adminEmployee, staffEmployee));
when(adoptionRepository.save(any(Adoption.class))).thenAnswer(invocation -> {
Adoption adoption = invocation.getArgument(0);