-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from nathan29849/backend
[Team-15][BE] 포키&나단의 airbnb 프로젝트 PR2
- Loading branch information
Showing
20 changed files
with
483 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
backend/src/main/java/team15/airbnb/domain/BaseEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package team15.airbnb.domain; | ||
|
||
import java.time.LocalDateTime; | ||
import javax.persistence.Column; | ||
import javax.persistence.MappedSuperclass; | ||
import javax.validation.constraints.NotNull; | ||
|
||
@MappedSuperclass | ||
public class BaseEntity { | ||
|
||
@NotNull | ||
private boolean isDeleted; | ||
|
||
@NotNull | ||
@Column(columnDefinition = "TIMESTAMP") | ||
private LocalDateTime createdAt; | ||
|
||
@NotNull | ||
@Column(columnDefinition = "TIMESTAMP") | ||
private LocalDateTime lastModifiedAt; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package team15.airbnb.domain; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import team15.airbnb.domain.accommodation.Accommodation; | ||
|
||
@Entity | ||
public class Favorite { | ||
|
||
@Id | ||
@Column(name = "favorite_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "accommodation_id") | ||
private Accommodation accommodation; | ||
} |
40 changes: 40 additions & 0 deletions
40
backend/src/main/java/team15/airbnb/domain/Reservation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package team15.airbnb.domain; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.time.LocalDateTime; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import team15.airbnb.domain.accommodation.Accommodation; | ||
|
||
@Entity | ||
public class Reservation extends BaseEntity{ | ||
|
||
@Id | ||
@Column(name = "reservation_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
@Column(columnDefinition = "TIMESTAMP") | ||
private LocalDateTime checkInDate; | ||
|
||
@NotNull | ||
@Column(columnDefinition = "TIMESTAMP") | ||
private LocalDateTime checkOutDate; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "accommodation_id") | ||
private Accommodation accommodation; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package team15.airbnb.domain; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import team15.airbnb.domain.accommodation.Accommodation; | ||
|
||
@Entity | ||
public class Review extends BaseEntity{ | ||
|
||
@Id | ||
@Column(name = "review_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
private String content; | ||
|
||
@NotNull | ||
private double starRating; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "accommodation_id") | ||
private Accommodation accommodation; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package team15.airbnb.domain; | ||
|
||
import javax.persistence.Table; | ||
import javax.validation.constraints.NotNull; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.OneToMany; | ||
|
||
|
||
@Entity | ||
@Table(name = "users") | ||
public class User extends BaseEntity{ | ||
|
||
@Id | ||
@Column(name = "user_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
@Column(name = "user_name", length = 20) | ||
private String name; | ||
|
||
@Enumerated(value = EnumType.STRING) | ||
@Column(name = "user_type") | ||
private UserType type; | ||
|
||
private String profileImage; | ||
|
||
@OneToMany(mappedBy = "user") | ||
private List<Favorite> favorites = new ArrayList<>(); | ||
|
||
@OneToMany(mappedBy = "user") | ||
private List<Review> reviews = new ArrayList<>(); | ||
|
||
@OneToMany(mappedBy = "user") | ||
private List<Reservation> reservations = new ArrayList<>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package team15.airbnb.domain; | ||
|
||
public enum UserType { | ||
CUSTOMER, HOST, SUPER_HOST | ||
} |
94 changes: 94 additions & 0 deletions
94
backend/src/main/java/team15/airbnb/domain/accommodation/Accommodation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package team15.airbnb.domain.accommodation; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.persistence.Column; | ||
import javax.persistence.Embedded; | ||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.OneToMany; | ||
import javax.persistence.OneToOne; | ||
import team15.airbnb.domain.BaseEntity; | ||
import team15.airbnb.domain.Reservation; | ||
import team15.airbnb.domain.Review; | ||
import team15.airbnb.domain.User; | ||
|
||
@Entity | ||
public class Accommodation extends BaseEntity { | ||
|
||
@Id | ||
@Column(name = "accommodation_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(length = 50) | ||
private String accommodationName; | ||
|
||
@Column(name = "accommodation_description") | ||
private String description; | ||
|
||
@Enumerated(value = EnumType.STRING) | ||
@Column(name = "accommodation_type") | ||
private AccommodationType type; | ||
|
||
@NotNull | ||
private int price; | ||
|
||
private String mainImage; | ||
|
||
@Embedded | ||
private Vat vat; | ||
|
||
@NotNull | ||
@Embedded | ||
private Address address; | ||
|
||
@Embedded | ||
private AccommodationDetails details; | ||
|
||
@NotNull | ||
@Column(columnDefinition = "TIMESTAMP") | ||
private LocalDateTime checkInTime; | ||
|
||
@NotNull | ||
@Column(columnDefinition = "TIMESTAMP") | ||
private LocalDateTime checkOutTime; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User host; | ||
|
||
@NotNull | ||
@OneToMany(mappedBy = "accommodation") | ||
private List<Review> reviews = new ArrayList<>(); | ||
|
||
@NotNull | ||
@OneToMany(mappedBy = "accommodation") | ||
private List<Reservation> reservations = new ArrayList<>(); | ||
|
||
@NotNull | ||
@OneToMany(mappedBy = "accommodation") | ||
private List<AccommodationImage> images = new ArrayList<>(); | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "policy_id") | ||
private DiscountPolicy discountPolicy; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "event_id") | ||
private Event event; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "region_id") | ||
private Region region; | ||
} |
20 changes: 20 additions & 0 deletions
20
backend/src/main/java/team15/airbnb/domain/accommodation/AccommodationDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package team15.airbnb.domain.accommodation; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import javax.persistence.Embeddable; | ||
|
||
@Embeddable | ||
public class AccommodationDetails { | ||
|
||
@NotNull | ||
private int maximumGuestNumber; | ||
|
||
@NotNull | ||
private int roomCount; | ||
|
||
@NotNull | ||
private int bedCount; | ||
|
||
@NotNull | ||
private int bathroomCount; | ||
} |
29 changes: 29 additions & 0 deletions
29
backend/src/main/java/team15/airbnb/domain/accommodation/AccommodationImage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package team15.airbnb.domain.accommodation; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import team15.airbnb.domain.BaseEntity; | ||
|
||
@Entity | ||
public class AccommodationImage extends BaseEntity { | ||
|
||
@Id | ||
@Column(name = "accommodation_image_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
private String url; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "accommodation_id") | ||
private Accommodation accommodation; | ||
} |
5 changes: 5 additions & 0 deletions
5
backend/src/main/java/team15/airbnb/domain/accommodation/AccommodationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package team15.airbnb.domain.accommodation; | ||
|
||
public enum AccommodationType { | ||
RESIDENCE, HOTEL, MOTEL, GUEST_HOUSE | ||
} |
38 changes: 38 additions & 0 deletions
38
backend/src/main/java/team15/airbnb/domain/accommodation/Address.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package team15.airbnb.domain.accommodation; | ||
|
||
import javax.persistence.*; | ||
import javax.validation.constraints.NotNull; | ||
|
||
import team15.airbnb.domain.BaseEntity; | ||
|
||
@Embeddable | ||
public class Address { | ||
|
||
@NotNull | ||
@Enumerated(value = EnumType.STRING) | ||
@Column(length = 20) | ||
private Country country; | ||
|
||
@NotNull | ||
@Enumerated(value = EnumType.STRING) | ||
@Column(length = 20) | ||
private City city; | ||
|
||
@NotNull | ||
@Column(length = 50) | ||
private String firstAddress; | ||
|
||
@NotNull | ||
@Column(length = 50) | ||
private String secondAddress; | ||
|
||
@NotNull | ||
@Column(length = 10) | ||
private String zipcode; | ||
|
||
@NotNull | ||
private double latitude; | ||
|
||
@NotNull | ||
private double longitude; | ||
} |
5 changes: 5 additions & 0 deletions
5
backend/src/main/java/team15/airbnb/domain/accommodation/City.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package team15.airbnb.domain.accommodation; | ||
|
||
public enum City { | ||
SEOUL, GWANGJU, UIJEONGBU, SUWON,DAEGU, ULJIN, DAEJUN, BUCHEON | ||
} |
5 changes: 5 additions & 0 deletions
5
backend/src/main/java/team15/airbnb/domain/accommodation/Country.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package team15.airbnb.domain.accommodation; | ||
|
||
public enum Country { | ||
SOUTH_KOREA, JAPAN, CHINA | ||
} |
Oops, something went wrong.