Skip to content

Commit

Permalink
Merge pull request #7 from Prithvi333/prem1
Browse files Browse the repository at this point in the history
fixed bugs related to entities
  • Loading branch information
Prithvi333 authored Jun 15, 2023
2 parents 258da64 + 4b50087 commit 77b886c
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 20 deletions.
6 changes: 6 additions & 0 deletions entities/Booking.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down Expand Up @@ -37,6 +38,11 @@ public class Booking {
@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;




Expand Down
21 changes: 21 additions & 0 deletions entities/Bus.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,38 @@

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 java.time.LocalDate;
import java.util.List;

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

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

@NotBlank(message = "Please provide the destination name")
@NotNull(message = "Please provide the destination name")
private String busType;

@NotBlank(message = "Please provide the destination name")
@NotNull(message = "Please provide the destination name")
private String busNumber;

@NotBlank(message = "Please provide the destination name")
@NotNull(message = "Please provide the destination name")
private Integer capacity;

@JsonIgnore
@ManyToMany(cascade = CascadeType.ALL)
private List<Route> routes;

Expand All @@ -23,6 +43,7 @@ public class Bus {
@JsonIgnore
private Travels travel;


@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "bus_destination",joinColumns = {@JoinColumn(referencedColumnName = "busId")},inverseJoinColumns = {@JoinColumn(referencedColumnName = "desId")})
private List<Destination> destinationList;
Expand Down
7 changes: 4 additions & 3 deletions entities/Customer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import lombok.NoArgsConstructor;

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

@Entity
Expand Down Expand Up @@ -40,11 +41,10 @@ public class Customer {

@NotBlank(message = "Please provide the customer password")
@NotNull(message = "Please provide the customer password")
@Size(min = 6,max = 10,message = "min 15 and max 15 characters allowed only")
@Size(min = 15,max = 15,message = "min 15 and max 15 characters allowed only")
private String aadharId;


@NotBlank(message = "Please select gender")
@NotNull(message = "Please select gender")
private Gender gender;

Expand All @@ -66,9 +66,10 @@ public class Customer {

@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "booking_id")
// @JsonIgnore
private Booking booking;

@JsonIgnore
@OneToMany(cascade = CascadeType.ALL,mappedBy = "customer")
private List<Feedback> feedback;
private List<Feedback> feedback ;
}
26 changes: 21 additions & 5 deletions entities/Destination.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
package com.masaiproject.tripManagement.entities;

import jakarta.persistence.CascadeType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany;
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 java.util.List;

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

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

@NotBlank(message = "Please provide the destination name")
@NotNull(message = "Please provide the destination name")
private String name;

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

@ManyToMany(cascade = CascadeType.ALL,mappedBy = "destinationList")

@JsonIgnore
private List<Bus> bus;

@JsonIgnore
@OneToMany(mappedBy = "destination",cascade = CascadeType.ALL)
private List<Hotel> hotels;

Expand Down
24 changes: 21 additions & 3 deletions entities/Feedback.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
package com.masaiproject.tripManagement.entities;

import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
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;

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

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

@NotBlank(message = "Please provide the feedback details")
@NotNull(message = "Please provide the feedback details")
private String feedback;
private String rating;

@NotBlank(message = "Please provide the rating as well")
@NotNull(message = "Please provide the rating as well")
private Integer rating;

@CreatedDate
private LocalDate submitDate;

@ManyToOne()
Expand Down
2 changes: 0 additions & 2 deletions entities/Package.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public class Package {
@ManyToMany(cascade = CascadeType.ALL)
private List<Hotel> hotels;

@OneToOne(mappedBy = "aPackage")
private Booking booking;



Expand Down
8 changes: 1 addition & 7 deletions entities/PaymentDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@
@Embeddable
public class PaymentDetails {

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

private Integer paymentId;

@NotNull(message = "payment type is required")
@NotNull(message = "payment type is required")
private PaymentType paymentType;

@NotNull(message = "payment money is required")
@NotNull(message = "payment money is required")
private double paymentMoney;


Expand Down

0 comments on commit 77b886c

Please sign in to comment.