Skip to content

Commit

Permalink
Merge pull request #8 from Prithvi333/prem2
Browse files Browse the repository at this point in the history
updated entity
  • Loading branch information
kumarprem66 authored Jun 15, 2023
2 parents 77b886c + 226288c commit 2e67b9c
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 74 deletions.
115 changes: 66 additions & 49 deletions entities/Booking.java
Original file line number Diff line number Diff line change
@@ -1,51 +1,68 @@
package com.masaiproject.tripManagement.entities;
//package com.masaiproject.tripManagement.entities;
//
//import com.fasterxml.jackson.annotation.JsonIgnore;
//import com.fasterxml.jackson.annotation.JsonSetter;
//import jakarta.persistence.*;
//import jakarta.validation.constraints.NotBlank;
//import jakarta.validation.constraints.NotEmpty;
//import jakarta.validation.constraints.NotNull;
//import lombok.AllArgsConstructor;
//import lombok.Data;
//import lombok.NoArgsConstructor;
//import org.springframework.data.annotation.CreatedDate;
//
//import java.time.LocalDate;
//import java.util.List;
//
//
//@Entity
//@Inheritance(strategy = InheritanceType.JOINED)
//@NoArgsConstructor
//@AllArgsConstructor
//@Data
//public class Booking {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private Integer bookingId;
//
// @NotNull(message = "booking type is important")
// private String bookingType;
//
//
// private String description;
//
// @NotNull(message = "give any booking title")
// private String bookingTitle;
//
// @CreatedDate
// private LocalDate bookingDate;
//
//
// @NotNull(message = "choose the package")
// @NotBlank(message = "choose the package")
// private String packageName;
//
// @NotNull(message = "mention the number of person that will be in this trip")
// private Integer number_Of_Person;
//
//
//// @OneToOne(cascade = CascadeType.ALL)
//// private Package aPackage;
//

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;

import java.time.LocalDate;


@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@NoArgsConstructor
@AllArgsConstructor
public class Booking {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer bookingId;

@NotNull(message = "booking type is important")
private String bookingType;


private String description;

@NotNull(message = "give any booking title")
private String bookingTitle;

@CreatedDate
private LocalDate bookingDate;

@NotNull(message = "mention the number of person that will be in this trip")
@NotBlank(message = "mention the number of person that will be in this trip")
private Integer number_Of_Person;

@NotNull(message = "you have to choose a package")
@NotEmpty(message = "you have to choose a package")
@OneToOne(cascade = CascadeType.ALL)
private Package aPackage;






}
import jakarta.persistence.OneToMany;

//@OneToMany(cascade = CascadeType.ALL)
// @JsonIgnore
// private List<PaymentDetails> payment;
////
//// @JoinColumn(name = "customer_id")
//// @ManyToOne(cascade = CascadeType.ALL)
//// @JsonIgnore
//// private Customer customerBooking;
//
//
//
//}
13 changes: 8 additions & 5 deletions entities/Customer.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ public class Customer {
private String email;


@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "booking_id")
// @JsonIgnore
private Booking booking;
@OneToMany(cascade = CascadeType.ALL,mappedBy = "customerBooking",fetch = FetchType.EAGER)
@JsonIgnore
private List<HotelBooking> hotelBookings;

@OneToMany(cascade = CascadeType.ALL,mappedBy = "customer",fetch = FetchType.EAGER)
@JsonIgnore
private List<PackageBooking> packageBookings;

@JsonIgnore
@OneToMany(cascade = CascadeType.ALL,mappedBy = "customer")
@OneToMany(cascade = CascadeType.ALL,mappedBy = "customerFeedback")
private List<Feedback> feedback ;
}
1 change: 0 additions & 1 deletion entities/Destination.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class Destination {
@NotNull(message = "Please provide the destination name")
private String name;

@NotBlank(message = "Please choose desEnvironment")
@NotNull(message = "Please choose desEnvironment")
private DesEnvironment desEnvironment;

Expand Down
2 changes: 1 addition & 1 deletion entities/Feedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ public class Feedback {

@ManyToOne()
@JoinColumn(name = "customer_id")
private Customer customer;
private Customer customerFeedback;
}
52 changes: 48 additions & 4 deletions entities/HotelBooking.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,59 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;

import java.time.LocalDate;
import java.util.List;

@Entity
@PrimaryKeyJoinColumn(name = "hotel_booking_id")
public class HotelBooking extends Booking{
@Data
@NoArgsConstructor
@AllArgsConstructor
public class HotelBooking{

// @JsonIgnore
// @OneToOne(cascade = CascadeType.ALL,mappedBy = "booking")
// private Customer customer;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer bookingId;

@NotNull(message = "booking type is important")
private String bookingType;


private String description;

@NotNull(message = "give any booking title")
private String bookingTitle;

@CreatedDate
private LocalDate bookingDate;


@NotNull(message = "choose the package")
@NotBlank(message = "choose the package")
private String packageName;

@NotNull(message = "mention the number of person that will be in this trip")
private Integer number_Of_Person;

@JoinColumn(name = "customer_id")
@ManyToOne(cascade = CascadeType.ALL)
@JsonIgnore
@OneToOne(cascade = CascadeType.ALL,mappedBy = "booking")
private Customer customer;
private Customer customerBooking;


@OneToMany(cascade = CascadeType.ALL)
@JsonIgnore
private List<PaymentDetails> payment;

@OneToOne(cascade = CascadeType.ALL)
private Hotel hotel;
Expand Down
2 changes: 1 addition & 1 deletion entities/HotelType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public enum HotelType {

ONE_STAR,TWO_STAR,THREE_STAR,FOUR_STAR,FIVE_START
ONE_STAR,TWO_STAR,THREE_STAR,FOUR_STAR,FIVE_STAR
}
15 changes: 8 additions & 7 deletions entities/Package.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.masaiproject.tripManagement.entities;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand All @@ -25,7 +26,6 @@ public class Package {
@Size(min = 4,message = "min 4 is required")
private String packageName;

@NotBlank(message = "Please provide the hotel type")
@NotNull(message = "Please provide the hotel type")
private HotelType hotelType;

Expand All @@ -34,7 +34,7 @@ public class Package {
private String daysAndNight;


@NotBlank(message = "Please provide the package season")

@NotNull(message = "Please provide the package season")
private Season packageSeason;

Expand All @@ -53,13 +53,14 @@ public class Package {
private String packageDescription4;
private String packageDescription5;

@NotBlank(message = "please provide package cost")
private double packageCost;

@NotNull(message = "please provide package cost")
private Double packageCost;

@Embedded
private PaymentDetails payment;
@JsonIgnore
@OneToMany(cascade = CascadeType.ALL,mappedBy = "aPackage")
private List<PackageBooking> bookingList;

@JsonIgnore
@ManyToMany(cascade = CascadeType.ALL)
private List<Hotel> hotels;

Expand Down
47 changes: 43 additions & 4 deletions entities/PackageBooking.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,56 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;

import java.time.LocalDate;
import java.util.List;

@Entity
@PrimaryKeyJoinColumn (name = "package_booking_id")
public class PackageBooking extends Booking{
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PackageBooking{

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer bookingId;

@NotNull(message = "booking type is important")
private String bookingType;


private String description;

@NotNull(message = "give any booking title")
private String bookingTitle;

@CreatedDate
private LocalDate bookingDate;


@NotNull(message = "choose the package")
@NotBlank(message = "choose the package")
private String packageName;

@NotNull(message = "mention the number of person that will be in this trip")
private Integer number_Of_Person;

@JsonIgnore
@OneToOne(cascade = CascadeType.ALL,mappedBy = "booking")
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "customer_id")
private Customer customer;

@OneToMany(cascade = CascadeType.ALL)
@JsonIgnore
private List<PaymentDetails> payment;

@OneToOne(cascade = CascadeType.ALL)
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "package_id")
private Package aPackage;

Expand Down
21 changes: 19 additions & 2 deletions entities/PaymentDetails.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
package com.masaiproject.tripManagement.entities;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.aspectj.bridge.Message;

@Embeddable
import java.math.BigDecimal;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PaymentDetails {


@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer paymentId;

@NotNull(message = "type can not be null")
private PaymentType paymentType;

private double paymentMoney;
private PaymentStatus paymentStatus;

// @Column(name = "payment_money", columnDefinition = "DECIMAL(10, 2) DEFAULT 0.0")

@NotNull(message = "money can not be null")
private BigDecimal paymentMoney ;

private Integer bookingId;


}
6 changes: 6 additions & 0 deletions entities/PaymentStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.masaiproject.tripManagement.entities;

public enum PaymentStatus {

PENDING,FAILED,COMPLETED
}

0 comments on commit 2e67b9c

Please sign in to comment.