diff --git a/src/main/java/com/ajou/hertz/domain/practice_room/dto/PracticeRoomImageDto.java b/src/main/java/com/ajou/hertz/domain/practice_room/dto/PracticeRoomImageDto.java new file mode 100644 index 0000000..54a01c5 --- /dev/null +++ b/src/main/java/com/ajou/hertz/domain/practice_room/dto/PracticeRoomImageDto.java @@ -0,0 +1,27 @@ +package com.ajou.hertz.domain.practice_room.dto; + +import com.ajou.hertz.domain.practice_room.entity.PracticeRoomImage; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@Getter + +public class PracticeRoomImageDto { + + private Long id; + private String name; + private String url; + + public static PracticeRoomImageDto from(PracticeRoomImage practiceRoomImage) { + return new PracticeRoomImageDto( + practiceRoomImage.getId(), + practiceRoomImage.getOriginalName(), + practiceRoomImage.getUrl() + ); + } +} diff --git a/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoom.java b/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoom.java new file mode 100644 index 0000000..e3f0aea --- /dev/null +++ b/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoom.java @@ -0,0 +1,79 @@ +package com.ajou.hertz.domain.practice_room.entity; + +import com.ajou.hertz.common.entity.Coordinate; +import com.ajou.hertz.common.entity.FullAddress; +import com.ajou.hertz.common.entity.TimeTrackedBaseEntity; +import com.ajou.hertz.domain.user.entity.User; + +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Getter +@Entity +public class PracticeRoom extends TimeTrackedBaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "practice_room_id", nullable = false) + private Long id; + + @JoinColumn(name = "seller_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY) + private User seller; + + @Column(nullable = false) + private String title; + + @Column(nullable = false) + @Embedded + private FullAddress fullAddress; + + @Column(nullable = false) + private Boolean hasSoundEquipment; + + @Column(nullable = false) + private Boolean hasInstrument; + + @Column(nullable = false) + private Integer pricePerDay; + + @Column(nullable = false) + private Integer pricePerHour; + + @Column(nullable = false) + private Integer pricePerMonth; + + @Column(nullable = false) + private Short capacity; + + @Column(nullable = false) + private String size; + + @Column(nullable = false) + private Boolean hasParkingLot; + + @Column(length = 1000, nullable = false) + private String description; + + @Embedded + private Coordinate coordinate; + + @Embedded + private PracticeRoomImages images = new PracticeRoomImages(); + + @Embedded + private PracticeRoomHashtags hashtags = new PracticeRoomHashtags(); +} diff --git a/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomHashtag.java b/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomHashtag.java new file mode 100644 index 0000000..1d1cb19 --- /dev/null +++ b/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomHashtag.java @@ -0,0 +1,39 @@ +package com.ajou.hertz.domain.practice_room.entity; + +import com.ajou.hertz.common.entity.BaseEntity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Getter +@Entity +public class PracticeRoomHashtag extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "practice_room_hashtag_id", nullable = false) + private Long id; + + @JoinColumn(name = "practice_room_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY) + private PracticeRoom practiceRoom; + + @Column(length = 10, nullable = false) + private String content; + + public static PracticeRoomHashtag create(PracticeRoom concertHall, String content) { + return new PracticeRoomHashtag(null, concertHall, content); + } +} diff --git a/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomHashtags.java b/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomHashtags.java new file mode 100644 index 0000000..f620389 --- /dev/null +++ b/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomHashtags.java @@ -0,0 +1,20 @@ +package com.ajou.hertz.domain.practice_room.entity; + +import java.util.LinkedList; +import java.util.List; + +import jakarta.persistence.Embeddable; +import jakarta.persistence.OneToMany; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; + +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Embeddable +public class PracticeRoomHashtags { + + @OneToMany(mappedBy = "practiceRoom") + private List content = new LinkedList<>(); + +} diff --git a/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomImage.java b/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomImage.java new file mode 100644 index 0000000..e16f7f2 --- /dev/null +++ b/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomImage.java @@ -0,0 +1,48 @@ +package com.ajou.hertz.domain.practice_room.entity; + +import com.ajou.hertz.common.entity.FileEntity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Getter +@Entity + +public class PracticeRoomImage extends FileEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "concert_hall_image_id", nullable = false) + private Long id; + + @JoinColumn(name = "practice_room", nullable = false) + @ManyToOne(fetch = FetchType.LAZY) + private PracticeRoom practiceRoom; + + private PracticeRoomImage(Long id, PracticeRoom practiceRoom, String originalName, String storedName, String url) { + super(originalName, storedName, url); + this.id = id; + this.practiceRoom = practiceRoom; + } + + public static PracticeRoomImage create(PracticeRoom practiceRoom, String originalName, String storedName, + String url) { + return new PracticeRoomImage( + null, + practiceRoom, + originalName, + storedName, + url + ); + } +} diff --git a/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomImages.java b/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomImages.java new file mode 100644 index 0000000..96e34b4 --- /dev/null +++ b/src/main/java/com/ajou/hertz/domain/practice_room/entity/PracticeRoomImages.java @@ -0,0 +1,20 @@ +package com.ajou.hertz.domain.practice_room.entity; + +import java.util.LinkedList; +import java.util.List; + +import jakarta.persistence.Embeddable; +import jakarta.persistence.OneToMany; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; + +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Embeddable + +public class PracticeRoomImages { + + @OneToMany(mappedBy = "practiceRoom") + private List content = new LinkedList<>(); +}