specification-arg-resolver icon indicating copy to clipboard operation
specification-arg-resolver copied to clipboard

Process JSON

Open rcbandit111 opened this issue 5 years ago • 0 comments

I want to implement search functionality with several sub conditions. I tried this:

    @GetMapping("find")
    public Page<PaymentTransactionsDTO> getAllBySpecification(
            @And({
                    @Spec(path = "name", spec = LikeIgnoreCase.class),
                    @Spec(path = "unique_id", spec = LikeIgnoreCase.class),
                    @Spec(path = "createdAt", params = "from", spec = GreaterThanOrEqual.class),
                    @Spec(path = "createdAt", params = "to", spec = LessThanOrEqual.class)
            }) Specification<PaymentTransactions> specification,
            Pageable pageable
    ) {        
        return transactionService.getAllBySpecification(specification, pageable));       
    }

Repository:

      @Override
	  public Page<PaymentTransactions> getAllBySpecification(final Specification<PaymentTransactions> specification, final Pageable pageable) {
	      return dao.findAll(specification, pageable);
	  }

Currently this request is working:

GET /api/transactions/find?unique_id=22&page=0&size=10 

But also I want to implement these additional search conditions not only sending basic search for unique_id:

start with 
=
end with 
contains

One solution will be to send from Angular this JSON object:

selectedFilters?:[  
   {  
      filter:{  
         filterValue:string,
         filterName:string
      },
      filterOption:string,
      selectedFilterValue:string
   }
]

Is these some way to send this JSON object and process the values?

rcbandit111 avatar May 01 '19 07:05 rcbandit111