IntentArchitect / Support

A repository dedicated to handling issues and support queries
3 stars 0 forks source link

Help with Paging #86

Open leonAtRain opened 6 months ago

leonAtRain commented 6 months ago

Ask a question

I've manually implemented this code on a controller, but I don't know how implement this on an Intent Module:

@GetMapping
    @Operation(summary = "findAll")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "Returns the specified List<CustomerBillDto>."),
            @ApiResponse(responseCode = "400", description = "One or more validation errors have occurred.")})
    @IntentIgnore
    public ResponseEntity<Page<CustomerBillDto>> findAll(@RequestParam(value = "fields", required = false) String[] fields,
                                                         @RequestParam Map<String, String> filtering, Pageable pageable) {
        if (pageable.isUnpaged()) {
            pageable = PageRequest.of(0, 500);
        }
        final Page<CustomerBillDto> result = customerBillService.findAll(fields, filtering, pageable);
        if (result.getTotalElements() == 0) {
            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
        }
        HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), result);

        return ResponseEntity.ok().headers(headers).body(result.getContent());
    }

This is how the Intent side looks like : image

The thing is - I want the Paging to be added on Intent side as well as the Generic return Page object and headers.

I also have a few Projects that need this so I would want to add it to my module and apply it to all the projects that have "findAll" endpoints exposed.

joelsteventurner commented 6 months ago

Hi @leonAtRain

We have a similar pattern in the .Net space. We'll reach out to you today over Teams to set up a session and unpack this requirement with you help you get this implemented.