added adoption search and filter andriod and backend

This commit is contained in:
Alex
2026-04-07 18:06:07 -06:00
parent 538b4440d8
commit 155c64a729
10 changed files with 244 additions and 75 deletions

View File

@@ -35,6 +35,7 @@ public class AdoptionController {
@RequestParam(required = false) String q,
@RequestParam(required = false) Long customerId,
@RequestParam(required = false) String status,
@RequestParam(required = false) Long storeId,
Pageable pageable) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String role = authentication.getAuthorities().stream()
@@ -48,7 +49,7 @@ public class AdoptionController {
effectiveCustomerId = user.getId();
}
return ResponseEntity.ok(adoptionService.getAllAdoptions(q, effectiveCustomerId, status, pageable));
return ResponseEntity.ok(adoptionService.getAllAdoptions(q, effectiveCustomerId, status, storeId, pageable));
}
@GetMapping("/{id}")

View File

@@ -20,11 +20,13 @@ public interface AdoptionRepository extends JpaRepository<Adoption, Long> {
"LOWER(a.pet.petName) LIKE LOWER(CONCAT('%', :q, '%'))" +
")) AND " +
"(:customerId IS NULL OR a.customer.id = :customerId) AND " +
"(:status IS NULL OR LOWER(a.adoptionStatus) = LOWER(:status))")
"(:status IS NULL OR LOWER(a.adoptionStatus) = LOWER(:status)) AND " +
"(:storeId IS NULL OR a.sourceStore.storeId = :storeId)")
Page<Adoption> searchAdoptions(
@Param("q") String query,
@Param("customerId") Long customerId,
@Param("status") String status,
@Param("storeId") Long storeId,
Pageable pageable);
Optional<Adoption> findFirstByPet_IdAndAdoptionStatusOrderByAdoptionDateDesc(Long petId, String adoptionStatus);

View File

@@ -38,7 +38,7 @@ public class AdoptionService {
this.storeRepository = storeRepository;
}
public Page<AdoptionResponse> getAllAdoptions(String query, Long customerId, String status, Pageable pageable) {
public Page<AdoptionResponse> getAllAdoptions(String query, Long customerId, String status, Long storeId, Pageable pageable) {
String normalizedQuery = normalizeFilter(query);
String normalizedStatus = normalizeFilter(status);
@@ -46,6 +46,7 @@ public class AdoptionService {
normalizedQuery,
customerId,
normalizedStatus,
storeId,
pageable
);