Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@FitBuddyDate should work on method parameter too #171

Open
mepox opened this issue Dec 1, 2022 · 0 comments
Open

@FitBuddyDate should work on method parameter too #171

mepox opened this issue Dec 1, 2022 · 0 comments

Comments

@mepox
Copy link
Owner

mepox commented Dec 1, 2022

It would be great if we could use the @FitBuddyDate annotation on method parameters as well.

https://github.com/mepox/fitbuddy/blob/08167233b48d2d7b3c55dc5272b2ee0bc5cbe6d5/src/main/java/app/fitbuddy/annotation/FitBuddyDate.java

Then we could add it to the method parameter String strDate here and remove the try-catch:

@GetMapping("{date}")
public List<HistoryResponseDTO> readAll(@PathVariable("date") String strDate,
@AuthenticationPrincipal AppUserPrincipal appUserPrincipal) {
if (strDate != null) {
try {
LocalDate.parse(strDate);
} catch (DateTimeParseException e) {
throw new FitBuddyException(DATE_NOT_VALID);
}
Integer userId = appUserPrincipal.getId();
if (userId != null) {
List<HistoryResponseDTO> historyResponseDTOs = historyCrudService.readMany(userId, strDate);
logger.info("Sending a history for: {}", strDate);
return historyResponseDTOs;
}
}
return Collections.emptyList();
}

@mepox mepox changed the title @FitBuddyDate to work on method parameter @FitBuddyDate should work on method parameter too Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant