making appointment userfrendly part1 andriod

This commit is contained in:
Alex
2026-04-08 16:53:42 -06:00
parent be9f07236a
commit 8d5d6f3872
17 changed files with 151 additions and 70 deletions

View File

@@ -28,8 +28,9 @@ public class PetController {
@RequestParam(required = false) String species,
@RequestParam(required = false) String status,
@RequestParam(required = false) Long storeId,
@RequestParam(required = false) Long customerId,
Pageable pageable) {
return ResponseEntity.ok(petService.getAllPets(q, species, status, storeId, pageable));
return ResponseEntity.ok(petService.getAllPets(q, species, status, storeId, customerId, pageable));
}
@GetMapping("/{id}")

View File

@@ -30,8 +30,9 @@ public interface PetRepository extends JpaRepository<Pet, Long> {
"(:q IS NULL OR LOWER(p.petName) LIKE LOWER(CONCAT('%', :q, '%')) OR LOWER(p.petSpecies) LIKE LOWER(CONCAT('%', :q, '%')) OR LOWER(COALESCE(p.petBreed, '')) LIKE LOWER(CONCAT('%', :q, '%'))) AND " +
"(:species IS NULL OR LOWER(p.petSpecies) = LOWER(:species)) AND " +
"(:status IS NULL OR LOWER(p.petStatus) = LOWER(:status)) AND " +
"(:storeId IS NULL OR p.store.storeId = :storeId)")
Page<Pet> searchPets(@Param("q") String query, @Param("species") String species, @Param("status") String status, @Param("storeId") Long storeId, Pageable pageable);
"(:storeId IS NULL OR p.store.storeId = :storeId) AND " +
"(:customerId IS NULL OR p.owner.id = :customerId)")
Page<Pet> searchPets(@Param("q") String query, @Param("species") String species, @Param("status") String status, @Param("storeId") Long storeId, @Param("customerId") Long customerId, Pageable pageable);
@Query("SELECT p FROM Pet p WHERE LOWER(p.petStatus) = 'available' AND " +
"(:q IS NULL OR LOWER(p.petName) LIKE LOWER(CONCAT('%', :q, '%')) OR LOWER(p.petSpecies) LIKE LOWER(CONCAT('%', :q, '%')) OR LOWER(COALESCE(p.petBreed, '')) LIKE LOWER(CONCAT('%', :q, '%'))) AND " +

View File

@@ -48,7 +48,7 @@ public class PetService {
}
@Transactional(readOnly = true)
public Page<PetResponse> getAllPets(String query, String species, String status, Long storeId, Pageable pageable) {
public Page<PetResponse> getAllPets(String query, String species, String status, Long storeId, Long customerId, Pageable pageable) {
String normalizedQuery = normalizeFilter(query);
String normalizedSpecies = normalizeFilter(species);
String normalizedStatus = normalizeFilter(status);
@@ -61,7 +61,7 @@ public class PetService {
}
pets = petRepository.searchPublicPets(normalizedQuery, normalizedSpecies, storeId, pageable);
} else if (viewer.role() == User.Role.STAFF || viewer.role() == User.Role.ADMIN) {
pets = petRepository.searchPets(normalizedQuery, normalizedSpecies, normalizedStatus, storeId, pageable);
pets = petRepository.searchPets(normalizedQuery, normalizedSpecies, normalizedStatus, storeId, customerId, pageable);
} else if (viewer.role() == User.Role.CUSTOMER) {
if (!isAllowedCustomerStatus(normalizedStatus)) {
return new PageImpl<>(java.util.List.of(), pageable, 0);