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

[OVERALL FIXING] Fixed some issues related to Payment and Rental #33

Merged
merged 18 commits into from
Oct 5, 2023

Conversation

ivan0dyatlyukkk
Copy link
Contributor

No description provided.

@ivan0dyatlyukkk ivan0dyatlyukkk changed the title [OVERALL FIXING] Fixed some logical issues [OVERALL FIXING] Fixed some issues related to Payment and Rental Oct 5, 2023
Copy link
Contributor

@DmytroV95 DmytroV95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GJ! Left some comments.

@@ -76,6 +77,13 @@ public User getByEmail(String email) {
);
}

@Override
public User getByAuthentication(Authentication auth) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public User getByAuthentication(Authentication auth) {
public User getAuthenticatedUser(Authentication auth) {

Comment on lines 39 to 47
Payment.Type type = Payment.Type.valueOf(requestDto.getType());

checkIfPaymentSessionValid(rental);

if (paymentRepository.existsByRentalIdAndStatus(rental.getId(), Payment.Status.PAUSED)) {
return paymentMapper.toDto(paymentRepository.findByRentalId(rental.getId()).get());
}

try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant lines

@@ -63,6 +64,8 @@ public PaymentResponseDto updateStatus(String sessionId, Payment.Status status)

@Override
public List<PaymentResponseDto> getAll(Authentication authentication, Pageable pageable) {
User user = userService.getByAuthentication(authentication);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant line

if (paymentRepository.existsByRentalIdAndStatus(rental.getId(), Payment.Status.PAID)) {
throw new NotValidPaymentProcessException("The rental is paid!");
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant line

@@ -53,6 +53,14 @@ public List<RentalDto> getByUserIdAndActiveStatus(Pageable pageable,
.toList();
}

@Override
public Rental getByUserAndId(User user, Long id) {
Copy link
Contributor

@DmytroV95 DmytroV95 Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you specify in method name by what entity id you want to get?

@ivan0dyatlyukkk ivan0dyatlyukkk merged commit a2bf40a into main Oct 5, 2023
2 checks passed
@ivan0dyatlyukkk ivan0dyatlyukkk deleted the feat-fixing-issues branch October 5, 2023 15:28
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

Successfully merging this pull request may close these issues.

5 participants