Changeset de83113 for src/main/java
- Timestamp:
- 02/17/25 21:52:11 (4 months ago)
- Branches:
- master
- Children:
- 62bba0c
- Parents:
- 9868304
- Location:
- src/main/java/com/example/skychasemk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/skychasemk/controller/BookingController.java
r9868304 rde83113 27 27 } 28 28 29 @PutMapping("/flights/{ id}")30 public Booking updateBooking(@PathVariable(" id") Integer bookingID, @RequestBody Booking booking) {29 @PutMapping("/flights/{bookingId}") 30 public Booking updateBooking(@PathVariable("bookingId") Integer bookingID, @RequestBody Booking booking) { 31 31 return bookingService.updateBooking(bookingID, booking); 32 32 } … … 40 40 public Booking createBooking(@RequestBody BookingDTO bookingRequest) { 41 41 Booking newBooking = new Booking(); 42 newBooking.setUserI D(bookingRequest.getUserID());42 newBooking.setUserId(bookingRequest.getUserId()); 43 43 newBooking.setFlightId(bookingRequest.getFlightId()); 44 44 newBooking.setBookingDate(LocalDate.now()); 45 45 newBooking.setStatus(Booking.payment_status.PENDING); 46 newBooking.setTotal Cost(bookingRequest.getTotalCost());46 newBooking.setTotal_cost(bookingRequest.getTotalCost()); 47 47 newBooking.setSeatNumber(bookingRequest.getSeatNumber()); 48 48 System.out.println("Saving Booking: " + newBooking); -
src/main/java/com/example/skychasemk/dto/BookingDTO.java
r9868304 rde83113 1 1 package com.example.skychasemk.dto; 2 2 3 import com.example.skychasemk.model.Flight; 3 import lombok.Getter; 4 import lombok.Setter; 4 5 5 6 import java.math.BigDecimal; … … 8 9 public class BookingDTO { 9 10 10 private Integer bookingID; 11 private Integer userID; 11 @Setter 12 private Integer bookingId; 13 14 @Getter 15 private Integer userId; 16 @Setter 17 @Getter 12 18 private Integer flightId; 19 @Setter 20 @Getter 13 21 private LocalDate bookingDate; 22 @Setter 23 @Getter 14 24 private PaymentStatus status; 25 @Setter 26 @Getter 15 27 private BigDecimal totalCost; 28 @Setter 29 @Getter 16 30 private Integer seatNumber; 17 18 public Integer getFlightId() {19 return flightId;20 }21 22 public void setFlightId(Integer flightId) {23 this.flightId = flightId;24 }25 31 26 32 public enum PaymentStatus { … … 30 36 } 31 37 32 // Getters and Setters 33 public Integer getBookingID() { 34 return bookingID; 38 public void setUserID(Integer userId) { 39 this.userId = userId; 35 40 } 36 41 37 public void setBookingID(Integer bookingID) {38 this.bookingID = bookingID;39 }40 41 public Integer getUserID() {42 return userID;43 }44 45 public void setUserID(Integer userID) {46 this.userID = userID;47 }48 49 public Integer getFlightID() {50 return flightId;51 }52 53 public void setFlightID(Integer flightId) {54 this.flightId = flightId;55 }56 57 public LocalDate getBookingDate() {58 return bookingDate;59 }60 61 public void setBookingDate(LocalDate bookingDate) {62 this.bookingDate = bookingDate;63 }64 65 public PaymentStatus getStatus() {66 return status;67 }68 69 public void setStatus(PaymentStatus status) {70 this.status = status;71 }72 73 public BigDecimal getTotalCost() {74 return totalCost;75 }76 77 public void setTotalCost(BigDecimal totalCost) {78 this.totalCost = totalCost;79 }80 81 public Integer getSeatNumber() {82 return seatNumber;83 }84 85 public void setSeatNumber(Integer seatNumber) {86 this.seatNumber = seatNumber;87 }88 42 } -
src/main/java/com/example/skychasemk/dto/PaymentDTO.java
r9868304 rde83113 1 1 package com.example.skychasemk.dto; 2 2 3 import com.example.skychasemk.model.Booking; 3 4 import lombok.Getter; 4 5 import lombok.Setter; … … 10 11 11 12 // Getters and Setters 13 @Setter 12 14 @Getter 13 15 private Long paymentID; 14 16 @Getter 15 17 private Integer bookingId; 16 private Integer userID; 18 @Setter 19 private Integer userId; 20 @Setter 17 21 @Getter 18 22 private PaymentMethod method; 23 @Setter 19 24 @Getter 20 25 private BigDecimal amount; 21 26 @Getter 22 27 private LocalDate transactionDate; 28 @Setter 23 29 @Getter 24 30 private PaymentStatus status; … … 38 44 CREDIT 39 45 } 40 public Integer getBookingID() { 41 return bookingId; 42 } 43 public void setPaymentID(Long paymentID) { 44 this.paymentID = paymentID; 46 47 48 public Long getUserId() { 49 return Long.valueOf(userId); 45 50 } 46 51 47 48 public Long getUserID() {49 return Long.valueOf(userID);50 }51 52 public void setUserID(Integer userID) {53 this.userID = userID;54 }55 56 public void setMethod(PaymentMethod method) {57 this.method = method;58 }59 60 public void setAmount(BigDecimal amount) {61 this.amount = amount;62 }63 64 public void setTransactionDate(LocalDate transactionDate) {65 this.transactionDate = transactionDate;66 }67 68 public void setStatus(PaymentStatus status) {69 this.status = status;70 }71 52 } 72 53 -
src/main/java/com/example/skychasemk/model/Booking.java
r9868304 rde83113 12 12 public class Booking { 13 13 14 @Setter15 @Getter16 14 @Id 17 15 @GeneratedValue(strategy = GenerationType.IDENTITY) 18 16 @Column(name = "bookingid") 19 17 20 private Integer bookingID; 21 @Setter 22 @Getter 18 private Integer bookingId; 23 19 @Column(name = "userid") 24 20 25 private Integer userI D;21 private Integer userId; 26 22 27 23 @Column(name = "booking_date") 28 24 29 25 private LocalDate booking_date; 30 @Setter 31 @Getter 26 32 27 @Column(name = "payment_status") 33 28 … … 62 57 } 63 58 64 public Integer getBookingI D() {65 return bookingI D;59 public Integer getBookingId() { 60 return bookingId; 66 61 } 67 62 68 public void setBookingI D(Integer bookingID) {69 this.bookingI D= bookingID;63 public void setBookingId(Integer bookingID) { 64 this.bookingId = bookingID; 70 65 } 71 66 72 public Integer getUserI D() {73 return userI D;67 public Integer getUserId() { 68 return userId; 74 69 } 75 70 76 public void setUserI D(Integer userID) {77 this.userI D = userID;71 public void setUserId(Integer userId) { 72 this.userId = userId; 78 73 } 79 74 … … 114 109 } 115 110 116 public BigDecimal getTotalCost() {117 return total_cost;118 }119 120 public void setTotalCost(BigDecimal totalCost) {121 this.total_cost = totalCost;122 }123 124 111 public Integer getSeatNumber() { 125 112 return seat_number; -
src/main/java/com/example/skychasemk/model/Payment.java
r9868304 rde83113 13 13 public class Payment { 14 14 15 @Setter 15 16 @Id 16 17 @GeneratedValue(strategy = GenerationType.IDENTITY) … … 19 20 private Integer paymentID; 20 21 21 @Column(name = "bookingid") 22 //@Column(name = "bookingId") 23 @Setter 24 @Column(name="bookingid") 25 private Integer bookingId; 26 @Getter 27 @Column(name = "userid") 22 28 23 private Integer bookingID; 24 @Column(name = "UserID") 25 26 private Integer userID; 29 private Integer userId; 27 30 @Setter 28 31 @Column(name = "payment_method") … … 39 42 40 43 private LocalDate transactionDate; 44 @Setter 45 @Getter 41 46 @Column(name = "payment_status") 42 47 43 48 @Enumerated(EnumType.STRING) 44 49 private PaymentStatus status; 50 45 51 46 52 public enum PaymentStatus { … … 56 62 } 57 63 58 public Integer get PaymentID() {59 return paymentID;64 public Integer getBookingID() { 65 return bookingId; 60 66 } 61 67 62 public Integer getBookingID() {63 return bookingID;68 public void setUserID(Integer userId) { 69 this.userId = userId; 64 70 } 65 71 66 public Integer getUserID() { 67 return userID; 68 } 69 70 public void setUserID(Integer userID) { 71 this.userID = userID; 72 } 73 74 public PaymentMethod getMethod() { 75 return method; 76 } 77 78 public void setMethod(PaymentMethod method) { 79 this.method = method; 80 } 81 82 public BigDecimal getAmount() { 83 return amount; 84 } 85 86 public void setPaymentID(Integer paymentID) { 87 this.paymentID = paymentID; 88 } 89 90 public void setBookingID(Integer bookingID) { 91 this.bookingID = bookingID; 92 } 93 94 public void setAmount(BigDecimal amount) { 95 this.amount = amount; 96 } 97 98 public LocalDate getTransactionDate() { 99 return transactionDate; 100 } 101 102 public void setTransactionDate(LocalDate transactionDate) { 103 this.transactionDate = transactionDate; 104 } 105 106 public PaymentStatus getStatus() { 107 return status; 108 } 109 110 public void setStatus(PaymentStatus status) { 111 this.status = status; 112 } 113 114 public void setUserID(Long userID) { 115 this.userID = Math.toIntExact(userID); 72 public void setUserId(Long userId) { 73 this.userId = Math.toIntExact(userId); 116 74 } 117 75 -
src/main/java/com/example/skychasemk/repository/PaymentRepository.java
r9868304 rde83113 9 9 10 10 public interface PaymentRepository extends JpaRepository<Payment, Integer> { 11 @Query("SELECT p FROM Payment p WHERE p.userI D = :userID")12 List<Payment> findByUserId(@Param("userID") Long userI D);11 @Query("SELECT p FROM Payment p WHERE p.userId = :userId") 12 List<Payment> findByUserId(@Param("userID") Long userId); 13 13 } 14 14 15 16 -
src/main/java/com/example/skychasemk/services/BookingService.java
r9868304 rde83113 8 8 import java.util.List; 9 9 import java.util.Optional; 10 11 import static com.example.skychasemk.model.Booking.payment_status.COMPLETED; 12 10 13 11 14 @Service … … 29 32 public Booking updateBooking(Integer bookingID, Booking booking) { 30 33 if (bookingRepository.existsById(bookingID)) { 31 booking.setBookingID(bookingID); 34 booking.setStatus(COMPLETED); 35 booking.setUserId(booking.getUserId()); 36 booking.setTotal_cost(booking.getTotal_cost()); 37 booking.setFlightId(booking.getFlightId()); 38 booking.setBooking_date(booking.getBooking_date()); 32 39 return bookingRepository.save(booking); 33 40 } else { -
src/main/java/com/example/skychasemk/services/PaymentService.java
r9868304 rde83113 55 55 56 56 public Payment createTransaction(PaymentDTO dto){ 57 //ApplicationUser user = userRepository.findById(dto.getUserID()) 58 // .orElseThrow(() -> new RuntimeException("User not found")); 59 57 System.out.println( dto); 60 58 Payment payment = new Payment(); 61 59 payment.setAmount(dto.getAmount()); 62 payment.setBookingI D(dto.getBookingID());63 //payment.setUserID(dto.getUserID());60 payment.setBookingId(dto.getBookingId()); 61 payment.setUserId(dto.getUserId()); 64 62 payment.setStatus(COMPLETED); 65 63 payment.setMethod(CREDIT);
Note:
See TracChangeset
for help on using the changeset viewer.