- Timestamp:
- 02/13/25 11:03:11 (4 months ago)
- Branches:
- master
- Children:
- 9868304
- Parents:
- 3d60932
- Location:
- src/main
- Files:
-
- 5 added
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/skychasemk/controller/ReviewController.java
r3d60932 ra70b5a4 3 3 import com.example.skychasemk.dto.ReviewDTO; 4 4 import com.example.skychasemk.model.Review; 5 import com.example.skychasemk.repository.ReviewRepository; 5 6 import com.example.skychasemk.services.ReviewService; 6 7 import org.springframework.beans.factory.annotation.Autowired; … … 17 18 @Autowired 18 19 private ReviewService reviewService; 20 @Autowired 21 private ReviewRepository reviewRepository; 19 22 20 23 // Get all reviews … … 22 25 public List<Review> getAllReviews() { 23 26 return reviewService.getAllReviews(); 27 } 28 29 30 @GetMapping("/{flightId}") 31 public List<Review> getReviewsByFlightId(@PathVariable("flightId") Integer flightId) { 32 return reviewRepository.findReviews(flightId); 24 33 } 25 34 -
src/main/java/com/example/skychasemk/repository/ReviewRepository.java
r3d60932 ra70b5a4 4 4 import org.springframework.data.jpa.repository.JpaRepository; 5 5 import org.springframework.data.jpa.repository.Query; 6 import org.springframework.data.repository.query.Param; 6 7 7 8 import java.util.List; … … 9 10 public interface ReviewRepository extends JpaRepository<Review, Integer> { 10 11 @Query("SELECT r from Review r where r.targetID = :flightId") 11 List<Review> findReviews( );12 List<Review> findReviews(@Param("flightId") Integer flightId); 12 13 } 13 14 -
src/main/java/com/example/skychasemk/services/ReviewService.java
r3d60932 ra70b5a4 18 18 19 19 public List<Review> getAllReviews() { 20 return reviewRepository.find Reviews();20 return reviewRepository.findAll(); 21 21 } 22 22 -
src/main/resources/static/ReviewPage.html
r3d60932 ra70b5a4 20 20 21 21 <div class="review-list"> 22 <div v-for="review in reviews" :key="review. reviewid" class="review-item">23 <h3> Description</h3>24 <p>{{ review. review_comment}}</p>22 <div v-for="review in reviews" :key="review.id" class="review-item"> 23 <h3>{{ review.subject }}</h3> 24 <p>{{ review.description }}</p> 25 25 <span>{{ review.date }}</span> 26 26 </div> … … 29 29 </div> 30 30 </div> 31 <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script> 32 <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> 31 33 32 <script> 34 33 new Vue({ 35 34 el: '#app', 36 35 data: { 37 reviews: [] 36 reviews: [ 37 { 38 id: 1, 39 subject: 'Great experience!', 40 description: 'The flight was amazing, the service was excellent, and the views were breathtaking.', 41 date: '2025-02-01', 42 }, 43 { 44 id: 2, 45 subject: 'Good but delayed', 46 description: 'The flight was comfortable, but it was delayed by two hours, which caused some inconvenience.', 47 date: '2025-02-02', 48 }, 49 { 50 id: 3, 51 subject: 'Okay, but not perfect', 52 description: 'Everything was fine, but the food options could have been better.', 53 date: '2025-02-03', 54 }, 55 ] 38 56 }, 39 57 methods: { … … 45 63 axios.get('api/reviews') 46 64 .then(response => { 47 this.reviews = response.data; 48 console.log(response.data); 65 this.review = response.data; 49 66 }) 50 67 .catch(error => { -
src/main/resources/templates/WishlistPage.html
r3d60932 ra70b5a4 81 81 }, 82 82 showReviews(flight) { 83 window.location.href = `/reviews?flightId=${flight. flightid}`;83 window.location.href = `/reviews?flightId=${flight.id}`; 84 84 }, 85 85 logout() {
Note:
See TracChangeset
for help on using the changeset viewer.