Skip to content

Commit

Permalink
chore: addressing sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Nov 5, 2024
1 parent c062fdd commit 4a1bbae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ResponseEntity<List<MyRecentActionsRequestsDto>> getUserTrackedOpenings()
* @return HTTP status code 201 if success, no response body.
*/
@PostMapping("/{id}")
public ResponseEntity<Void> saveUserOpening(Long id) {
public ResponseEntity<Void> saveUserOpening(@PathVariable Long id) {
userOpeningService.addUserFavoriteOpening(id);
return ResponseEntity.status(HttpStatus.CREATED).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,13 @@ public List<Long> listUserFavoriteOpenings() {

@Transactional
public void addUserFavoriteOpening(Long openingId) {
log.info("Adding opening ID {} as favorite for user {}", openingId,
loggedUserService.getLoggedUserId());
openingRepository
.findById(openingId)
.orElseThrow(() -> {
log.info("Opening ID not found: {}", openingId);
return new OpeningNotFoundException();
});
log.info("Adding opening ID {} as favorite for user {}", openingId,
loggedUserService.getLoggedUserId());

if (openingRepository.findById(openingId).isEmpty()) {
log.info("Opening ID not found: {}", openingId);
throw new OpeningNotFoundException();
}

log.info("Opening ID {} added as favorite for user {}", openingId,
loggedUserService.getLoggedUserId());
Expand Down

0 comments on commit 4a1bbae

Please sign in to comment.