making appointment userfrendly part1 andriod
This commit is contained in:
@@ -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}")
|
||||
|
||||
@@ -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 " +
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user