added adoption search and filter andriod and backend
This commit is contained in:
@@ -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}")
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user