Skip to content

Commit

Permalink
Merge pull request #101 from Ajou-Hertz/feature/#100-practice-room-en…
Browse files Browse the repository at this point in the history
…tity
  • Loading branch information
Wo-ogie authored Apr 7, 2024
2 parents f166c64 + ba5e47b commit 9846c33
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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()
);
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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<PracticeRoomHashtag> content = new LinkedList<>();

}
Original file line number Diff line number Diff line change
@@ -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
);
}
}
Original file line number Diff line number Diff line change
@@ -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<PracticeRoomImage> content = new LinkedList<>();
}

0 comments on commit 9846c33

Please sign in to comment.