task_98580_98578_98576_register_and_comment#7
Open
ngocvt-0484 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds several end-user features to the Tour Booking client flow: user registration + Google OAuth2 login, booking cancellation and mock payment, and tour review/rating with rating summaries shown on tour detail pages.
Changes:
- Added registration page/endpoint and Google OAuth2 login wiring (UI + Spring Security config + user schema changes).
- Added booking cancellation, mock payment flow, and payment persistence.
- Added tour review creation/display and rating aggregation (DB + entities + services + UI).
Reviewed changes
Copilot reviewed 38 out of 38 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/resources/templates/client/tours/show.html | Shows rating summary + review form/list; adds auth-gated booking/review actions |
| src/main/resources/templates/client/register.html | New registration UI |
| src/main/resources/templates/client/payment/mock.html | New mock payment UI |
| src/main/resources/templates/client/login.html | Adds registration success banner + Google OAuth link |
| src/main/resources/templates/client/booking/index.html | Adds cancel/pay actions with CSRF + flash messages |
| src/main/resources/static/js/user-register.js | Password visibility toggle script |
| src/main/resources/db/migration/V202606291424__create_payments.sql | Creates payments table |
| src/main/resources/db/migration/V202606291317__create_tour_reviews.sql | Creates tour_reviews table |
| src/main/resources/db/migration/V202606291151__alter_users.sql | Allows nullable password_digest; adds login_provider |
| src/main/resources/application.yml | Adds Google OAuth2 client configuration |
| src/main/java/com/bookingtour/sun/services/UserService.java | Adds register() |
| src/main/java/com/bookingtour/sun/services/TourService.java | Adds rating summary hydration in tour DTO |
| src/main/java/com/bookingtour/sun/services/TourReviewService.java | Adds review creation + listing |
| src/main/java/com/bookingtour/sun/services/PaymentService.java | Adds payment creation + success handling |
| src/main/java/com/bookingtour/sun/services/CurrentUserService.java | Adds unified current-user email lookup (local + OAuth2) |
| src/main/java/com/bookingtour/sun/services/BookingService.java | Adds cancel booking logic |
| src/main/java/com/bookingtour/sun/repository/TourReviewRepository.java | Adds review queries + rating aggregation |
| src/main/java/com/bookingtour/sun/repository/PaymentRepository.java | Adds payment lookup by booking |
| src/main/java/com/bookingtour/sun/exception/UnauthorizedException.java | New exception |
| src/main/java/com/bookingtour/sun/exception/DuplicateResourceException.java | New exception |
| src/main/java/com/bookingtour/sun/enums/PaymentStatus.java | New enum |
| src/main/java/com/bookingtour/sun/enums/LoginProvider.java | New enum |
| src/main/java/com/bookingtour/sun/entity/User.java | Adds loginProvider; allows nullable passwordDigest |
| src/main/java/com/bookingtour/sun/entity/TourReview.java | New entity |
| src/main/java/com/bookingtour/sun/entity/Payment.java | New entity |
| src/main/java/com/bookingtour/sun/entity/Booking.java | Links booking ↔ payment |
| src/main/java/com/bookingtour/sun/dto/response/ReviewResponse.java | New DTO |
| src/main/java/com/bookingtour/sun/dto/request/ReviewRequest.java | New DTO |
| src/main/java/com/bookingtour/sun/dto/request/RegisterRequest.java | New DTO |
| src/main/java/com/bookingtour/sun/dto/request/RatingSummary.java | New DTO |
| src/main/java/com/bookingtour/sun/dto/request/EditTourRequest.java | Adds averageRating + reviewCount |
| src/main/java/com/bookingtour/sun/controller/TourController.java | Adds review endpoint + loads reviews |
| src/main/java/com/bookingtour/sun/controller/PaymentController.java | Adds mock payment endpoints |
| src/main/java/com/bookingtour/sun/controller/ClientController.java | Adds register endpoints |
| src/main/java/com/bookingtour/sun/controller/BookingController.java | Adds cancel endpoint; uses CurrentUserService |
| src/main/java/com/bookingtour/sun/config/SecurityConfig.java | Permits public pages; adds oauth2Login |
| src/main/java/com/bookingtour/sun/config/OAuth2LoginSuccessHandler.java | Creates user on first Google login |
| pom.xml | Adds spring-boot-starter-oauth2-client |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+14
to
+28
| List<TourReview> findByTourIdOrderByCreatedAtDesc(Long tourId); | ||
|
|
||
| boolean existsByTourIdAndUserId( | ||
| Long tourId, | ||
| Long userId | ||
| ); | ||
|
|
||
| @Query(""" | ||
| SELECT | ||
| AVG(r.rating), | ||
| COUNT(r.id) | ||
| FROM TourReview r | ||
| WHERE r.tour.id = :tourId | ||
| """) | ||
| RatingSummary getRatingSummary(@Param("tourId") Long tourId); |
Comment on lines
+1
to
+11
| package com.bookingtour.sun.repository; | ||
|
|
||
| import com.bookingtour.sun.entity.Payment; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface PaymentRepository | ||
| extends JpaRepository<Payment,Long> { | ||
| Optional<Payment> findByBookingId(Long bookingId); | ||
| } |
Comment on lines
+13
to
+15
| <form th:action="@{/payments/{id}/success(id=${paymentId})}" | ||
| method="post"> | ||
|
|
Comment on lines
+4
to
+5
| layout:decorate="~{client/layouts/main}" | ||
| xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"> |
Comment on lines
+29
to
+31
| User user = userRepository.findByEmail(email) | ||
| .orElseThrow(() -> new ResourceNotFoundException("User not found with id: " + email)); | ||
|
|
Comment on lines
+168
to
+173
| <div class="social-login"> | ||
| <button type="button" | ||
| class="social-btn google-btn"> | ||
| </button> | ||
| </div> |
Comment on lines
+51
to
+57
| @Transactional | ||
| public void success(Long paymentId){ | ||
| Payment payment = paymentRepository.findById(paymentId) | ||
| .orElseThrow(() -> new ResourceNotFoundException("Payment not found with id: " + paymentId)); | ||
| payment.setStatus(PaymentStatus.SUCCESS); | ||
| payment.getBooking().setStatus(BookingStatus.PAID); | ||
| } |
Comment on lines
+35
to
+42
| @GetMapping("/mock/{id}") | ||
| public String mockPayment( | ||
| @PathVariable Long id, | ||
| Model model | ||
| ){ | ||
| model.addAttribute("paymentId", id); | ||
| return "client/payment/mock"; | ||
| } |
Comment on lines
+42
to
+46
| User u = new User(); | ||
| u.setEmail(email); | ||
| u.setFullName(name); | ||
| u.setUsername(name); | ||
| u.setRole(UserRole.USER); |
Comment on lines
18
to
+22
| .authorizeHttpRequests(auth -> auth | ||
|
|
||
| // public pages | ||
| .requestMatchers( | ||
| "/", | ||
| "/tours", |
52ffd43 to
0d022a8
Compare
0d022a8 to
bace8c8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
🔗 Related Issue
https://edu-redmine.sun-asterisk.vn/issues/98580
https://edu-redmine.sun-asterisk.vn/issues/98579
https://edu-redmine.sun-asterisk.vn/issues/98578
https://edu-redmine.sun-asterisk.vn/issues/98576
🛠 Type of Change
📦 How to Test
📸 Screenshots or Screen Recordings