Skip to content

Commit

Permalink
chore: updating legacy api
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Dec 9, 2024
1 parent 7a31863 commit d277516
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,12 @@ public Flux<ForestClientDto> findByIdAndLastName(
* Handles the HTTP GET request to retrieve client details by client number.
*
* @param clientNumber the client number to search for
* @param groups the list of user groups for authorization or filtering purposes
* @return a Mono containing the client details if found, or an empty Mono if not found
*/
@GetMapping("/clientNumber")
public Mono<ForestClientDetailsDto> findByClientNumber(
@RequestParam String clientNumber,
@RequestParam List<String> groups
) {
log.info("Receiving request to search by ID {} and groups {}",
clientNumber,
groups);
return service.findByClientNumber(clientNumber, groups);
@GetMapping("/clientNumber/{clientNumber}")
public Mono<ForestClientDetailsDto> findByClientNumber(@PathVariable String clientNumber) {
log.info("Receiving request to search by ID {}",clientNumber);
return service.findByClientNumber(clientNumber);
}

@GetMapping("/id/{idType}/{identification}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,21 +541,17 @@ public Flux<ForestClientDto> findByClientName(String clientName) {
);
}

public Mono<ForestClientDetailsDto> findByClientNumber(String clientNumber, List<String> groups) {
public Mono<ForestClientDetailsDto> findByClientNumber(String clientNumber) {
log.info("Searching for client with number {}", clientNumber);

if (StringUtils.isBlank(clientNumber)) {
return Mono.error(new MissingRequiredParameterException("clientNumber"));
}

if (CollectionUtils.isEmpty(groups)) {
return Mono.error(new MissingRequiredParameterException("groups"));
}

return forestClientRepository.findDetailsByClientNumber(clientNumber)
.switchIfEmpty(
Mono.error(
new NoValueFoundException("Client not found with number: " + clientNumber)
new NoValueFoundException("client with number: " + clientNumber)
)
)
.doOnNext(
Expand Down

0 comments on commit d277516

Please sign in to comment.