Skip to content

task_98580_98578_98576_register_and_comment#7

Open
ngocvt-0484 wants to merge 1 commit into
awesome-academy:masterfrom
ngocvt-0484:task_98580_98578_98576_register_and_comment
Open

task_98580_98578_98576_register_and_comment#7
ngocvt-0484 wants to merge 1 commit into
awesome-academy:masterfrom
ngocvt-0484:task_98580_98578_98576_register_and_comment

Conversation

@ngocvt-0484

Copy link
Copy Markdown
Contributor

📝 Description

  • Đăng kí tài khoản
  • Login qua gmail
  • Cho phép hủy đặt tour, thanh toán tour giả lập
  • Cho phép review và rating tour

🔗 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

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • ♻️ Code refactoring (cleanup, minor improvements, no API changes)
  • 📚 Documentation update
  • ⚡ Performance improvement
  • 🧪 Test addition or update

📦 How to Test

📸 Screenshots or Screen Recordings

image image image image image image

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +168 to +173
<div class="social-login">
<button type="button"
class="social-btn google-btn">
🔍 Google
</button>
</div>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

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);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

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";
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +42 to +46
User u = new User();
u.setEmail(email);
u.setFullName(name);
u.setUsername(name);
u.setRole(UserRole.USER);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 18 to +22
.authorizeHttpRequests(auth -> auth

// public pages
.requestMatchers(
"/",
"/tours",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@ngocvt-0484 ngocvt-0484 force-pushed the task_98580_98578_98576_register_and_comment branch from 52ffd43 to 0d022a8 Compare June 29, 2026 09:23
@ngocvt-0484 ngocvt-0484 force-pushed the task_98580_98578_98576_register_and_comment branch from 0d022a8 to bace8c8 Compare June 29, 2026 09: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.

2 participants